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

software.amazon.awssdk.services.imagebuilder.model.CreateDistributionConfigurationRequest 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.imagebuilder.model;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
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 java.util.stream.Collectors;
import java.util.stream.Stream;
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.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.traits.MapTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
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 CreateDistributionConfigurationRequest extends ImagebuilderRequest implements
        ToCopyableBuilder {
    private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING)
            .getter(getter(CreateDistributionConfigurationRequest::name)).setter(setter(Builder::name))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("name").build()).build();

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

    private static final SdkField> DISTRIBUTIONS_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .getter(getter(CreateDistributionConfigurationRequest::distributions))
            .setter(setter(Builder::distributions))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("distributions").build(),
                    ListTrait
                            .builder()
                            .memberLocationName(null)
                            .memberFieldInfo(
                                    SdkField. builder(MarshallingType.SDK_POJO)
                                            .constructor(Distribution::builder)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("member").build()).build()).build()).build();

    private static final SdkField> TAGS_FIELD = SdkField
            .> builder(MarshallingType.MAP)
            .getter(getter(CreateDistributionConfigurationRequest::tags))
            .setter(setter(Builder::tags))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("tags").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 CLIENT_TOKEN_FIELD = SdkField
            . builder(MarshallingType.STRING)
            .getter(getter(CreateDistributionConfigurationRequest::clientToken))
            .setter(setter(Builder::clientToken))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("clientToken").build(),
                    DefaultValueTrait.idempotencyToken()).build();

    private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NAME_FIELD, DESCRIPTION_FIELD,
            DISTRIBUTIONS_FIELD, TAGS_FIELD, CLIENT_TOKEN_FIELD));

    private final String name;

    private final String description;

    private final List distributions;

    private final Map tags;

    private final String clientToken;

    private CreateDistributionConfigurationRequest(BuilderImpl builder) {
        super(builder);
        this.name = builder.name;
        this.description = builder.description;
        this.distributions = builder.distributions;
        this.tags = builder.tags;
        this.clientToken = builder.clientToken;
    }

    /**
     * 

* The name of the distribution configuration. *

* * @return The name of the distribution configuration. */ public String name() { return name; } /** *

* The description of the distribution configuration. *

* * @return The description of the distribution configuration. */ public String description() { return description; } /** * Returns true if the Distributions 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 boolean hasDistributions() { return distributions != null && !(distributions instanceof SdkAutoConstructList); } /** *

* The distributions of the distribution configuration. *

*

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

*

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

* * @return The distributions of the distribution configuration. */ public List distributions() { return distributions; } /** * Returns true if the Tags 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 boolean hasTags() { return tags != null && !(tags instanceof SdkAutoConstructMap); } /** *

* The tags of the distribution configuration. *

*

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

*

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

* * @return The tags of the distribution configuration. */ public Map tags() { return tags; } /** *

* The idempotency token of the distribution configuration. *

* * @return The idempotency token of the distribution configuration. */ public 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 int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + super.hashCode(); hashCode = 31 * hashCode + Objects.hashCode(name()); hashCode = 31 * hashCode + Objects.hashCode(description()); hashCode = 31 * hashCode + Objects.hashCode(distributions()); hashCode = 31 * hashCode + Objects.hashCode(tags()); hashCode = 31 * hashCode + Objects.hashCode(clientToken()); return hashCode; } @Override public boolean equals(Object obj) { return super.equals(obj) && equalsBySdkFields(obj); } @Override public boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof CreateDistributionConfigurationRequest)) { return false; } CreateDistributionConfigurationRequest other = (CreateDistributionConfigurationRequest) obj; return Objects.equals(name(), other.name()) && Objects.equals(description(), other.description()) && Objects.equals(distributions(), other.distributions()) && Objects.equals(tags(), other.tags()) && 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 String toString() { return ToString.builder("CreateDistributionConfigurationRequest").add("Name", name()).add("Description", description()) .add("Distributions", distributions()).add("Tags", tags()).add("ClientToken", clientToken()).build(); } public Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "name": return Optional.ofNullable(clazz.cast(name())); case "description": return Optional.ofNullable(clazz.cast(description())); case "distributions": return Optional.ofNullable(clazz.cast(distributions())); case "tags": return Optional.ofNullable(clazz.cast(tags())); case "clientToken": return Optional.ofNullable(clazz.cast(clientToken())); default: return Optional.empty(); } } @Override public List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((CreateDistributionConfigurationRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends ImagebuilderRequest.Builder, SdkPojo, CopyableBuilder { /** *

* The name of the distribution configuration. *

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

* The description of the distribution configuration. *

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

* The distributions of the distribution configuration. *

* * @param distributions * The distributions of the distribution configuration. * @return Returns a reference to this object so that method calls can be chained together. */ Builder distributions(Collection distributions); /** *

* The distributions of the distribution configuration. *

* * @param distributions * The distributions of the distribution configuration. * @return Returns a reference to this object so that method calls can be chained together. */ Builder distributions(Distribution... distributions); /** *

* The distributions of the distribution configuration. *

* 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 #distributions(List)}. * * @param distributions * 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 #distributions(List) */ Builder distributions(Consumer... distributions); /** *

* The tags of the distribution configuration. *

* * @param tags * The tags of the distribution configuration. * @return Returns a reference to this object so that method calls can be chained together. */ Builder tags(Map tags); /** *

* The idempotency token of the distribution configuration. *

* * @param clientToken * The idempotency token of the distribution configuration. * @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 ImagebuilderRequest.BuilderImpl implements Builder { private String name; private String description; private List distributions = DefaultSdkAutoConstructList.getInstance(); private Map tags = DefaultSdkAutoConstructMap.getInstance(); private String clientToken; private BuilderImpl() { } private BuilderImpl(CreateDistributionConfigurationRequest model) { super(model); name(model.name); description(model.description); distributions(model.distributions); tags(model.tags); clientToken(model.clientToken); } public final String getName() { return name; } @Override public final Builder name(String name) { this.name = name; return this; } public final void setName(String name) { this.name = name; } public final String getDescription() { return description; } @Override public final Builder description(String description) { this.description = description; return this; } public final void setDescription(String description) { this.description = description; } public final Collection getDistributions() { return distributions != null ? distributions.stream().map(Distribution::toBuilder).collect(Collectors.toList()) : null; } @Override public final Builder distributions(Collection distributions) { this.distributions = DistributionListCopier.copy(distributions); return this; } @Override @SafeVarargs public final Builder distributions(Distribution... distributions) { distributions(Arrays.asList(distributions)); return this; } @Override @SafeVarargs public final Builder distributions(Consumer... distributions) { distributions(Stream.of(distributions).map(c -> Distribution.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final void setDistributions(Collection distributions) { this.distributions = DistributionListCopier.copyFromBuilder(distributions); } public final Map getTags() { return tags; } @Override public final Builder tags(Map tags) { this.tags = TagMapCopier.copy(tags); return this; } public final void setTags(Map tags) { this.tags = TagMapCopier.copy(tags); } public final String getClientToken() { return clientToken; } @Override public final Builder clientToken(String clientToken) { this.clientToken = clientToken; return this; } public final void setClientToken(String clientToken) { this.clientToken = clientToken; } @Override public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { super.overrideConfiguration(overrideConfiguration); return this; } @Override public Builder overrideConfiguration(Consumer builderConsumer) { super.overrideConfiguration(builderConsumer); return this; } @Override public CreateDistributionConfigurationRequest build() { return new CreateDistributionConfigurationRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy