software.amazon.awssdk.services.ec2.model.LaunchTemplate Maven / Gradle / Ivy
Show all versions of ec2 Show documentation
/*
* 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.ec2.model;
import java.io.Serializable;
import java.time.Instant;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import software.amazon.awssdk.annotations.Generated;
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;
/**
*
* Describes a launch template.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class LaunchTemplate implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField LAUNCH_TEMPLATE_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("LaunchTemplateId")
.getter(getter(LaunchTemplate::launchTemplateId))
.setter(setter(Builder::launchTemplateId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LaunchTemplateId")
.unmarshallLocationName("launchTemplateId").build()).build();
private static final SdkField LAUNCH_TEMPLATE_NAME_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("LaunchTemplateName")
.getter(getter(LaunchTemplate::launchTemplateName))
.setter(setter(Builder::launchTemplateName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LaunchTemplateName")
.unmarshallLocationName("launchTemplateName").build()).build();
private static final SdkField CREATE_TIME_FIELD = SdkField
. builder(MarshallingType.INSTANT)
.memberName("CreateTime")
.getter(getter(LaunchTemplate::createTime))
.setter(setter(Builder::createTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CreateTime")
.unmarshallLocationName("createTime").build()).build();
private static final SdkField CREATED_BY_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("CreatedBy")
.getter(getter(LaunchTemplate::createdBy))
.setter(setter(Builder::createdBy))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CreatedBy")
.unmarshallLocationName("createdBy").build()).build();
private static final SdkField DEFAULT_VERSION_NUMBER_FIELD = SdkField
. builder(MarshallingType.LONG)
.memberName("DefaultVersionNumber")
.getter(getter(LaunchTemplate::defaultVersionNumber))
.setter(setter(Builder::defaultVersionNumber))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DefaultVersionNumber")
.unmarshallLocationName("defaultVersionNumber").build()).build();
private static final SdkField LATEST_VERSION_NUMBER_FIELD = SdkField
. builder(MarshallingType.LONG)
.memberName("LatestVersionNumber")
.getter(getter(LaunchTemplate::latestVersionNumber))
.setter(setter(Builder::latestVersionNumber))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LatestVersionNumber")
.unmarshallLocationName("latestVersionNumber").build()).build();
private static final SdkField> TAGS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Tags")
.getter(getter(LaunchTemplate::tags))
.setter(setter(Builder::tags))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TagSet")
.unmarshallLocationName("tagSet").build(),
ListTrait
.builder()
.memberLocationName("item")
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(Tag::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("Item").unmarshallLocationName("item").build()).build())
.build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(LAUNCH_TEMPLATE_ID_FIELD,
LAUNCH_TEMPLATE_NAME_FIELD, CREATE_TIME_FIELD, CREATED_BY_FIELD, DEFAULT_VERSION_NUMBER_FIELD,
LATEST_VERSION_NUMBER_FIELD, TAGS_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("LaunchTemplateId", LAUNCH_TEMPLATE_ID_FIELD);
put("LaunchTemplateName", LAUNCH_TEMPLATE_NAME_FIELD);
put("CreateTime", CREATE_TIME_FIELD);
put("CreatedBy", CREATED_BY_FIELD);
put("DefaultVersionNumber", DEFAULT_VERSION_NUMBER_FIELD);
put("LatestVersionNumber", LATEST_VERSION_NUMBER_FIELD);
put("TagSet", TAGS_FIELD);
}
});
private static final long serialVersionUID = 1L;
private final String launchTemplateId;
private final String launchTemplateName;
private final Instant createTime;
private final String createdBy;
private final Long defaultVersionNumber;
private final Long latestVersionNumber;
private final List tags;
private LaunchTemplate(BuilderImpl builder) {
this.launchTemplateId = builder.launchTemplateId;
this.launchTemplateName = builder.launchTemplateName;
this.createTime = builder.createTime;
this.createdBy = builder.createdBy;
this.defaultVersionNumber = builder.defaultVersionNumber;
this.latestVersionNumber = builder.latestVersionNumber;
this.tags = builder.tags;
}
/**
*
* The ID of the launch template.
*
*
* @return The ID of the launch template.
*/
public final String launchTemplateId() {
return launchTemplateId;
}
/**
*
* The name of the launch template.
*
*
* @return The name of the launch template.
*/
public final String launchTemplateName() {
return launchTemplateName;
}
/**
*
* The time launch template was created.
*
*
* @return The time launch template was created.
*/
public final Instant createTime() {
return createTime;
}
/**
*
* The principal that created the launch template.
*
*
* @return The principal that created the launch template.
*/
public final String createdBy() {
return createdBy;
}
/**
*
* The version number of the default version of the launch template.
*
*
* @return The version number of the default version of the launch template.
*/
public final Long defaultVersionNumber() {
return defaultVersionNumber;
}
/**
*
* The version number of the latest version of the launch template.
*
*
* @return The version number of the latest version of the launch template.
*/
public final Long latestVersionNumber() {
return latestVersionNumber;
}
/**
* For responses, this returns true if the service returned a value for the Tags 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 hasTags() {
return tags != null && !(tags instanceof SdkAutoConstructList);
}
/**
*
* The tags for the launch template.
*
*
* 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 #hasTags} method.
*
*
* @return The tags for the launch template.
*/
public final 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 final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(launchTemplateId());
hashCode = 31 * hashCode + Objects.hashCode(launchTemplateName());
hashCode = 31 * hashCode + Objects.hashCode(createTime());
hashCode = 31 * hashCode + Objects.hashCode(createdBy());
hashCode = 31 * hashCode + Objects.hashCode(defaultVersionNumber());
hashCode = 31 * hashCode + Objects.hashCode(latestVersionNumber());
hashCode = 31 * hashCode + Objects.hashCode(hasTags() ? tags() : null);
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof LaunchTemplate)) {
return false;
}
LaunchTemplate other = (LaunchTemplate) obj;
return Objects.equals(launchTemplateId(), other.launchTemplateId())
&& Objects.equals(launchTemplateName(), other.launchTemplateName())
&& Objects.equals(createTime(), other.createTime()) && Objects.equals(createdBy(), other.createdBy())
&& Objects.equals(defaultVersionNumber(), other.defaultVersionNumber())
&& Objects.equals(latestVersionNumber(), other.latestVersionNumber()) && hasTags() == other.hasTags()
&& 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 final String toString() {
return ToString.builder("LaunchTemplate").add("LaunchTemplateId", launchTemplateId())
.add("LaunchTemplateName", launchTemplateName()).add("CreateTime", createTime()).add("CreatedBy", createdBy())
.add("DefaultVersionNumber", defaultVersionNumber()).add("LatestVersionNumber", latestVersionNumber())
.add("Tags", hasTags() ? tags() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "LaunchTemplateId":
return Optional.ofNullable(clazz.cast(launchTemplateId()));
case "LaunchTemplateName":
return Optional.ofNullable(clazz.cast(launchTemplateName()));
case "CreateTime":
return Optional.ofNullable(clazz.cast(createTime()));
case "CreatedBy":
return Optional.ofNullable(clazz.cast(createdBy()));
case "DefaultVersionNumber":
return Optional.ofNullable(clazz.cast(defaultVersionNumber()));
case "LatestVersionNumber":
return Optional.ofNullable(clazz.cast(latestVersionNumber()));
case "Tags":
return Optional.ofNullable(clazz.cast(tags()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Function