
software.amazon.awssdk.services.ssm.model.CreateActivationRequest Maven / Gradle / Ivy
/*
* Copyright 2014-2019 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.ssm.model;
import java.time.Instant;
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.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*/
@Generated("software.amazon.awssdk:codegen")
public final class CreateActivationRequest extends SsmRequest implements
ToCopyableBuilder {
private static final SdkField DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(CreateActivationRequest::description)).setter(setter(Builder::description))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Description").build()).build();
private static final SdkField DEFAULT_INSTANCE_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(CreateActivationRequest::defaultInstanceName)).setter(setter(Builder::defaultInstanceName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DefaultInstanceName").build())
.build();
private static final SdkField IAM_ROLE_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(CreateActivationRequest::iamRole)).setter(setter(Builder::iamRole))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("IamRole").build()).build();
private static final SdkField REGISTRATION_LIMIT_FIELD = SdkField. builder(MarshallingType.INTEGER)
.getter(getter(CreateActivationRequest::registrationLimit)).setter(setter(Builder::registrationLimit))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RegistrationLimit").build()).build();
private static final SdkField EXPIRATION_DATE_FIELD = SdkField. builder(MarshallingType.INSTANT)
.getter(getter(CreateActivationRequest::expirationDate)).setter(setter(Builder::expirationDate))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ExpirationDate").build()).build();
private static final SdkField> TAGS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.getter(getter(CreateActivationRequest::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 List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(DESCRIPTION_FIELD,
DEFAULT_INSTANCE_NAME_FIELD, IAM_ROLE_FIELD, REGISTRATION_LIMIT_FIELD, EXPIRATION_DATE_FIELD, TAGS_FIELD));
private final String description;
private final String defaultInstanceName;
private final String iamRole;
private final Integer registrationLimit;
private final Instant expirationDate;
private final List tags;
private CreateActivationRequest(BuilderImpl builder) {
super(builder);
this.description = builder.description;
this.defaultInstanceName = builder.defaultInstanceName;
this.iamRole = builder.iamRole;
this.registrationLimit = builder.registrationLimit;
this.expirationDate = builder.expirationDate;
this.tags = builder.tags;
}
/**
*
* A user-defined description of the resource that you want to register with Amazon EC2.
*
*
*
* Do not enter personally identifiable information in this field.
*
*
*
* @return A user-defined description of the resource that you want to register with Amazon EC2.
*
* Do not enter personally identifiable information in this field.
*
*/
public String description() {
return description;
}
/**
*
* The name of the registered, managed instance as it will appear in the Amazon EC2 console or when you use the AWS
* command line tools to list EC2 resources.
*
*
*
* Do not enter personally identifiable information in this field.
*
*
*
* @return The name of the registered, managed instance as it will appear in the Amazon EC2 console or when you use
* the AWS command line tools to list EC2 resources.
*
* Do not enter personally identifiable information in this field.
*
*/
public String defaultInstanceName() {
return defaultInstanceName;
}
/**
*
* The Amazon Identity and Access Management (IAM) role that you want to assign to the managed instance.
*
*
* @return The Amazon Identity and Access Management (IAM) role that you want to assign to the managed instance.
*/
public String iamRole() {
return iamRole;
}
/**
*
* Specify the maximum number of managed instances you want to register. The default value is 1 instance.
*
*
* @return Specify the maximum number of managed instances you want to register. The default value is 1 instance.
*/
public Integer registrationLimit() {
return registrationLimit;
}
/**
*
* The date by which this activation request should expire. The default value is 24 hours.
*
*
* @return The date by which this activation request should expire. The default value is 24 hours.
*/
public Instant expirationDate() {
return expirationDate;
}
/**
*
* Optional metadata that you assign to a resource. Tags enable you to categorize a resource in different ways, such
* as by purpose, owner, or environment. For example, you might want to tag an activation to identify which servers
* or virtual machines (VMs) in your on-premises environment you intend to activate. In this case, you could specify
* the following key name/value pairs:
*
*
* -
*
* Key=OS,Value=Windows
*
*
* -
*
* Key=Environment,Value=Production
*
*
*
*
*
* When you install SSM Agent on your on-premises servers and VMs, you specify an activation ID and code. When you
* specify the activation ID and code, tags assigned to the activation are automatically applied to the on-premises
* servers or VMs.
*
*
*
* You can't add tags to or delete tags from an existing activation. You can tag your on-premises servers and VMs
* after they connect to Systems Manager for the first time and are assigned a managed instance ID. This means they
* are listed in the AWS Systems Manager console with an ID that is prefixed with "mi-". For information about how
* to add tags to your managed instances, see AddTagsToResource. For information about how to remove tags
* from your managed instances, see RemoveTagsFromResource.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return Optional metadata that you assign to a resource. Tags enable you to categorize a resource in different
* ways, such as by purpose, owner, or environment. For example, you might want to tag an activation to
* identify which servers or virtual machines (VMs) in your on-premises environment you intend to activate.
* In this case, you could specify the following key name/value pairs:
*
* -
*
* Key=OS,Value=Windows
*
*
* -
*
* Key=Environment,Value=Production
*
*
*
*
*
* When you install SSM Agent on your on-premises servers and VMs, you specify an activation ID and code.
* When you specify the activation ID and code, tags assigned to the activation are automatically applied to
* the on-premises servers or VMs.
*
*
*
* You can't add tags to or delete tags from an existing activation. You can tag your on-premises servers
* and VMs after they connect to Systems Manager for the first time and are assigned a managed instance ID.
* This means they are listed in the AWS Systems Manager console with an ID that is prefixed with "mi-". For
* information about how to add tags to your managed instances, see AddTagsToResource. For
* information about how to remove tags from your managed instances, see RemoveTagsFromResource.
*/
public List tags() {
return tags;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(description());
hashCode = 31 * hashCode + Objects.hashCode(defaultInstanceName());
hashCode = 31 * hashCode + Objects.hashCode(iamRole());
hashCode = 31 * hashCode + Objects.hashCode(registrationLimit());
hashCode = 31 * hashCode + Objects.hashCode(expirationDate());
hashCode = 31 * hashCode + Objects.hashCode(tags());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof CreateActivationRequest)) {
return false;
}
CreateActivationRequest other = (CreateActivationRequest) obj;
return Objects.equals(description(), other.description())
&& Objects.equals(defaultInstanceName(), other.defaultInstanceName())
&& Objects.equals(iamRole(), other.iamRole()) && Objects.equals(registrationLimit(), other.registrationLimit())
&& Objects.equals(expirationDate(), other.expirationDate()) && Objects.equals(tags(), other.tags());
}
/**
* 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("CreateActivationRequest").add("Description", description())
.add("DefaultInstanceName", defaultInstanceName()).add("IamRole", iamRole())
.add("RegistrationLimit", registrationLimit()).add("ExpirationDate", expirationDate()).add("Tags", tags())
.build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Description":
return Optional.ofNullable(clazz.cast(description()));
case "DefaultInstanceName":
return Optional.ofNullable(clazz.cast(defaultInstanceName()));
case "IamRole":
return Optional.ofNullable(clazz.cast(iamRole()));
case "RegistrationLimit":
return Optional.ofNullable(clazz.cast(registrationLimit()));
case "ExpirationDate":
return Optional.ofNullable(clazz.cast(expirationDate()));
case "Tags":
return Optional.ofNullable(clazz.cast(tags()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function
*
* Do not enter personally identifiable information in this field.
*
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder description(String description);
/**
*
* The name of the registered, managed instance as it will appear in the Amazon EC2 console or when you use the
* AWS command line tools to list EC2 resources.
*
*
*
* Do not enter personally identifiable information in this field.
*
*
*
* @param defaultInstanceName
* The name of the registered, managed instance as it will appear in the Amazon EC2 console or when you
* use the AWS command line tools to list EC2 resources.
*
* Do not enter personally identifiable information in this field.
*
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder defaultInstanceName(String defaultInstanceName);
/**
*
* The Amazon Identity and Access Management (IAM) role that you want to assign to the managed instance.
*
*
* @param iamRole
* The Amazon Identity and Access Management (IAM) role that you want to assign to the managed instance.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder iamRole(String iamRole);
/**
*
* Specify the maximum number of managed instances you want to register. The default value is 1 instance.
*
*
* @param registrationLimit
* Specify the maximum number of managed instances you want to register. The default value is 1 instance.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder registrationLimit(Integer registrationLimit);
/**
*
* The date by which this activation request should expire. The default value is 24 hours.
*
*
* @param expirationDate
* The date by which this activation request should expire. The default value is 24 hours.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder expirationDate(Instant expirationDate);
/**
*
* Optional metadata that you assign to a resource. Tags enable you to categorize a resource in different ways,
* such as by purpose, owner, or environment. For example, you might want to tag an activation to identify which
* servers or virtual machines (VMs) in your on-premises environment you intend to activate. In this case, you
* could specify the following key name/value pairs:
*
*
* -
*
* Key=OS,Value=Windows
*
*
* -
*
* Key=Environment,Value=Production
*
*
*
*
*
* When you install SSM Agent on your on-premises servers and VMs, you specify an activation ID and code. When
* you specify the activation ID and code, tags assigned to the activation are automatically applied to the
* on-premises servers or VMs.
*
*
*
* You can't add tags to or delete tags from an existing activation. You can tag your on-premises servers and
* VMs after they connect to Systems Manager for the first time and are assigned a managed instance ID. This
* means they are listed in the AWS Systems Manager console with an ID that is prefixed with "mi-". For
* information about how to add tags to your managed instances, see AddTagsToResource. For information
* about how to remove tags from your managed instances, see RemoveTagsFromResource.
*
*
* @param tags
* Optional metadata that you assign to a resource. Tags enable you to categorize a resource in different
* ways, such as by purpose, owner, or environment. For example, you might want to tag an activation to
* identify which servers or virtual machines (VMs) in your on-premises environment you intend to
* activate. In this case, you could specify the following key name/value pairs:
*
* -
*
* Key=OS,Value=Windows
*
*
* -
*
* Key=Environment,Value=Production
*
*
*
*
*
* When you install SSM Agent on your on-premises servers and VMs, you specify an activation ID and code.
* When you specify the activation ID and code, tags assigned to the activation are automatically applied
* to the on-premises servers or VMs.
*
*
*
* You can't add tags to or delete tags from an existing activation. You can tag your on-premises servers
* and VMs after they connect to Systems Manager for the first time and are assigned a managed instance
* ID. This means they are listed in the AWS Systems Manager console with an ID that is prefixed with
* "mi-". For information about how to add tags to your managed instances, see AddTagsToResource.
* For information about how to remove tags from your managed instances, see
* RemoveTagsFromResource.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder tags(Collection tags);
/**
*
* Optional metadata that you assign to a resource. Tags enable you to categorize a resource in different ways,
* such as by purpose, owner, or environment. For example, you might want to tag an activation to identify which
* servers or virtual machines (VMs) in your on-premises environment you intend to activate. In this case, you
* could specify the following key name/value pairs:
*
*
* -
*
* Key=OS,Value=Windows
*
*
* -
*
* Key=Environment,Value=Production
*
*
*
*
*
* When you install SSM Agent on your on-premises servers and VMs, you specify an activation ID and code. When
* you specify the activation ID and code, tags assigned to the activation are automatically applied to the
* on-premises servers or VMs.
*
*
*
* You can't add tags to or delete tags from an existing activation. You can tag your on-premises servers and
* VMs after they connect to Systems Manager for the first time and are assigned a managed instance ID. This
* means they are listed in the AWS Systems Manager console with an ID that is prefixed with "mi-". For
* information about how to add tags to your managed instances, see AddTagsToResource. For information
* about how to remove tags from your managed instances, see RemoveTagsFromResource.
*
*
* @param tags
* Optional metadata that you assign to a resource. Tags enable you to categorize a resource in different
* ways, such as by purpose, owner, or environment. For example, you might want to tag an activation to
* identify which servers or virtual machines (VMs) in your on-premises environment you intend to
* activate. In this case, you could specify the following key name/value pairs:
*
* -
*
* Key=OS,Value=Windows
*
*
* -
*
* Key=Environment,Value=Production
*
*
*
*
*
* When you install SSM Agent on your on-premises servers and VMs, you specify an activation ID and code.
* When you specify the activation ID and code, tags assigned to the activation are automatically applied
* to the on-premises servers or VMs.
*
*
*
* You can't add tags to or delete tags from an existing activation. You can tag your on-premises servers
* and VMs after they connect to Systems Manager for the first time and are assigned a managed instance
* ID. This means they are listed in the AWS Systems Manager console with an ID that is prefixed with
* "mi-". For information about how to add tags to your managed instances, see AddTagsToResource.
* For information about how to remove tags from your managed instances, see
* RemoveTagsFromResource.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder tags(Tag... tags);
/**
*
* Optional metadata that you assign to a resource. Tags enable you to categorize a resource in different ways,
* such as by purpose, owner, or environment. For example, you might want to tag an activation to identify which
* servers or virtual machines (VMs) in your on-premises environment you intend to activate. In this case, you
* could specify the following key name/value pairs:
*
*
* -
*
* Key=OS,Value=Windows
*
*
* -
*
* Key=Environment,Value=Production
*
*
*
*
*
* When you install SSM Agent on your on-premises servers and VMs, you specify an activation ID and code. When
* you specify the activation ID and code, tags assigned to the activation are automatically applied to the
* on-premises servers or VMs.
*
*
*
* You can't add tags to or delete tags from an existing activation. You can tag your on-premises servers and
* VMs after they connect to Systems Manager for the first time and are assigned a managed instance ID. This
* means they are listed in the AWS Systems Manager console with an ID that is prefixed with "mi-". For
* information about how to add tags to your managed instances, see AddTagsToResource. For information
* about how to remove tags from your managed instances, see RemoveTagsFromResource.
*
* 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);
@Override
Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration);
@Override
Builder overrideConfiguration(Consumer builderConsumer);
}
static final class BuilderImpl extends SsmRequest.BuilderImpl implements Builder {
private String description;
private String defaultInstanceName;
private String iamRole;
private Integer registrationLimit;
private Instant expirationDate;
private List tags = DefaultSdkAutoConstructList.getInstance();
private BuilderImpl() {
}
private BuilderImpl(CreateActivationRequest model) {
super(model);
description(model.description);
defaultInstanceName(model.defaultInstanceName);
iamRole(model.iamRole);
registrationLimit(model.registrationLimit);
expirationDate(model.expirationDate);
tags(model.tags);
}
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 String getDefaultInstanceName() {
return defaultInstanceName;
}
@Override
public final Builder defaultInstanceName(String defaultInstanceName) {
this.defaultInstanceName = defaultInstanceName;
return this;
}
public final void setDefaultInstanceName(String defaultInstanceName) {
this.defaultInstanceName = defaultInstanceName;
}
public final String getIamRole() {
return iamRole;
}
@Override
public final Builder iamRole(String iamRole) {
this.iamRole = iamRole;
return this;
}
public final void setIamRole(String iamRole) {
this.iamRole = iamRole;
}
public final Integer getRegistrationLimit() {
return registrationLimit;
}
@Override
public final Builder registrationLimit(Integer registrationLimit) {
this.registrationLimit = registrationLimit;
return this;
}
public final void setRegistrationLimit(Integer registrationLimit) {
this.registrationLimit = registrationLimit;
}
public final Instant getExpirationDate() {
return expirationDate;
}
@Override
public final Builder expirationDate(Instant expirationDate) {
this.expirationDate = expirationDate;
return this;
}
public final void setExpirationDate(Instant expirationDate) {
this.expirationDate = expirationDate;
}
public final Collection getTags() {
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);
}
@Override
public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) {
super.overrideConfiguration(overrideConfiguration);
return this;
}
@Override
public Builder overrideConfiguration(Consumer builderConsumer) {
super.overrideConfiguration(builderConsumer);
return this;
}
@Override
public CreateActivationRequest build() {
return new CreateActivationRequest(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}