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

software.amazon.awssdk.services.quicksight.model.CreateTemplateRequest 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.quicksight.model;

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.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.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 CreateTemplateRequest extends QuickSightRequest implements
        ToCopyableBuilder {
    private static final SdkField AWS_ACCOUNT_ID_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("AwsAccountId").getter(getter(CreateTemplateRequest::awsAccountId)).setter(setter(Builder::awsAccountId))
            .traits(LocationTrait.builder().location(MarshallLocation.PATH).locationName("AwsAccountId").build()).build();

    private static final SdkField TEMPLATE_ID_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("TemplateId").getter(getter(CreateTemplateRequest::templateId)).setter(setter(Builder::templateId))
            .traits(LocationTrait.builder().location(MarshallLocation.PATH).locationName("TemplateId").build()).build();

    private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Name")
            .getter(getter(CreateTemplateRequest::name)).setter(setter(Builder::name))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Name").build()).build();

    private static final SdkField> PERMISSIONS_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .memberName("Permissions")
            .getter(getter(CreateTemplateRequest::permissions))
            .setter(setter(Builder::permissions))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Permissions").build(),
                    ListTrait
                            .builder()
                            .memberLocationName(null)
                            .memberFieldInfo(
                                    SdkField. builder(MarshallingType.SDK_POJO)
                                            .constructor(ResourcePermission::builder)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("member").build()).build()).build()).build();

    private static final SdkField SOURCE_ENTITY_FIELD = SdkField
            . builder(MarshallingType.SDK_POJO).memberName("SourceEntity")
            .getter(getter(CreateTemplateRequest::sourceEntity)).setter(setter(Builder::sourceEntity))
            .constructor(TemplateSourceEntity::builder)
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SourceEntity").build()).build();

    private static final SdkField> TAGS_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .memberName("Tags")
            .getter(getter(CreateTemplateRequest::tags))
            .setter(setter(Builder::tags))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Tags").build(),
                    ListTrait
                            .builder()
                            .memberLocationName(null)
                            .memberFieldInfo(
                                    SdkField. builder(MarshallingType.SDK_POJO)
                                            .constructor(Tag::builder)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("member").build()).build()).build()).build();

    private static final SdkField VERSION_DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("VersionDescription").getter(getter(CreateTemplateRequest::versionDescription))
            .setter(setter(Builder::versionDescription))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("VersionDescription").build())
            .build();

    private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(AWS_ACCOUNT_ID_FIELD,
            TEMPLATE_ID_FIELD, NAME_FIELD, PERMISSIONS_FIELD, SOURCE_ENTITY_FIELD, TAGS_FIELD, VERSION_DESCRIPTION_FIELD));

    private final String awsAccountId;

    private final String templateId;

    private final String name;

    private final List permissions;

    private final TemplateSourceEntity sourceEntity;

    private final List tags;

    private final String versionDescription;

    private CreateTemplateRequest(BuilderImpl builder) {
        super(builder);
        this.awsAccountId = builder.awsAccountId;
        this.templateId = builder.templateId;
        this.name = builder.name;
        this.permissions = builder.permissions;
        this.sourceEntity = builder.sourceEntity;
        this.tags = builder.tags;
        this.versionDescription = builder.versionDescription;
    }

    /**
     * 

* The ID for the AWS account that the group is in. Currently, you use the ID for the AWS account that contains your * Amazon QuickSight account. *

* * @return The ID for the AWS account that the group is in. Currently, you use the ID for the AWS account that * contains your Amazon QuickSight account. */ public final String awsAccountId() { return awsAccountId; } /** *

* An ID for the template that you want to create. This template is unique per AWS Region in each AWS account. *

* * @return An ID for the template that you want to create. This template is unique per AWS Region in each AWS * account. */ public final String templateId() { return templateId; } /** *

* A display name for the template. *

* * @return A display name for the template. */ public final String name() { return name; } /** * Returns true if the Permissions 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 hasPermissions() { return permissions != null && !(permissions instanceof SdkAutoConstructList); } /** *

* A list of resource permissions to be set on the template. *

*

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

*

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

* * @return A list of resource permissions to be set on the template. */ public final List permissions() { return permissions; } /** *

* The entity that you are using as a source when you create the template. In SourceEntity, you specify * the type of object you're using as source: SourceTemplate for a template or * SourceAnalysis for an analysis. Both of these require an Amazon Resource Name (ARN). For * SourceTemplate, specify the ARN of the source template. For SourceAnalysis, specify the * ARN of the source analysis. The SourceTemplate ARN can contain any AWS Account and any * QuickSight-supported AWS Region. *

*

* Use the DataSetReferences entity within SourceTemplate or SourceAnalysis * to list the replacement datasets for the placeholders listed in the original. The schema in each dataset must * match its placeholder. *

* * @return The entity that you are using as a source when you create the template. In SourceEntity, you * specify the type of object you're using as source: SourceTemplate for a template or * SourceAnalysis for an analysis. Both of these require an Amazon Resource Name (ARN). For * SourceTemplate, specify the ARN of the source template. For SourceAnalysis, * specify the ARN of the source analysis. The SourceTemplate ARN can contain any AWS Account * and any QuickSight-supported AWS Region.

*

* Use the DataSetReferences entity within SourceTemplate or * SourceAnalysis to list the replacement datasets for the placeholders listed in the original. * The schema in each dataset must match its placeholder. */ public final TemplateSourceEntity sourceEntity() { return sourceEntity; } /** * 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 final boolean hasTags() { return tags != null && !(tags instanceof SdkAutoConstructList); } /** *

* Contains a map of the key-value pairs for the resource tag or tags assigned to the resource. *

*

* 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 Contains a map of the key-value pairs for the resource tag or tags assigned to the resource. */ public final List tags() { return tags; } /** *

* A description of the current template version being created. This API operation creates the first version of the * template. Every time UpdateTemplate is called, a new version is created. Each version of the * template maintains a description of the version in the VersionDescription field. *

* * @return A description of the current template version being created. This API operation creates the first version * of the template. Every time UpdateTemplate is called, a new version is created. Each version * of the template maintains a description of the version in the VersionDescription field. */ public final String versionDescription() { return versionDescription; } @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(awsAccountId()); hashCode = 31 * hashCode + Objects.hashCode(templateId()); hashCode = 31 * hashCode + Objects.hashCode(name()); hashCode = 31 * hashCode + Objects.hashCode(hasPermissions() ? permissions() : null); hashCode = 31 * hashCode + Objects.hashCode(sourceEntity()); hashCode = 31 * hashCode + Objects.hashCode(hasTags() ? tags() : null); hashCode = 31 * hashCode + Objects.hashCode(versionDescription()); 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 CreateTemplateRequest)) { return false; } CreateTemplateRequest other = (CreateTemplateRequest) obj; return Objects.equals(awsAccountId(), other.awsAccountId()) && Objects.equals(templateId(), other.templateId()) && Objects.equals(name(), other.name()) && hasPermissions() == other.hasPermissions() && Objects.equals(permissions(), other.permissions()) && Objects.equals(sourceEntity(), other.sourceEntity()) && hasTags() == other.hasTags() && Objects.equals(tags(), other.tags()) && Objects.equals(versionDescription(), other.versionDescription()); } /** * 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("CreateTemplateRequest").add("AwsAccountId", awsAccountId()).add("TemplateId", templateId()) .add("Name", name()).add("Permissions", hasPermissions() ? permissions() : null) .add("SourceEntity", sourceEntity()).add("Tags", hasTags() ? tags() : null) .add("VersionDescription", versionDescription()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "AwsAccountId": return Optional.ofNullable(clazz.cast(awsAccountId())); case "TemplateId": return Optional.ofNullable(clazz.cast(templateId())); case "Name": return Optional.ofNullable(clazz.cast(name())); case "Permissions": return Optional.ofNullable(clazz.cast(permissions())); case "SourceEntity": return Optional.ofNullable(clazz.cast(sourceEntity())); case "Tags": return Optional.ofNullable(clazz.cast(tags())); case "VersionDescription": return Optional.ofNullable(clazz.cast(versionDescription())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((CreateTemplateRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends QuickSightRequest.Builder, SdkPojo, CopyableBuilder { /** *

* The ID for the AWS account that the group is in. Currently, you use the ID for the AWS account that contains * your Amazon QuickSight account. *

* * @param awsAccountId * The ID for the AWS account that the group is in. Currently, you use the ID for the AWS account that * contains your Amazon QuickSight account. * @return Returns a reference to this object so that method calls can be chained together. */ Builder awsAccountId(String awsAccountId); /** *

* An ID for the template that you want to create. This template is unique per AWS Region in each AWS account. *

* * @param templateId * An ID for the template that you want to create. This template is unique per AWS Region in each AWS * account. * @return Returns a reference to this object so that method calls can be chained together. */ Builder templateId(String templateId); /** *

* A display name for the template. *

* * @param name * A display name for the template. * @return Returns a reference to this object so that method calls can be chained together. */ Builder name(String name); /** *

* A list of resource permissions to be set on the template. *

* * @param permissions * A list of resource permissions to be set on the template. * @return Returns a reference to this object so that method calls can be chained together. */ Builder permissions(Collection permissions); /** *

* A list of resource permissions to be set on the template. *

* * @param permissions * A list of resource permissions to be set on the template. * @return Returns a reference to this object so that method calls can be chained together. */ Builder permissions(ResourcePermission... permissions); /** *

* A list of resource permissions to be set on the template. *

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

* The entity that you are using as a source when you create the template. In SourceEntity, you * specify the type of object you're using as source: SourceTemplate for a template or * SourceAnalysis for an analysis. Both of these require an Amazon Resource Name (ARN). For * SourceTemplate, specify the ARN of the source template. For SourceAnalysis, specify * the ARN of the source analysis. The SourceTemplate ARN can contain any AWS Account and any * QuickSight-supported AWS Region. *

*

* Use the DataSetReferences entity within SourceTemplate or * SourceAnalysis to list the replacement datasets for the placeholders listed in the original. The * schema in each dataset must match its placeholder. *

* * @param sourceEntity * The entity that you are using as a source when you create the template. In SourceEntity, * you specify the type of object you're using as source: SourceTemplate for a template or * SourceAnalysis for an analysis. Both of these require an Amazon Resource Name (ARN). For * SourceTemplate, specify the ARN of the source template. For SourceAnalysis, * specify the ARN of the source analysis. The SourceTemplate ARN can contain any AWS * Account and any QuickSight-supported AWS Region.

*

* Use the DataSetReferences entity within SourceTemplate or * SourceAnalysis to list the replacement datasets for the placeholders listed in the * original. The schema in each dataset must match its placeholder. * @return Returns a reference to this object so that method calls can be chained together. */ Builder sourceEntity(TemplateSourceEntity sourceEntity); /** *

* The entity that you are using as a source when you create the template. In SourceEntity, you * specify the type of object you're using as source: SourceTemplate for a template or * SourceAnalysis for an analysis. Both of these require an Amazon Resource Name (ARN). For * SourceTemplate, specify the ARN of the source template. For SourceAnalysis, specify * the ARN of the source analysis. The SourceTemplate ARN can contain any AWS Account and any * QuickSight-supported AWS Region. *

*

* Use the DataSetReferences entity within SourceTemplate or * SourceAnalysis to list the replacement datasets for the placeholders listed in the original. The * schema in each dataset must match its placeholder. *

* This is a convenience that creates an instance of the {@link TemplateSourceEntity.Builder} avoiding the need * to create one manually via {@link TemplateSourceEntity#builder()}. * * When the {@link Consumer} completes, {@link TemplateSourceEntity.Builder#build()} is called immediately and * its result is passed to {@link #sourceEntity(TemplateSourceEntity)}. * * @param sourceEntity * a consumer that will call methods on {@link TemplateSourceEntity.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #sourceEntity(TemplateSourceEntity) */ default Builder sourceEntity(Consumer sourceEntity) { return sourceEntity(TemplateSourceEntity.builder().applyMutation(sourceEntity).build()); } /** *

* Contains a map of the key-value pairs for the resource tag or tags assigned to the resource. *

* * @param tags * Contains a map of the key-value pairs for the resource tag or tags assigned to the resource. * @return Returns a reference to this object so that method calls can be chained together. */ Builder tags(Collection tags); /** *

* Contains a map of the key-value pairs for the resource tag or tags assigned to the resource. *

* * @param tags * Contains a map of the key-value pairs for the resource tag or tags assigned to the resource. * @return Returns a reference to this object so that method calls can be chained together. */ Builder tags(Tag... tags); /** *

* Contains a map of the key-value pairs for the resource tag or tags assigned to the resource. *

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

* A description of the current template version being created. This API operation creates the first version of * the template. Every time UpdateTemplate is called, a new version is created. Each version of the * template maintains a description of the version in the VersionDescription field. *

* * @param versionDescription * A description of the current template version being created. This API operation creates the first * version of the template. Every time UpdateTemplate is called, a new version is created. * Each version of the template maintains a description of the version in the * VersionDescription field. * @return Returns a reference to this object so that method calls can be chained together. */ Builder versionDescription(String versionDescription); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer builderConsumer); } static final class BuilderImpl extends QuickSightRequest.BuilderImpl implements Builder { private String awsAccountId; private String templateId; private String name; private List permissions = DefaultSdkAutoConstructList.getInstance(); private TemplateSourceEntity sourceEntity; private List tags = DefaultSdkAutoConstructList.getInstance(); private String versionDescription; private BuilderImpl() { } private BuilderImpl(CreateTemplateRequest model) { super(model); awsAccountId(model.awsAccountId); templateId(model.templateId); name(model.name); permissions(model.permissions); sourceEntity(model.sourceEntity); tags(model.tags); versionDescription(model.versionDescription); } public final String getAwsAccountId() { return awsAccountId; } @Override public final Builder awsAccountId(String awsAccountId) { this.awsAccountId = awsAccountId; return this; } public final void setAwsAccountId(String awsAccountId) { this.awsAccountId = awsAccountId; } public final String getTemplateId() { return templateId; } @Override public final Builder templateId(String templateId) { this.templateId = templateId; return this; } public final void setTemplateId(String templateId) { this.templateId = templateId; } 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 Collection getPermissions() { if (permissions instanceof SdkAutoConstructList) { return null; } return permissions != null ? permissions.stream().map(ResourcePermission::toBuilder).collect(Collectors.toList()) : null; } @Override public final Builder permissions(Collection permissions) { this.permissions = ResourcePermissionListCopier.copy(permissions); return this; } @Override @SafeVarargs public final Builder permissions(ResourcePermission... permissions) { permissions(Arrays.asList(permissions)); return this; } @Override @SafeVarargs public final Builder permissions(Consumer... permissions) { permissions(Stream.of(permissions).map(c -> ResourcePermission.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final void setPermissions(Collection permissions) { this.permissions = ResourcePermissionListCopier.copyFromBuilder(permissions); } public final TemplateSourceEntity.Builder getSourceEntity() { return sourceEntity != null ? sourceEntity.toBuilder() : null; } @Override public final Builder sourceEntity(TemplateSourceEntity sourceEntity) { this.sourceEntity = sourceEntity; return this; } public final void setSourceEntity(TemplateSourceEntity.BuilderImpl sourceEntity) { this.sourceEntity = sourceEntity != null ? sourceEntity.build() : null; } public final Collection getTags() { if (tags instanceof SdkAutoConstructList) { return null; } return tags != null ? tags.stream().map(Tag::toBuilder).collect(Collectors.toList()) : null; } @Override public final Builder tags(Collection tags) { this.tags = TagListCopier.copy(tags); return this; } @Override @SafeVarargs public final Builder tags(Tag... tags) { tags(Arrays.asList(tags)); return this; } @Override @SafeVarargs public final Builder tags(Consumer... tags) { tags(Stream.of(tags).map(c -> Tag.builder().applyMutation(c).build()).collect(Collectors.toList())); return this; } public final void setTags(Collection tags) { this.tags = TagListCopier.copyFromBuilder(tags); } public final String getVersionDescription() { return versionDescription; } @Override public final Builder versionDescription(String versionDescription) { this.versionDescription = versionDescription; return this; } public final void setVersionDescription(String versionDescription) { this.versionDescription = versionDescription; } @Override public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { super.overrideConfiguration(overrideConfiguration); return this; } @Override public Builder overrideConfiguration(Consumer builderConsumer) { super.overrideConfiguration(builderConsumer); return this; } @Override public CreateTemplateRequest build() { return new CreateTemplateRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy