All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.sagemakeredge.model.Model Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Sagemaker Edge module holds the client classes that are used for communicating with Sagemaker Edge.

There is a newer version: 2.29.15
Show newest version
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
 * the License. A copy of the License is located at
 * 
 * http://aws.amazon.com/apache2.0
 * 
 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
 * and limitations under the License.
 */

package software.amazon.awssdk.services.sagemakeredge.model;

import java.io.Serializable;
import java.time.Instant;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 * 

* Information about a model deployed on an edge device that is registered with SageMaker Edge Manager. *

*/ @Generated("software.amazon.awssdk:codegen") public final class Model implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField MODEL_NAME_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("ModelName").getter(getter(Model::modelName)).setter(setter(Builder::modelName)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ModelName").build()).build(); private static final SdkField MODEL_VERSION_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("ModelVersion").getter(getter(Model::modelVersion)).setter(setter(Builder::modelVersion)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ModelVersion").build()).build(); private static final SdkField LATEST_SAMPLE_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT) .memberName("LatestSampleTime").getter(getter(Model::latestSampleTime)).setter(setter(Builder::latestSampleTime)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LatestSampleTime").build()).build(); private static final SdkField LATEST_INFERENCE_FIELD = SdkField. builder(MarshallingType.INSTANT) .memberName("LatestInference").getter(getter(Model::latestInference)).setter(setter(Builder::latestInference)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LatestInference").build()).build(); private static final SdkField> MODEL_METRICS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("ModelMetrics") .getter(getter(Model::modelMetrics)) .setter(setter(Builder::modelMetrics)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ModelMetrics").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(EdgeMetric::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(MODEL_NAME_FIELD, MODEL_VERSION_FIELD, LATEST_SAMPLE_TIME_FIELD, LATEST_INFERENCE_FIELD, MODEL_METRICS_FIELD)); private static final long serialVersionUID = 1L; private final String modelName; private final String modelVersion; private final Instant latestSampleTime; private final Instant latestInference; private final List modelMetrics; private Model(BuilderImpl builder) { this.modelName = builder.modelName; this.modelVersion = builder.modelVersion; this.latestSampleTime = builder.latestSampleTime; this.latestInference = builder.latestInference; this.modelMetrics = builder.modelMetrics; } /** *

* The name of the model. *

* * @return The name of the model. */ public final String modelName() { return modelName; } /** *

* The version of the model. *

* * @return The version of the model. */ public final String modelVersion() { return modelVersion; } /** *

* The timestamp of the last data sample taken. *

* * @return The timestamp of the last data sample taken. */ public final Instant latestSampleTime() { return latestSampleTime; } /** *

* The timestamp of the last inference that was made. *

* * @return The timestamp of the last inference that was made. */ public final Instant latestInference() { return latestInference; } /** * For responses, this returns true if the service returned a value for the ModelMetrics property. This DOES NOT * check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property). * This is useful because the SDK will never return a null collection or map, but you may need to differentiate * between the service returning nothing (or null) and the service returning an empty collection or map. For * requests, this returns true if a value for the property was specified in the request builder, and false if a * value was not specified. */ public final boolean hasModelMetrics() { return modelMetrics != null && !(modelMetrics instanceof SdkAutoConstructList); } /** *

* Information required for model metrics. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasModelMetrics} method. *

* * @return Information required for model metrics. */ public final List modelMetrics() { return modelMetrics; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(modelName()); hashCode = 31 * hashCode + Objects.hashCode(modelVersion()); hashCode = 31 * hashCode + Objects.hashCode(latestSampleTime()); hashCode = 31 * hashCode + Objects.hashCode(latestInference()); hashCode = 31 * hashCode + Objects.hashCode(hasModelMetrics() ? modelMetrics() : null); return hashCode; } @Override public final boolean equals(Object obj) { return equalsBySdkFields(obj); } @Override public final boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof Model)) { return false; } Model other = (Model) obj; return Objects.equals(modelName(), other.modelName()) && Objects.equals(modelVersion(), other.modelVersion()) && Objects.equals(latestSampleTime(), other.latestSampleTime()) && Objects.equals(latestInference(), other.latestInference()) && hasModelMetrics() == other.hasModelMetrics() && Objects.equals(modelMetrics(), other.modelMetrics()); } /** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. */ @Override public final String toString() { return ToString.builder("Model").add("ModelName", modelName()).add("ModelVersion", modelVersion()) .add("LatestSampleTime", latestSampleTime()).add("LatestInference", latestInference()) .add("ModelMetrics", hasModelMetrics() ? modelMetrics() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "ModelName": return Optional.ofNullable(clazz.cast(modelName())); case "ModelVersion": return Optional.ofNullable(clazz.cast(modelVersion())); case "LatestSampleTime": return Optional.ofNullable(clazz.cast(latestSampleTime())); case "LatestInference": return Optional.ofNullable(clazz.cast(latestInference())); case "ModelMetrics": return Optional.ofNullable(clazz.cast(modelMetrics())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((Model) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The name of the model. *

* * @param modelName * The name of the model. * @return Returns a reference to this object so that method calls can be chained together. */ Builder modelName(String modelName); /** *

* The version of the model. *

* * @param modelVersion * The version of the model. * @return Returns a reference to this object so that method calls can be chained together. */ Builder modelVersion(String modelVersion); /** *

* The timestamp of the last data sample taken. *

* * @param latestSampleTime * The timestamp of the last data sample taken. * @return Returns a reference to this object so that method calls can be chained together. */ Builder latestSampleTime(Instant latestSampleTime); /** *

* The timestamp of the last inference that was made. *

* * @param latestInference * The timestamp of the last inference that was made. * @return Returns a reference to this object so that method calls can be chained together. */ Builder latestInference(Instant latestInference); /** *

* Information required for model metrics. *

* * @param modelMetrics * Information required for model metrics. * @return Returns a reference to this object so that method calls can be chained together. */ Builder modelMetrics(Collection modelMetrics); /** *

* Information required for model metrics. *

* * @param modelMetrics * Information required for model metrics. * @return Returns a reference to this object so that method calls can be chained together. */ Builder modelMetrics(EdgeMetric... modelMetrics); /** *

* Information required for model metrics. *

* This is a convenience method that creates an instance of the {@link List.Builder} avoiding the * need to create one manually via {@link List#builder()}. * * When the {@link Consumer} completes, {@link List.Builder#build()} is called immediately and its * result is passed to {@link #modelMetrics(List)}. * * @param modelMetrics * a consumer that will call methods on {@link List.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #modelMetrics(List) */ Builder modelMetrics(Consumer... modelMetrics); } static final class BuilderImpl implements Builder { private String modelName; private String modelVersion; private Instant latestSampleTime; private Instant latestInference; private List modelMetrics = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(Model model) { modelName(model.modelName); modelVersion(model.modelVersion); latestSampleTime(model.latestSampleTime); latestInference(model.latestInference); modelMetrics(model.modelMetrics); } public final String getModelName() { return modelName; } public final void setModelName(String modelName) { this.modelName = modelName; } @Override public final Builder modelName(String modelName) { this.modelName = modelName; return this; } public final String getModelVersion() { return modelVersion; } public final void setModelVersion(String modelVersion) { this.modelVersion = modelVersion; } @Override public final Builder modelVersion(String modelVersion) { this.modelVersion = modelVersion; return this; } public final Instant getLatestSampleTime() { return latestSampleTime; } public final void setLatestSampleTime(Instant latestSampleTime) { this.latestSampleTime = latestSampleTime; } @Override public final Builder latestSampleTime(Instant latestSampleTime) { this.latestSampleTime = latestSampleTime; return this; } public final Instant getLatestInference() { return latestInference; } public final void setLatestInference(Instant latestInference) { this.latestInference = latestInference; } @Override public final Builder latestInference(Instant latestInference) { this.latestInference = latestInference; return this; } public final List getModelMetrics() { List result = EdgeMetricsCopier.copyToBuilder(this.modelMetrics); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setModelMetrics(Collection modelMetrics) { this.modelMetrics = EdgeMetricsCopier.copyFromBuilder(modelMetrics); } @Override public final Builder modelMetrics(Collection modelMetrics) { this.modelMetrics = EdgeMetricsCopier.copy(modelMetrics); return this; } @Override @SafeVarargs public final Builder modelMetrics(EdgeMetric... modelMetrics) { modelMetrics(Arrays.asList(modelMetrics)); return this; } @Override @SafeVarargs public final Builder modelMetrics(Consumer... modelMetrics) { modelMetrics(Stream.of(modelMetrics).map(c -> EdgeMetric.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } @Override public Model build() { return new Model(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy