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

software.amazon.awssdk.services.iot.model.UpdatePackageVersionRequest Maven / Gradle / Ivy

Go to download

The AWS Java SDK for AWS Iot Service module holds the client classes that are used for communicating with AWS IoT Service

There is a newer version: 2.30.1
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.iot.model;

import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
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.DefaultValueTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.traits.MapTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap;
import software.amazon.awssdk.core.util.SdkAutoConstructMap;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 */
@Generated("software.amazon.awssdk:codegen")
public final class UpdatePackageVersionRequest extends IotRequest implements
        ToCopyableBuilder {
    private static final SdkField PACKAGE_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("packageName").getter(getter(UpdatePackageVersionRequest::packageName))
            .setter(setter(Builder::packageName))
            .traits(LocationTrait.builder().location(MarshallLocation.PATH).locationName("packageName").build()).build();

    private static final SdkField VERSION_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("versionName").getter(getter(UpdatePackageVersionRequest::versionName))
            .setter(setter(Builder::versionName))
            .traits(LocationTrait.builder().location(MarshallLocation.PATH).locationName("versionName").build()).build();

    private static final SdkField DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("description").getter(getter(UpdatePackageVersionRequest::description))
            .setter(setter(Builder::description))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("description").build()).build();

    private static final SdkField> ATTRIBUTES_FIELD = SdkField
            .> builder(MarshallingType.MAP)
            .memberName("attributes")
            .getter(getter(UpdatePackageVersionRequest::attributes))
            .setter(setter(Builder::attributes))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("attributes").build(),
                    MapTrait.builder()
                            .keyLocationName("key")
                            .valueLocationName("value")
                            .valueFieldInfo(
                                    SdkField. builder(MarshallingType.STRING)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("value").build()).build()).build()).build();

    private static final SdkField ARTIFACT_FIELD = SdkField
            . builder(MarshallingType.SDK_POJO).memberName("artifact")
            .getter(getter(UpdatePackageVersionRequest::artifact)).setter(setter(Builder::artifact))
            .constructor(PackageVersionArtifact::builder)
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("artifact").build()).build();

    private static final SdkField ACTION_FIELD = SdkField. builder(MarshallingType.STRING).memberName("action")
            .getter(getter(UpdatePackageVersionRequest::actionAsString)).setter(setter(Builder::action))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("action").build()).build();

    private static final SdkField RECIPE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("recipe")
            .getter(getter(UpdatePackageVersionRequest::recipe)).setter(setter(Builder::recipe))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("recipe").build()).build();

    private static final SdkField CLIENT_TOKEN_FIELD = SdkField
            . builder(MarshallingType.STRING)
            .memberName("clientToken")
            .getter(getter(UpdatePackageVersionRequest::clientToken))
            .setter(setter(Builder::clientToken))
            .traits(LocationTrait.builder().location(MarshallLocation.QUERY_PARAM).locationName("clientToken").build(),
                    DefaultValueTrait.idempotencyToken()).build();

    private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(PACKAGE_NAME_FIELD,
            VERSION_NAME_FIELD, DESCRIPTION_FIELD, ATTRIBUTES_FIELD, ARTIFACT_FIELD, ACTION_FIELD, RECIPE_FIELD,
            CLIENT_TOKEN_FIELD));

    private static final Map> SDK_NAME_TO_FIELD = memberNameToFieldInitializer();

    private final String packageName;

    private final String versionName;

    private final String description;

    private final Map attributes;

    private final PackageVersionArtifact artifact;

    private final String action;

    private final String recipe;

    private final String clientToken;

    private UpdatePackageVersionRequest(BuilderImpl builder) {
        super(builder);
        this.packageName = builder.packageName;
        this.versionName = builder.versionName;
        this.description = builder.description;
        this.attributes = builder.attributes;
        this.artifact = builder.artifact;
        this.action = builder.action;
        this.recipe = builder.recipe;
        this.clientToken = builder.clientToken;
    }

    /**
     * 

* The name of the associated software package. *

* * @return The name of the associated software package. */ public final String packageName() { return packageName; } /** *

* The name of the target package version. *

* * @return The name of the target package version. */ public final String versionName() { return versionName; } /** *

* The package version description. *

* * @return The package version description. */ public final String description() { return description; } /** * For responses, this returns true if the service returned a value for the Attributes 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 hasAttributes() { return attributes != null && !(attributes instanceof SdkAutoConstructMap); } /** *

* Metadata that can be used to define a package version’s configuration. For example, the Amazon S3 file location, * configuration options that are being sent to the device or fleet. *

*

* Note: Attributes can be updated only when the package version is in a draft state. *

*

* The combined size of all the attributes on a package version is limited to 3KB. *

*

* 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 #hasAttributes} method. *

* * @return Metadata that can be used to define a package version’s configuration. For example, the Amazon S3 file * location, configuration options that are being sent to the device or fleet.

*

* Note: Attributes can be updated only when the package version is in a draft state. *

*

* The combined size of all the attributes on a package version is limited to 3KB. */ public final Map attributes() { return attributes; } /** *

* The various components that make up a software package version. *

* * @return The various components that make up a software package version. */ public final PackageVersionArtifact artifact() { return artifact; } /** *

* The status that the package version should be assigned. For more information, see Package version lifecycle. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #action} will * return {@link PackageVersionAction#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available * from {@link #actionAsString}. *

* * @return The status that the package version should be assigned. For more information, see Package version lifecycle. * @see PackageVersionAction */ public final PackageVersionAction action() { return PackageVersionAction.fromValue(action); } /** *

* The status that the package version should be assigned. For more information, see Package version lifecycle. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #action} will * return {@link PackageVersionAction#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available * from {@link #actionAsString}. *

* * @return The status that the package version should be assigned. For more information, see Package version lifecycle. * @see PackageVersionAction */ public final String actionAsString() { return action; } /** *

* The inline job document associated with a software package version used for a quick job deployment. *

* * @return The inline job document associated with a software package version used for a quick job deployment. */ public final String recipe() { return recipe; } /** *

* A unique case-sensitive identifier that you can provide to ensure the idempotency of the request. Don't reuse * this client token if a new idempotent request is required. *

* * @return A unique case-sensitive identifier that you can provide to ensure the idempotency of the request. Don't * reuse this client token if a new idempotent request is required. */ public final String clientToken() { return clientToken; } @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 + super.hashCode(); hashCode = 31 * hashCode + Objects.hashCode(packageName()); hashCode = 31 * hashCode + Objects.hashCode(versionName()); hashCode = 31 * hashCode + Objects.hashCode(description()); hashCode = 31 * hashCode + Objects.hashCode(hasAttributes() ? attributes() : null); hashCode = 31 * hashCode + Objects.hashCode(artifact()); hashCode = 31 * hashCode + Objects.hashCode(actionAsString()); hashCode = 31 * hashCode + Objects.hashCode(recipe()); hashCode = 31 * hashCode + Objects.hashCode(clientToken()); return hashCode; } @Override public final boolean equals(Object obj) { return super.equals(obj) && equalsBySdkFields(obj); } @Override public final boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof UpdatePackageVersionRequest)) { return false; } UpdatePackageVersionRequest other = (UpdatePackageVersionRequest) obj; return Objects.equals(packageName(), other.packageName()) && Objects.equals(versionName(), other.versionName()) && Objects.equals(description(), other.description()) && hasAttributes() == other.hasAttributes() && Objects.equals(attributes(), other.attributes()) && Objects.equals(artifact(), other.artifact()) && Objects.equals(actionAsString(), other.actionAsString()) && Objects.equals(recipe(), other.recipe()) && Objects.equals(clientToken(), other.clientToken()); } /** * 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("UpdatePackageVersionRequest").add("PackageName", packageName()) .add("VersionName", versionName()) .add("Description", description() == null ? null : "*** Sensitive Data Redacted ***") .add("Attributes", attributes() == null ? null : "*** Sensitive Data Redacted ***").add("Artifact", artifact()) .add("Action", actionAsString()).add("Recipe", recipe() == null ? null : "*** Sensitive Data Redacted ***") .add("ClientToken", clientToken()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "packageName": return Optional.ofNullable(clazz.cast(packageName())); case "versionName": return Optional.ofNullable(clazz.cast(versionName())); case "description": return Optional.ofNullable(clazz.cast(description())); case "attributes": return Optional.ofNullable(clazz.cast(attributes())); case "artifact": return Optional.ofNullable(clazz.cast(artifact())); case "action": return Optional.ofNullable(clazz.cast(actionAsString())); case "recipe": return Optional.ofNullable(clazz.cast(recipe())); case "clientToken": return Optional.ofNullable(clazz.cast(clientToken())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } @Override public final Map> sdkFieldNameToField() { return SDK_NAME_TO_FIELD; } private static Map> memberNameToFieldInitializer() { Map> map = new HashMap<>(); map.put("packageName", PACKAGE_NAME_FIELD); map.put("versionName", VERSION_NAME_FIELD); map.put("description", DESCRIPTION_FIELD); map.put("attributes", ATTRIBUTES_FIELD); map.put("artifact", ARTIFACT_FIELD); map.put("action", ACTION_FIELD); map.put("recipe", RECIPE_FIELD); map.put("clientToken", CLIENT_TOKEN_FIELD); return Collections.unmodifiableMap(map); } private static Function getter(Function g) { return obj -> g.apply((UpdatePackageVersionRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends IotRequest.Builder, SdkPojo, CopyableBuilder { /** *

* The name of the associated software package. *

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

* The name of the target package version. *

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

* The package version description. *

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

* Metadata that can be used to define a package version’s configuration. For example, the Amazon S3 file * location, configuration options that are being sent to the device or fleet. *

*

* Note: Attributes can be updated only when the package version is in a draft state. *

*

* The combined size of all the attributes on a package version is limited to 3KB. *

* * @param attributes * Metadata that can be used to define a package version’s configuration. For example, the Amazon S3 file * location, configuration options that are being sent to the device or fleet.

*

* Note: Attributes can be updated only when the package version is in a draft state. *

*

* The combined size of all the attributes on a package version is limited to 3KB. * @return Returns a reference to this object so that method calls can be chained together. */ Builder attributes(Map attributes); /** *

* The various components that make up a software package version. *

* * @param artifact * The various components that make up a software package version. * @return Returns a reference to this object so that method calls can be chained together. */ Builder artifact(PackageVersionArtifact artifact); /** *

* The various components that make up a software package version. *

* This is a convenience method that creates an instance of the {@link PackageVersionArtifact.Builder} avoiding * the need to create one manually via {@link PackageVersionArtifact#builder()}. * *

* When the {@link Consumer} completes, {@link PackageVersionArtifact.Builder#build()} is called immediately and * its result is passed to {@link #artifact(PackageVersionArtifact)}. * * @param artifact * a consumer that will call methods on {@link PackageVersionArtifact.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #artifact(PackageVersionArtifact) */ default Builder artifact(Consumer artifact) { return artifact(PackageVersionArtifact.builder().applyMutation(artifact).build()); } /** *

* The status that the package version should be assigned. For more information, see Package version lifecycle. *

* * @param action * The status that the package version should be assigned. For more information, see Package version lifecycle. * @see PackageVersionAction * @return Returns a reference to this object so that method calls can be chained together. * @see PackageVersionAction */ Builder action(String action); /** *

* The status that the package version should be assigned. For more information, see Package version lifecycle. *

* * @param action * The status that the package version should be assigned. For more information, see Package version lifecycle. * @see PackageVersionAction * @return Returns a reference to this object so that method calls can be chained together. * @see PackageVersionAction */ Builder action(PackageVersionAction action); /** *

* The inline job document associated with a software package version used for a quick job deployment. *

* * @param recipe * The inline job document associated with a software package version used for a quick job deployment. * @return Returns a reference to this object so that method calls can be chained together. */ Builder recipe(String recipe); /** *

* A unique case-sensitive identifier that you can provide to ensure the idempotency of the request. Don't reuse * this client token if a new idempotent request is required. *

* * @param clientToken * A unique case-sensitive identifier that you can provide to ensure the idempotency of the request. * Don't reuse this client token if a new idempotent request is required. * @return Returns a reference to this object so that method calls can be chained together. */ Builder clientToken(String clientToken); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer builderConsumer); } static final class BuilderImpl extends IotRequest.BuilderImpl implements Builder { private String packageName; private String versionName; private String description; private Map attributes = DefaultSdkAutoConstructMap.getInstance(); private PackageVersionArtifact artifact; private String action; private String recipe; private String clientToken; private BuilderImpl() { } private BuilderImpl(UpdatePackageVersionRequest model) { super(model); packageName(model.packageName); versionName(model.versionName); description(model.description); attributes(model.attributes); artifact(model.artifact); action(model.action); recipe(model.recipe); clientToken(model.clientToken); } public final String getPackageName() { return packageName; } public final void setPackageName(String packageName) { this.packageName = packageName; } @Override public final Builder packageName(String packageName) { this.packageName = packageName; return this; } public final String getVersionName() { return versionName; } public final void setVersionName(String versionName) { this.versionName = versionName; } @Override public final Builder versionName(String versionName) { this.versionName = versionName; return this; } public final String getDescription() { return description; } public final void setDescription(String description) { this.description = description; } @Override public final Builder description(String description) { this.description = description; return this; } public final Map getAttributes() { if (attributes instanceof SdkAutoConstructMap) { return null; } return attributes; } public final void setAttributes(Map attributes) { this.attributes = ResourceAttributesCopier.copy(attributes); } @Override public final Builder attributes(Map attributes) { this.attributes = ResourceAttributesCopier.copy(attributes); return this; } public final PackageVersionArtifact.Builder getArtifact() { return artifact != null ? artifact.toBuilder() : null; } public final void setArtifact(PackageVersionArtifact.BuilderImpl artifact) { this.artifact = artifact != null ? artifact.build() : null; } @Override public final Builder artifact(PackageVersionArtifact artifact) { this.artifact = artifact; return this; } public final String getAction() { return action; } public final void setAction(String action) { this.action = action; } @Override public final Builder action(String action) { this.action = action; return this; } @Override public final Builder action(PackageVersionAction action) { this.action(action == null ? null : action.toString()); return this; } public final String getRecipe() { return recipe; } public final void setRecipe(String recipe) { this.recipe = recipe; } @Override public final Builder recipe(String recipe) { this.recipe = recipe; return this; } public final String getClientToken() { return clientToken; } public final void setClientToken(String clientToken) { this.clientToken = clientToken; } @Override public final Builder clientToken(String clientToken) { this.clientToken = clientToken; return this; } @Override public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { super.overrideConfiguration(overrideConfiguration); return this; } @Override public Builder overrideConfiguration(Consumer builderConsumer) { super.overrideConfiguration(builderConsumer); return this; } @Override public UpdatePackageVersionRequest build() { return new UpdatePackageVersionRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } @Override public Map> sdkFieldNameToField() { return SDK_NAME_TO_FIELD; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy