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

software.amazon.awssdk.services.sagemaker.model.ProductionVariantSummary Maven / Gradle / Ivy

/*
 * 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.sagemaker.model;

import java.io.Serializable;
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;

/**
 * 

* Describes weight and capacities for a production variant associated with an endpoint. If you sent a request to the * UpdateEndpointWeightsAndCapacities API and the endpoint status is Updating, you get * different desired and current values. *

*/ @Generated("software.amazon.awssdk:codegen") public final class ProductionVariantSummary implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField VARIANT_NAME_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("VariantName").getter(getter(ProductionVariantSummary::variantName)).setter(setter(Builder::variantName)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("VariantName").build()).build(); private static final SdkField> DEPLOYED_IMAGES_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("DeployedImages") .getter(getter(ProductionVariantSummary::deployedImages)) .setter(setter(Builder::deployedImages)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DeployedImages").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(DeployedImage::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField CURRENT_WEIGHT_FIELD = SdkField. builder(MarshallingType.FLOAT) .memberName("CurrentWeight").getter(getter(ProductionVariantSummary::currentWeight)) .setter(setter(Builder::currentWeight)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CurrentWeight").build()).build(); private static final SdkField DESIRED_WEIGHT_FIELD = SdkField. builder(MarshallingType.FLOAT) .memberName("DesiredWeight").getter(getter(ProductionVariantSummary::desiredWeight)) .setter(setter(Builder::desiredWeight)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DesiredWeight").build()).build(); private static final SdkField CURRENT_INSTANCE_COUNT_FIELD = SdkField. builder(MarshallingType.INTEGER) .memberName("CurrentInstanceCount").getter(getter(ProductionVariantSummary::currentInstanceCount)) .setter(setter(Builder::currentInstanceCount)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CurrentInstanceCount").build()) .build(); private static final SdkField DESIRED_INSTANCE_COUNT_FIELD = SdkField. builder(MarshallingType.INTEGER) .memberName("DesiredInstanceCount").getter(getter(ProductionVariantSummary::desiredInstanceCount)) .setter(setter(Builder::desiredInstanceCount)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DesiredInstanceCount").build()) .build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(VARIANT_NAME_FIELD, DEPLOYED_IMAGES_FIELD, CURRENT_WEIGHT_FIELD, DESIRED_WEIGHT_FIELD, CURRENT_INSTANCE_COUNT_FIELD, DESIRED_INSTANCE_COUNT_FIELD)); private static final long serialVersionUID = 1L; private final String variantName; private final List deployedImages; private final Float currentWeight; private final Float desiredWeight; private final Integer currentInstanceCount; private final Integer desiredInstanceCount; private ProductionVariantSummary(BuilderImpl builder) { this.variantName = builder.variantName; this.deployedImages = builder.deployedImages; this.currentWeight = builder.currentWeight; this.desiredWeight = builder.desiredWeight; this.currentInstanceCount = builder.currentInstanceCount; this.desiredInstanceCount = builder.desiredInstanceCount; } /** *

* The name of the variant. *

* * @return The name of the variant. */ public final String variantName() { return variantName; } /** * Returns true if the DeployedImages property was specified by the sender (it may be empty), or false if the sender * did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service. */ public final boolean hasDeployedImages() { return deployedImages != null && !(deployedImages instanceof SdkAutoConstructList); } /** *

* An array of DeployedImage objects that specify the Amazon EC2 Container Registry paths of the * inference images deployed on instances of this ProductionVariant. *

*

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

*

* You can use {@link #hasDeployedImages()} to see if a value was sent in this field. *

* * @return An array of DeployedImage objects that specify the Amazon EC2 Container Registry paths of * the inference images deployed on instances of this ProductionVariant. */ public final List deployedImages() { return deployedImages; } /** *

* The weight associated with the variant. *

* * @return The weight associated with the variant. */ public final Float currentWeight() { return currentWeight; } /** *

* The requested weight, as specified in the UpdateEndpointWeightsAndCapacities request. *

* * @return The requested weight, as specified in the UpdateEndpointWeightsAndCapacities request. */ public final Float desiredWeight() { return desiredWeight; } /** *

* The number of instances associated with the variant. *

* * @return The number of instances associated with the variant. */ public final Integer currentInstanceCount() { return currentInstanceCount; } /** *

* The number of instances requested in the UpdateEndpointWeightsAndCapacities request. *

* * @return The number of instances requested in the UpdateEndpointWeightsAndCapacities request. */ public final Integer desiredInstanceCount() { return desiredInstanceCount; } @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(variantName()); hashCode = 31 * hashCode + Objects.hashCode(hasDeployedImages() ? deployedImages() : null); hashCode = 31 * hashCode + Objects.hashCode(currentWeight()); hashCode = 31 * hashCode + Objects.hashCode(desiredWeight()); hashCode = 31 * hashCode + Objects.hashCode(currentInstanceCount()); hashCode = 31 * hashCode + Objects.hashCode(desiredInstanceCount()); 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 ProductionVariantSummary)) { return false; } ProductionVariantSummary other = (ProductionVariantSummary) obj; return Objects.equals(variantName(), other.variantName()) && hasDeployedImages() == other.hasDeployedImages() && Objects.equals(deployedImages(), other.deployedImages()) && Objects.equals(currentWeight(), other.currentWeight()) && Objects.equals(desiredWeight(), other.desiredWeight()) && Objects.equals(currentInstanceCount(), other.currentInstanceCount()) && Objects.equals(desiredInstanceCount(), other.desiredInstanceCount()); } /** * 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("ProductionVariantSummary").add("VariantName", variantName()) .add("DeployedImages", hasDeployedImages() ? deployedImages() : null).add("CurrentWeight", currentWeight()) .add("DesiredWeight", desiredWeight()).add("CurrentInstanceCount", currentInstanceCount()) .add("DesiredInstanceCount", desiredInstanceCount()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "VariantName": return Optional.ofNullable(clazz.cast(variantName())); case "DeployedImages": return Optional.ofNullable(clazz.cast(deployedImages())); case "CurrentWeight": return Optional.ofNullable(clazz.cast(currentWeight())); case "DesiredWeight": return Optional.ofNullable(clazz.cast(desiredWeight())); case "CurrentInstanceCount": return Optional.ofNullable(clazz.cast(currentInstanceCount())); case "DesiredInstanceCount": return Optional.ofNullable(clazz.cast(desiredInstanceCount())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((ProductionVariantSummary) 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 variant. *

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

* An array of DeployedImage objects that specify the Amazon EC2 Container Registry paths of the * inference images deployed on instances of this ProductionVariant. *

* * @param deployedImages * An array of DeployedImage objects that specify the Amazon EC2 Container Registry paths of * the inference images deployed on instances of this ProductionVariant. * @return Returns a reference to this object so that method calls can be chained together. */ Builder deployedImages(Collection deployedImages); /** *

* An array of DeployedImage objects that specify the Amazon EC2 Container Registry paths of the * inference images deployed on instances of this ProductionVariant. *

* * @param deployedImages * An array of DeployedImage objects that specify the Amazon EC2 Container Registry paths of * the inference images deployed on instances of this ProductionVariant. * @return Returns a reference to this object so that method calls can be chained together. */ Builder deployedImages(DeployedImage... deployedImages); /** *

* An array of DeployedImage objects that specify the Amazon EC2 Container Registry paths of the * inference images deployed on instances of this ProductionVariant. *

* This is a convenience 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 #deployedImages(List)}. * * @param deployedImages * 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 #deployedImages(List) */ Builder deployedImages(Consumer... deployedImages); /** *

* The weight associated with the variant. *

* * @param currentWeight * The weight associated with the variant. * @return Returns a reference to this object so that method calls can be chained together. */ Builder currentWeight(Float currentWeight); /** *

* The requested weight, as specified in the UpdateEndpointWeightsAndCapacities request. *

* * @param desiredWeight * The requested weight, as specified in the UpdateEndpointWeightsAndCapacities request. * @return Returns a reference to this object so that method calls can be chained together. */ Builder desiredWeight(Float desiredWeight); /** *

* The number of instances associated with the variant. *

* * @param currentInstanceCount * The number of instances associated with the variant. * @return Returns a reference to this object so that method calls can be chained together. */ Builder currentInstanceCount(Integer currentInstanceCount); /** *

* The number of instances requested in the UpdateEndpointWeightsAndCapacities request. *

* * @param desiredInstanceCount * The number of instances requested in the UpdateEndpointWeightsAndCapacities request. * @return Returns a reference to this object so that method calls can be chained together. */ Builder desiredInstanceCount(Integer desiredInstanceCount); } static final class BuilderImpl implements Builder { private String variantName; private List deployedImages = DefaultSdkAutoConstructList.getInstance(); private Float currentWeight; private Float desiredWeight; private Integer currentInstanceCount; private Integer desiredInstanceCount; private BuilderImpl() { } private BuilderImpl(ProductionVariantSummary model) { variantName(model.variantName); deployedImages(model.deployedImages); currentWeight(model.currentWeight); desiredWeight(model.desiredWeight); currentInstanceCount(model.currentInstanceCount); desiredInstanceCount(model.desiredInstanceCount); } public final String getVariantName() { return variantName; } @Override public final Builder variantName(String variantName) { this.variantName = variantName; return this; } public final void setVariantName(String variantName) { this.variantName = variantName; } public final List getDeployedImages() { List result = DeployedImagesCopier.copyToBuilder(this.deployedImages); if (result instanceof SdkAutoConstructList) { return null; } return result; } @Override public final Builder deployedImages(Collection deployedImages) { this.deployedImages = DeployedImagesCopier.copy(deployedImages); return this; } @Override @SafeVarargs public final Builder deployedImages(DeployedImage... deployedImages) { deployedImages(Arrays.asList(deployedImages)); return this; } @Override @SafeVarargs public final Builder deployedImages(Consumer... deployedImages) { deployedImages(Stream.of(deployedImages).map(c -> DeployedImage.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final void setDeployedImages(Collection deployedImages) { this.deployedImages = DeployedImagesCopier.copyFromBuilder(deployedImages); } public final Float getCurrentWeight() { return currentWeight; } @Override public final Builder currentWeight(Float currentWeight) { this.currentWeight = currentWeight; return this; } public final void setCurrentWeight(Float currentWeight) { this.currentWeight = currentWeight; } public final Float getDesiredWeight() { return desiredWeight; } @Override public final Builder desiredWeight(Float desiredWeight) { this.desiredWeight = desiredWeight; return this; } public final void setDesiredWeight(Float desiredWeight) { this.desiredWeight = desiredWeight; } public final Integer getCurrentInstanceCount() { return currentInstanceCount; } @Override public final Builder currentInstanceCount(Integer currentInstanceCount) { this.currentInstanceCount = currentInstanceCount; return this; } public final void setCurrentInstanceCount(Integer currentInstanceCount) { this.currentInstanceCount = currentInstanceCount; } public final Integer getDesiredInstanceCount() { return desiredInstanceCount; } @Override public final Builder desiredInstanceCount(Integer desiredInstanceCount) { this.desiredInstanceCount = desiredInstanceCount; return this; } public final void setDesiredInstanceCount(Integer desiredInstanceCount) { this.desiredInstanceCount = desiredInstanceCount; } @Override public ProductionVariantSummary build() { return new ProductionVariantSummary(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy