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

software.amazon.awssdk.services.secretsmanager.model.PutSecretValueRequest 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.secretsmanager.model;

import java.nio.ByteBuffer;
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 software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
import software.amazon.awssdk.core.SdkBytes;
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.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;

/**
 */
@Generated("software.amazon.awssdk:codegen")
public final class PutSecretValueRequest extends SecretsManagerRequest implements
        ToCopyableBuilder {
    private static final SdkField SECRET_ID_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("SecretId").getter(getter(PutSecretValueRequest::secretId)).setter(setter(Builder::secretId))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SecretId").build()).build();

    private static final SdkField CLIENT_REQUEST_TOKEN_FIELD = SdkField
            . builder(MarshallingType.STRING)
            .memberName("ClientRequestToken")
            .getter(getter(PutSecretValueRequest::clientRequestToken))
            .setter(setter(Builder::clientRequestToken))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ClientRequestToken").build(),
                    DefaultValueTrait.idempotencyToken()).build();

    private static final SdkField SECRET_BINARY_FIELD = SdkField. builder(MarshallingType.SDK_BYTES)
            .memberName("SecretBinary").getter(getter(PutSecretValueRequest::secretBinary)).setter(setter(Builder::secretBinary))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SecretBinary").build()).build();

    private static final SdkField SECRET_STRING_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("SecretString").getter(getter(PutSecretValueRequest::secretString)).setter(setter(Builder::secretString))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SecretString").build()).build();

    private static final SdkField> VERSION_STAGES_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .memberName("VersionStages")
            .getter(getter(PutSecretValueRequest::versionStages))
            .setter(setter(Builder::versionStages))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("VersionStages").build(),
                    ListTrait
                            .builder()
                            .memberLocationName(null)
                            .memberFieldInfo(
                                    SdkField. builder(MarshallingType.STRING)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("member").build()).build()).build()).build();

    private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(SECRET_ID_FIELD,
            CLIENT_REQUEST_TOKEN_FIELD, SECRET_BINARY_FIELD, SECRET_STRING_FIELD, VERSION_STAGES_FIELD));

    private final String secretId;

    private final String clientRequestToken;

    private final SdkBytes secretBinary;

    private final String secretString;

    private final List versionStages;

    private PutSecretValueRequest(BuilderImpl builder) {
        super(builder);
        this.secretId = builder.secretId;
        this.clientRequestToken = builder.clientRequestToken;
        this.secretBinary = builder.secretBinary;
        this.secretString = builder.secretString;
        this.versionStages = builder.versionStages;
    }

    /**
     * 

* The ARN or name of the secret to add a new version to. *

*

* For an ARN, we recommend that you specify a complete ARN rather than a partial ARN. See Finding * a secret from a partial ARN. *

*

* If the secret doesn't already exist, use CreateSecret instead. *

* * @return The ARN or name of the secret to add a new version to.

*

* For an ARN, we recommend that you specify a complete ARN rather than a partial ARN. See Finding a secret from a partial ARN. *

*

* If the secret doesn't already exist, use CreateSecret instead. */ public final String secretId() { return secretId; } /** *

* A unique identifier for the new version of the secret. *

* *

* If you use the Amazon Web Services CLI or one of the Amazon Web Services SDKs to call this operation, then you * can leave this parameter empty. The CLI or SDK generates a random UUID for you and includes it as the value for * this parameter in the request. *

*
*

* If you generate a raw HTTP request to the Secrets Manager service endpoint, then you must generate a * ClientRequestToken and include it in the request. *

*

* This value helps ensure idempotency. Secrets Manager uses this value to prevent the accidental creation of * duplicate versions if there are failures and retries during a rotation. We recommend that you generate a UUID-type value to ensure uniqueness of your * versions within the specified secret. *

*
    *
  • *

    * If the ClientRequestToken value isn't already associated with a version of the secret then a new * version of the secret is created. *

    *
  • *
  • *

    * If a version with this value already exists and that version's SecretString or * SecretBinary values are the same as those in the request then the request is ignored. The operation * is idempotent. *

    *
  • *
  • *

    * If a version with this value already exists and the version of the SecretString and * SecretBinary values are different from those in the request, then the request fails because you * can't modify a secret version. You can only create new versions to store new secret values. *

    *
  • *
*

* This value becomes the VersionId of the new version. *

* * @return A unique identifier for the new version of the secret.

*

* If you use the Amazon Web Services CLI or one of the Amazon Web Services SDKs to call this operation, * then you can leave this parameter empty. The CLI or SDK generates a random UUID for you and includes it * as the value for this parameter in the request. *

*
*

* If you generate a raw HTTP request to the Secrets Manager service endpoint, then you must generate a * ClientRequestToken and include it in the request. *

*

* This value helps ensure idempotency. Secrets Manager uses this value to prevent the accidental creation * of duplicate versions if there are failures and retries during a rotation. We recommend that you generate * a UUID-type value to ensure * uniqueness of your versions within the specified secret. *

*
    *
  • *

    * If the ClientRequestToken value isn't already associated with a version of the secret then a * new version of the secret is created. *

    *
  • *
  • *

    * If a version with this value already exists and that version's SecretString or * SecretBinary values are the same as those in the request then the request is ignored. The * operation is idempotent. *

    *
  • *
  • *

    * If a version with this value already exists and the version of the SecretString and * SecretBinary values are different from those in the request, then the request fails because * you can't modify a secret version. You can only create new versions to store new secret values. *

    *
  • *
*

* This value becomes the VersionId of the new version. */ public final String clientRequestToken() { return clientRequestToken; } /** *

* The binary data to encrypt and store in the new version of the secret. To use this parameter in the command-line * tools, we recommend that you store your binary data in a file and then pass the contents of the file as a * parameter. *

*

* You must include SecretBinary or SecretString, but not both. *

*

* You can't access this value from the Secrets Manager console. *

* * @return The binary data to encrypt and store in the new version of the secret. To use this parameter in the * command-line tools, we recommend that you store your binary data in a file and then pass the contents of * the file as a parameter.

*

* You must include SecretBinary or SecretString, but not both. *

*

* You can't access this value from the Secrets Manager console. */ public final SdkBytes secretBinary() { return secretBinary; } /** *

* The text to encrypt and store in the new version of the secret. *

*

* You must include SecretBinary or SecretString, but not both. *

*

* We recommend you create the secret string as JSON key/value pairs, as shown in the example. *

* * @return The text to encrypt and store in the new version of the secret.

*

* You must include SecretBinary or SecretString, but not both. *

*

* We recommend you create the secret string as JSON key/value pairs, as shown in the example. */ public final String secretString() { return secretString; } /** * For responses, this returns true if the service returned a value for the VersionStages 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 hasVersionStages() { return versionStages != null && !(versionStages instanceof SdkAutoConstructList); } /** *

* A list of staging labels to attach to this version of the secret. Secrets Manager uses staging labels to track * versions of a secret through the rotation process. *

*

* If you specify a staging label that's already associated with a different version of the same secret, then * Secrets Manager removes the label from the other version and attaches it to this version. If you specify * AWSCURRENT, and it is already attached to another version, then Secrets Manager also moves the * staging label AWSPREVIOUS to the version that AWSCURRENT was removed from. *

*

* If you don't include VersionStages, then Secrets Manager automatically moves the staging label * AWSCURRENT to this version. *

*

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

* * @return A list of staging labels to attach to this version of the secret. Secrets Manager uses staging labels to * track versions of a secret through the rotation process.

*

* If you specify a staging label that's already associated with a different version of the same secret, * then Secrets Manager removes the label from the other version and attaches it to this version. If you * specify AWSCURRENT, and it is already attached to another version, then Secrets Manager also * moves the staging label AWSPREVIOUS to the version that AWSCURRENT was removed * from. *

*

* If you don't include VersionStages, then Secrets Manager automatically moves the staging * label AWSCURRENT to this version. */ public final List versionStages() { return versionStages; } @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(secretId()); hashCode = 31 * hashCode + Objects.hashCode(clientRequestToken()); hashCode = 31 * hashCode + Objects.hashCode(secretBinary()); hashCode = 31 * hashCode + Objects.hashCode(secretString()); hashCode = 31 * hashCode + Objects.hashCode(hasVersionStages() ? versionStages() : null); 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 PutSecretValueRequest)) { return false; } PutSecretValueRequest other = (PutSecretValueRequest) obj; return Objects.equals(secretId(), other.secretId()) && Objects.equals(clientRequestToken(), other.clientRequestToken()) && Objects.equals(secretBinary(), other.secretBinary()) && Objects.equals(secretString(), other.secretString()) && hasVersionStages() == other.hasVersionStages() && Objects.equals(versionStages(), other.versionStages()); } /** * 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("PutSecretValueRequest").add("SecretId", secretId()) .add("ClientRequestToken", clientRequestToken()) .add("SecretBinary", secretBinary() == null ? null : "*** Sensitive Data Redacted ***") .add("SecretString", secretString() == null ? null : "*** Sensitive Data Redacted ***") .add("VersionStages", hasVersionStages() ? versionStages() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "SecretId": return Optional.ofNullable(clazz.cast(secretId())); case "ClientRequestToken": return Optional.ofNullable(clazz.cast(clientRequestToken())); case "SecretBinary": return Optional.ofNullable(clazz.cast(secretBinary())); case "SecretString": return Optional.ofNullable(clazz.cast(secretString())); case "VersionStages": return Optional.ofNullable(clazz.cast(versionStages())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((PutSecretValueRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SecretsManagerRequest.Builder, SdkPojo, CopyableBuilder { /** *

* The ARN or name of the secret to add a new version to. *

*

* For an ARN, we recommend that you specify a complete ARN rather than a partial ARN. See Finding a secret from a partial ARN. *

*

* If the secret doesn't already exist, use CreateSecret instead. *

* * @param secretId * The ARN or name of the secret to add a new version to.

*

* For an ARN, we recommend that you specify a complete ARN rather than a partial ARN. See Finding a secret from a partial ARN. *

*

* If the secret doesn't already exist, use CreateSecret instead. * @return Returns a reference to this object so that method calls can be chained together. */ Builder secretId(String secretId); /** *

* A unique identifier for the new version of the secret. *

* *

* If you use the Amazon Web Services CLI or one of the Amazon Web Services SDKs to call this operation, then * you can leave this parameter empty. The CLI or SDK generates a random UUID for you and includes it as the * value for this parameter in the request. *

*
*

* If you generate a raw HTTP request to the Secrets Manager service endpoint, then you must generate a * ClientRequestToken and include it in the request. *

*

* This value helps ensure idempotency. Secrets Manager uses this value to prevent the accidental creation of * duplicate versions if there are failures and retries during a rotation. We recommend that you generate a UUID-type value to ensure uniqueness of * your versions within the specified secret. *

*
    *
  • *

    * If the ClientRequestToken value isn't already associated with a version of the secret then a new * version of the secret is created. *

    *
  • *
  • *

    * If a version with this value already exists and that version's SecretString or * SecretBinary values are the same as those in the request then the request is ignored. The * operation is idempotent. *

    *
  • *
  • *

    * If a version with this value already exists and the version of the SecretString and * SecretBinary values are different from those in the request, then the request fails because you * can't modify a secret version. You can only create new versions to store new secret values. *

    *
  • *
*

* This value becomes the VersionId of the new version. *

* * @param clientRequestToken * A unique identifier for the new version of the secret.

*

* If you use the Amazon Web Services CLI or one of the Amazon Web Services SDKs to call this operation, * then you can leave this parameter empty. The CLI or SDK generates a random UUID for you and includes * it as the value for this parameter in the request. *

*
*

* If you generate a raw HTTP request to the Secrets Manager service endpoint, then you must generate a * ClientRequestToken and include it in the request. *

*

* This value helps ensure idempotency. Secrets Manager uses this value to prevent the accidental * creation of duplicate versions if there are failures and retries during a rotation. We recommend that * you generate a UUID-type value * to ensure uniqueness of your versions within the specified secret. *

*
    *
  • *

    * If the ClientRequestToken value isn't already associated with a version of the secret * then a new version of the secret is created. *

    *
  • *
  • *

    * If a version with this value already exists and that version's SecretString or * SecretBinary values are the same as those in the request then the request is ignored. The * operation is idempotent. *

    *
  • *
  • *

    * If a version with this value already exists and the version of the SecretString and * SecretBinary values are different from those in the request, then the request fails * because you can't modify a secret version. You can only create new versions to store new secret * values. *

    *
  • *
*

* This value becomes the VersionId of the new version. * @return Returns a reference to this object so that method calls can be chained together. */ Builder clientRequestToken(String clientRequestToken); /** *

* The binary data to encrypt and store in the new version of the secret. To use this parameter in the * command-line tools, we recommend that you store your binary data in a file and then pass the contents of the * file as a parameter. *

*

* You must include SecretBinary or SecretString, but not both. *

*

* You can't access this value from the Secrets Manager console. *

* * @param secretBinary * The binary data to encrypt and store in the new version of the secret. To use this parameter in the * command-line tools, we recommend that you store your binary data in a file and then pass the contents * of the file as a parameter.

*

* You must include SecretBinary or SecretString, but not both. *

*

* You can't access this value from the Secrets Manager console. * @return Returns a reference to this object so that method calls can be chained together. */ Builder secretBinary(SdkBytes secretBinary); /** *

* The text to encrypt and store in the new version of the secret. *

*

* You must include SecretBinary or SecretString, but not both. *

*

* We recommend you create the secret string as JSON key/value pairs, as shown in the example. *

* * @param secretString * The text to encrypt and store in the new version of the secret.

*

* You must include SecretBinary or SecretString, but not both. *

*

* We recommend you create the secret string as JSON key/value pairs, as shown in the example. * @return Returns a reference to this object so that method calls can be chained together. */ Builder secretString(String secretString); /** *

* A list of staging labels to attach to this version of the secret. Secrets Manager uses staging labels to * track versions of a secret through the rotation process. *

*

* If you specify a staging label that's already associated with a different version of the same secret, then * Secrets Manager removes the label from the other version and attaches it to this version. If you specify * AWSCURRENT, and it is already attached to another version, then Secrets Manager also moves the * staging label AWSPREVIOUS to the version that AWSCURRENT was removed from. *

*

* If you don't include VersionStages, then Secrets Manager automatically moves the staging label * AWSCURRENT to this version. *

* * @param versionStages * A list of staging labels to attach to this version of the secret. Secrets Manager uses staging labels * to track versions of a secret through the rotation process.

*

* If you specify a staging label that's already associated with a different version of the same secret, * then Secrets Manager removes the label from the other version and attaches it to this version. If you * specify AWSCURRENT, and it is already attached to another version, then Secrets Manager * also moves the staging label AWSPREVIOUS to the version that AWSCURRENT was * removed from. *

*

* If you don't include VersionStages, then Secrets Manager automatically moves the staging * label AWSCURRENT to this version. * @return Returns a reference to this object so that method calls can be chained together. */ Builder versionStages(Collection versionStages); /** *

* A list of staging labels to attach to this version of the secret. Secrets Manager uses staging labels to * track versions of a secret through the rotation process. *

*

* If you specify a staging label that's already associated with a different version of the same secret, then * Secrets Manager removes the label from the other version and attaches it to this version. If you specify * AWSCURRENT, and it is already attached to another version, then Secrets Manager also moves the * staging label AWSPREVIOUS to the version that AWSCURRENT was removed from. *

*

* If you don't include VersionStages, then Secrets Manager automatically moves the staging label * AWSCURRENT to this version. *

* * @param versionStages * A list of staging labels to attach to this version of the secret. Secrets Manager uses staging labels * to track versions of a secret through the rotation process.

*

* If you specify a staging label that's already associated with a different version of the same secret, * then Secrets Manager removes the label from the other version and attaches it to this version. If you * specify AWSCURRENT, and it is already attached to another version, then Secrets Manager * also moves the staging label AWSPREVIOUS to the version that AWSCURRENT was * removed from. *

*

* If you don't include VersionStages, then Secrets Manager automatically moves the staging * label AWSCURRENT to this version. * @return Returns a reference to this object so that method calls can be chained together. */ Builder versionStages(String... versionStages); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer builderConsumer); } static final class BuilderImpl extends SecretsManagerRequest.BuilderImpl implements Builder { private String secretId; private String clientRequestToken; private SdkBytes secretBinary; private String secretString; private List versionStages = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(PutSecretValueRequest model) { super(model); secretId(model.secretId); clientRequestToken(model.clientRequestToken); secretBinary(model.secretBinary); secretString(model.secretString); versionStages(model.versionStages); } public final String getSecretId() { return secretId; } public final void setSecretId(String secretId) { this.secretId = secretId; } @Override public final Builder secretId(String secretId) { this.secretId = secretId; return this; } public final String getClientRequestToken() { return clientRequestToken; } public final void setClientRequestToken(String clientRequestToken) { this.clientRequestToken = clientRequestToken; } @Override public final Builder clientRequestToken(String clientRequestToken) { this.clientRequestToken = clientRequestToken; return this; } public final ByteBuffer getSecretBinary() { return secretBinary == null ? null : secretBinary.asByteBuffer(); } public final void setSecretBinary(ByteBuffer secretBinary) { secretBinary(secretBinary == null ? null : SdkBytes.fromByteBuffer(secretBinary)); } @Override public final Builder secretBinary(SdkBytes secretBinary) { this.secretBinary = secretBinary; return this; } public final String getSecretString() { return secretString; } public final void setSecretString(String secretString) { this.secretString = secretString; } @Override public final Builder secretString(String secretString) { this.secretString = secretString; return this; } public final Collection getVersionStages() { if (versionStages instanceof SdkAutoConstructList) { return null; } return versionStages; } public final void setVersionStages(Collection versionStages) { this.versionStages = SecretVersionStagesTypeCopier.copy(versionStages); } @Override public final Builder versionStages(Collection versionStages) { this.versionStages = SecretVersionStagesTypeCopier.copy(versionStages); return this; } @Override @SafeVarargs public final Builder versionStages(String... versionStages) { versionStages(Arrays.asList(versionStages)); 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 PutSecretValueRequest build() { return new PutSecretValueRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy