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

software.amazon.awssdk.services.ec2.model.LaunchTemplate Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Amazon EC2 module holds the client classes that are used for communicating with Amazon EC2 Service

The newest version!
/*
 * 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 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 getter(Function g) { return obj -> g.apply((LaunchTemplate) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The ID of the launch template. *

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

* The name of the launch template. *

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

* The time launch template was created. *

* * @param createTime * The time launch template was created. * @return Returns a reference to this object so that method calls can be chained together. */ Builder createTime(Instant createTime); /** *

* The principal that created the launch template. *

* * @param createdBy * The principal that created the launch template. * @return Returns a reference to this object so that method calls can be chained together. */ Builder createdBy(String createdBy); /** *

* The version number of the default version of the launch template. *

* * @param defaultVersionNumber * The version number of the default version of the launch template. * @return Returns a reference to this object so that method calls can be chained together. */ Builder defaultVersionNumber(Long defaultVersionNumber); /** *

* The version number of the latest version of the launch template. *

* * @param latestVersionNumber * The version number of the latest version of the launch template. * @return Returns a reference to this object so that method calls can be chained together. */ Builder latestVersionNumber(Long latestVersionNumber); /** *

* The tags for the launch template. *

* * @param tags * The tags for the launch template. * @return Returns a reference to this object so that method calls can be chained together. */ Builder tags(Collection tags); /** *

* The tags for the launch template. *

* * @param tags * The tags for the launch template. * @return Returns a reference to this object so that method calls can be chained together. */ Builder tags(Tag... tags); /** *

* The tags for the launch template. *

* This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.ec2.model.Tag.Builder} avoiding the need to create one manually via * {@link software.amazon.awssdk.services.ec2.model.Tag#builder()}. * *

* When the {@link Consumer} completes, {@link software.amazon.awssdk.services.ec2.model.Tag.Builder#build()} is * called immediately and its result is passed to {@link #tags(List)}. * * @param tags * a consumer that will call methods on {@link software.amazon.awssdk.services.ec2.model.Tag.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #tags(java.util.Collection) */ Builder tags(Consumer... tags); } static final class BuilderImpl implements Builder { private String launchTemplateId; private String launchTemplateName; private Instant createTime; private String createdBy; private Long defaultVersionNumber; private Long latestVersionNumber; private List tags = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(LaunchTemplate model) { launchTemplateId(model.launchTemplateId); launchTemplateName(model.launchTemplateName); createTime(model.createTime); createdBy(model.createdBy); defaultVersionNumber(model.defaultVersionNumber); latestVersionNumber(model.latestVersionNumber); tags(model.tags); } public final String getLaunchTemplateId() { return launchTemplateId; } public final void setLaunchTemplateId(String launchTemplateId) { this.launchTemplateId = launchTemplateId; } @Override public final Builder launchTemplateId(String launchTemplateId) { this.launchTemplateId = launchTemplateId; return this; } public final String getLaunchTemplateName() { return launchTemplateName; } public final void setLaunchTemplateName(String launchTemplateName) { this.launchTemplateName = launchTemplateName; } @Override public final Builder launchTemplateName(String launchTemplateName) { this.launchTemplateName = launchTemplateName; return this; } public final Instant getCreateTime() { return createTime; } public final void setCreateTime(Instant createTime) { this.createTime = createTime; } @Override public final Builder createTime(Instant createTime) { this.createTime = createTime; return this; } public final String getCreatedBy() { return createdBy; } public final void setCreatedBy(String createdBy) { this.createdBy = createdBy; } @Override public final Builder createdBy(String createdBy) { this.createdBy = createdBy; return this; } public final Long getDefaultVersionNumber() { return defaultVersionNumber; } public final void setDefaultVersionNumber(Long defaultVersionNumber) { this.defaultVersionNumber = defaultVersionNumber; } @Override public final Builder defaultVersionNumber(Long defaultVersionNumber) { this.defaultVersionNumber = defaultVersionNumber; return this; } public final Long getLatestVersionNumber() { return latestVersionNumber; } public final void setLatestVersionNumber(Long latestVersionNumber) { this.latestVersionNumber = latestVersionNumber; } @Override public final Builder latestVersionNumber(Long latestVersionNumber) { this.latestVersionNumber = latestVersionNumber; return this; } public final List getTags() { List result = TagListCopier.copyToBuilder(this.tags); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setTags(Collection tags) { this.tags = TagListCopier.copyFromBuilder(tags); } @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; } @Override public LaunchTemplate build() { return new LaunchTemplate(this); } @Override public List> sdkFields() { return SDK_FIELDS; } @Override public Map> sdkFieldNameToField() { return SDK_NAME_TO_FIELD; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy