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

software.amazon.awssdk.services.autoscaling.model.LifecycleHook 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.autoscaling.model;

import java.io.Serializable;
import java.util.Arrays;
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.Function;
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.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 * 

* Describes a lifecycle hook. A lifecycle hook lets you create solutions that are aware of events in the Auto Scaling * instance lifecycle, and then perform a custom action on instances when the corresponding lifecycle event occurs. *

*/ @Generated("software.amazon.awssdk:codegen") public final class LifecycleHook implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField LIFECYCLE_HOOK_NAME_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("LifecycleHookName").getter(getter(LifecycleHook::lifecycleHookName)) .setter(setter(Builder::lifecycleHookName)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LifecycleHookName").build()).build(); private static final SdkField AUTO_SCALING_GROUP_NAME_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("AutoScalingGroupName").getter(getter(LifecycleHook::autoScalingGroupName)) .setter(setter(Builder::autoScalingGroupName)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AutoScalingGroupName").build()) .build(); private static final SdkField LIFECYCLE_TRANSITION_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("LifecycleTransition").getter(getter(LifecycleHook::lifecycleTransition)) .setter(setter(Builder::lifecycleTransition)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LifecycleTransition").build()) .build(); private static final SdkField NOTIFICATION_TARGET_ARN_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("NotificationTargetARN").getter(getter(LifecycleHook::notificationTargetARN)) .setter(setter(Builder::notificationTargetARN)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NotificationTargetARN").build()) .build(); private static final SdkField ROLE_ARN_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("RoleARN").getter(getter(LifecycleHook::roleARN)).setter(setter(Builder::roleARN)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RoleARN").build()).build(); private static final SdkField NOTIFICATION_METADATA_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("NotificationMetadata").getter(getter(LifecycleHook::notificationMetadata)) .setter(setter(Builder::notificationMetadata)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NotificationMetadata").build()) .build(); private static final SdkField HEARTBEAT_TIMEOUT_FIELD = SdkField. builder(MarshallingType.INTEGER) .memberName("HeartbeatTimeout").getter(getter(LifecycleHook::heartbeatTimeout)) .setter(setter(Builder::heartbeatTimeout)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("HeartbeatTimeout").build()).build(); private static final SdkField GLOBAL_TIMEOUT_FIELD = SdkField. builder(MarshallingType.INTEGER) .memberName("GlobalTimeout").getter(getter(LifecycleHook::globalTimeout)).setter(setter(Builder::globalTimeout)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("GlobalTimeout").build()).build(); private static final SdkField DEFAULT_RESULT_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("DefaultResult").getter(getter(LifecycleHook::defaultResult)).setter(setter(Builder::defaultResult)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DefaultResult").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(LIFECYCLE_HOOK_NAME_FIELD, AUTO_SCALING_GROUP_NAME_FIELD, LIFECYCLE_TRANSITION_FIELD, NOTIFICATION_TARGET_ARN_FIELD, ROLE_ARN_FIELD, NOTIFICATION_METADATA_FIELD, HEARTBEAT_TIMEOUT_FIELD, GLOBAL_TIMEOUT_FIELD, DEFAULT_RESULT_FIELD)); private static final Map> SDK_NAME_TO_FIELD = Collections .unmodifiableMap(new HashMap>() { { put("LifecycleHookName", LIFECYCLE_HOOK_NAME_FIELD); put("AutoScalingGroupName", AUTO_SCALING_GROUP_NAME_FIELD); put("LifecycleTransition", LIFECYCLE_TRANSITION_FIELD); put("NotificationTargetARN", NOTIFICATION_TARGET_ARN_FIELD); put("RoleARN", ROLE_ARN_FIELD); put("NotificationMetadata", NOTIFICATION_METADATA_FIELD); put("HeartbeatTimeout", HEARTBEAT_TIMEOUT_FIELD); put("GlobalTimeout", GLOBAL_TIMEOUT_FIELD); put("DefaultResult", DEFAULT_RESULT_FIELD); } }); private static final long serialVersionUID = 1L; private final String lifecycleHookName; private final String autoScalingGroupName; private final String lifecycleTransition; private final String notificationTargetARN; private final String roleARN; private final String notificationMetadata; private final Integer heartbeatTimeout; private final Integer globalTimeout; private final String defaultResult; private LifecycleHook(BuilderImpl builder) { this.lifecycleHookName = builder.lifecycleHookName; this.autoScalingGroupName = builder.autoScalingGroupName; this.lifecycleTransition = builder.lifecycleTransition; this.notificationTargetARN = builder.notificationTargetARN; this.roleARN = builder.roleARN; this.notificationMetadata = builder.notificationMetadata; this.heartbeatTimeout = builder.heartbeatTimeout; this.globalTimeout = builder.globalTimeout; this.defaultResult = builder.defaultResult; } /** *

* The name of the lifecycle hook. *

* * @return The name of the lifecycle hook. */ public final String lifecycleHookName() { return lifecycleHookName; } /** *

* The name of the Auto Scaling group for the lifecycle hook. *

* * @return The name of the Auto Scaling group for the lifecycle hook. */ public final String autoScalingGroupName() { return autoScalingGroupName; } /** *

* The lifecycle transition. *

*

* Valid values: autoscaling:EC2_INSTANCE_LAUNCHING | autoscaling:EC2_INSTANCE_TERMINATING *

* * @return The lifecycle transition.

*

* Valid values: autoscaling:EC2_INSTANCE_LAUNCHING | * autoscaling:EC2_INSTANCE_TERMINATING */ public final String lifecycleTransition() { return lifecycleTransition; } /** *

* The ARN of the target that Amazon EC2 Auto Scaling sends notifications to when an instance is in a wait state for * the lifecycle hook. *

* * @return The ARN of the target that Amazon EC2 Auto Scaling sends notifications to when an instance is in a wait * state for the lifecycle hook. */ public final String notificationTargetARN() { return notificationTargetARN; } /** *

* The ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target (an * Amazon SNS topic or an Amazon SQS queue). *

* * @return The ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification * target (an Amazon SNS topic or an Amazon SQS queue). */ public final String roleARN() { return roleARN; } /** *

* Additional information that is included any time Amazon EC2 Auto Scaling sends a message to the notification * target. *

* * @return Additional information that is included any time Amazon EC2 Auto Scaling sends a message to the * notification target. */ public final String notificationMetadata() { return notificationMetadata; } /** *

* The maximum time, in seconds, that can elapse before the lifecycle hook times out. If the lifecycle hook times * out, Amazon EC2 Auto Scaling performs the action that you specified in the DefaultResult property. *

* * @return The maximum time, in seconds, that can elapse before the lifecycle hook times out. If the lifecycle hook * times out, Amazon EC2 Auto Scaling performs the action that you specified in the * DefaultResult property. */ public final Integer heartbeatTimeout() { return heartbeatTimeout; } /** *

* The maximum time, in seconds, that an instance can remain in a wait state. The maximum is 172800 seconds (48 * hours) or 100 times HeartbeatTimeout, whichever is smaller. *

* * @return The maximum time, in seconds, that an instance can remain in a wait state. The maximum is 172800 seconds * (48 hours) or 100 times HeartbeatTimeout, whichever is smaller. */ public final Integer globalTimeout() { return globalTimeout; } /** *

* The action the Auto Scaling group takes when the lifecycle hook timeout elapses or if an unexpected failure * occurs. *

*

* Valid values: CONTINUE | ABANDON *

* * @return The action the Auto Scaling group takes when the lifecycle hook timeout elapses or if an unexpected * failure occurs.

*

* Valid values: CONTINUE | ABANDON */ public final String defaultResult() { return defaultResult; } @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(lifecycleHookName()); hashCode = 31 * hashCode + Objects.hashCode(autoScalingGroupName()); hashCode = 31 * hashCode + Objects.hashCode(lifecycleTransition()); hashCode = 31 * hashCode + Objects.hashCode(notificationTargetARN()); hashCode = 31 * hashCode + Objects.hashCode(roleARN()); hashCode = 31 * hashCode + Objects.hashCode(notificationMetadata()); hashCode = 31 * hashCode + Objects.hashCode(heartbeatTimeout()); hashCode = 31 * hashCode + Objects.hashCode(globalTimeout()); hashCode = 31 * hashCode + Objects.hashCode(defaultResult()); 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 LifecycleHook)) { return false; } LifecycleHook other = (LifecycleHook) obj; return Objects.equals(lifecycleHookName(), other.lifecycleHookName()) && Objects.equals(autoScalingGroupName(), other.autoScalingGroupName()) && Objects.equals(lifecycleTransition(), other.lifecycleTransition()) && Objects.equals(notificationTargetARN(), other.notificationTargetARN()) && Objects.equals(roleARN(), other.roleARN()) && Objects.equals(notificationMetadata(), other.notificationMetadata()) && Objects.equals(heartbeatTimeout(), other.heartbeatTimeout()) && Objects.equals(globalTimeout(), other.globalTimeout()) && Objects.equals(defaultResult(), other.defaultResult()); } /** * 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("LifecycleHook").add("LifecycleHookName", lifecycleHookName()) .add("AutoScalingGroupName", autoScalingGroupName()).add("LifecycleTransition", lifecycleTransition()) .add("NotificationTargetARN", notificationTargetARN()).add("RoleARN", roleARN()) .add("NotificationMetadata", notificationMetadata()).add("HeartbeatTimeout", heartbeatTimeout()) .add("GlobalTimeout", globalTimeout()).add("DefaultResult", defaultResult()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "LifecycleHookName": return Optional.ofNullable(clazz.cast(lifecycleHookName())); case "AutoScalingGroupName": return Optional.ofNullable(clazz.cast(autoScalingGroupName())); case "LifecycleTransition": return Optional.ofNullable(clazz.cast(lifecycleTransition())); case "NotificationTargetARN": return Optional.ofNullable(clazz.cast(notificationTargetARN())); case "RoleARN": return Optional.ofNullable(clazz.cast(roleARN())); case "NotificationMetadata": return Optional.ofNullable(clazz.cast(notificationMetadata())); case "HeartbeatTimeout": return Optional.ofNullable(clazz.cast(heartbeatTimeout())); case "GlobalTimeout": return Optional.ofNullable(clazz.cast(globalTimeout())); case "DefaultResult": return Optional.ofNullable(clazz.cast(defaultResult())); 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((LifecycleHook) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The name of the lifecycle hook. *

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

* The name of the Auto Scaling group for the lifecycle hook. *

* * @param autoScalingGroupName * The name of the Auto Scaling group for the lifecycle hook. * @return Returns a reference to this object so that method calls can be chained together. */ Builder autoScalingGroupName(String autoScalingGroupName); /** *

* The lifecycle transition. *

*

* Valid values: autoscaling:EC2_INSTANCE_LAUNCHING | * autoscaling:EC2_INSTANCE_TERMINATING *

* * @param lifecycleTransition * The lifecycle transition.

*

* Valid values: autoscaling:EC2_INSTANCE_LAUNCHING | * autoscaling:EC2_INSTANCE_TERMINATING * @return Returns a reference to this object so that method calls can be chained together. */ Builder lifecycleTransition(String lifecycleTransition); /** *

* The ARN of the target that Amazon EC2 Auto Scaling sends notifications to when an instance is in a wait state * for the lifecycle hook. *

* * @param notificationTargetARN * The ARN of the target that Amazon EC2 Auto Scaling sends notifications to when an instance is in a * wait state for the lifecycle hook. * @return Returns a reference to this object so that method calls can be chained together. */ Builder notificationTargetARN(String notificationTargetARN); /** *

* The ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target * (an Amazon SNS topic or an Amazon SQS queue). *

* * @param roleARN * The ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification * target (an Amazon SNS topic or an Amazon SQS queue). * @return Returns a reference to this object so that method calls can be chained together. */ Builder roleARN(String roleARN); /** *

* Additional information that is included any time Amazon EC2 Auto Scaling sends a message to the notification * target. *

* * @param notificationMetadata * Additional information that is included any time Amazon EC2 Auto Scaling sends a message to the * notification target. * @return Returns a reference to this object so that method calls can be chained together. */ Builder notificationMetadata(String notificationMetadata); /** *

* The maximum time, in seconds, that can elapse before the lifecycle hook times out. If the lifecycle hook * times out, Amazon EC2 Auto Scaling performs the action that you specified in the DefaultResult * property. *

* * @param heartbeatTimeout * The maximum time, in seconds, that can elapse before the lifecycle hook times out. If the lifecycle * hook times out, Amazon EC2 Auto Scaling performs the action that you specified in the * DefaultResult property. * @return Returns a reference to this object so that method calls can be chained together. */ Builder heartbeatTimeout(Integer heartbeatTimeout); /** *

* The maximum time, in seconds, that an instance can remain in a wait state. The maximum is 172800 seconds (48 * hours) or 100 times HeartbeatTimeout, whichever is smaller. *

* * @param globalTimeout * The maximum time, in seconds, that an instance can remain in a wait state. The maximum is 172800 * seconds (48 hours) or 100 times HeartbeatTimeout, whichever is smaller. * @return Returns a reference to this object so that method calls can be chained together. */ Builder globalTimeout(Integer globalTimeout); /** *

* The action the Auto Scaling group takes when the lifecycle hook timeout elapses or if an unexpected failure * occurs. *

*

* Valid values: CONTINUE | ABANDON *

* * @param defaultResult * The action the Auto Scaling group takes when the lifecycle hook timeout elapses or if an unexpected * failure occurs.

*

* Valid values: CONTINUE | ABANDON * @return Returns a reference to this object so that method calls can be chained together. */ Builder defaultResult(String defaultResult); } static final class BuilderImpl implements Builder { private String lifecycleHookName; private String autoScalingGroupName; private String lifecycleTransition; private String notificationTargetARN; private String roleARN; private String notificationMetadata; private Integer heartbeatTimeout; private Integer globalTimeout; private String defaultResult; private BuilderImpl() { } private BuilderImpl(LifecycleHook model) { lifecycleHookName(model.lifecycleHookName); autoScalingGroupName(model.autoScalingGroupName); lifecycleTransition(model.lifecycleTransition); notificationTargetARN(model.notificationTargetARN); roleARN(model.roleARN); notificationMetadata(model.notificationMetadata); heartbeatTimeout(model.heartbeatTimeout); globalTimeout(model.globalTimeout); defaultResult(model.defaultResult); } public final String getLifecycleHookName() { return lifecycleHookName; } public final void setLifecycleHookName(String lifecycleHookName) { this.lifecycleHookName = lifecycleHookName; } @Override public final Builder lifecycleHookName(String lifecycleHookName) { this.lifecycleHookName = lifecycleHookName; return this; } public final String getAutoScalingGroupName() { return autoScalingGroupName; } public final void setAutoScalingGroupName(String autoScalingGroupName) { this.autoScalingGroupName = autoScalingGroupName; } @Override public final Builder autoScalingGroupName(String autoScalingGroupName) { this.autoScalingGroupName = autoScalingGroupName; return this; } public final String getLifecycleTransition() { return lifecycleTransition; } public final void setLifecycleTransition(String lifecycleTransition) { this.lifecycleTransition = lifecycleTransition; } @Override public final Builder lifecycleTransition(String lifecycleTransition) { this.lifecycleTransition = lifecycleTransition; return this; } public final String getNotificationTargetARN() { return notificationTargetARN; } public final void setNotificationTargetARN(String notificationTargetARN) { this.notificationTargetARN = notificationTargetARN; } @Override public final Builder notificationTargetARN(String notificationTargetARN) { this.notificationTargetARN = notificationTargetARN; return this; } public final String getRoleARN() { return roleARN; } public final void setRoleARN(String roleARN) { this.roleARN = roleARN; } @Override public final Builder roleARN(String roleARN) { this.roleARN = roleARN; return this; } public final String getNotificationMetadata() { return notificationMetadata; } public final void setNotificationMetadata(String notificationMetadata) { this.notificationMetadata = notificationMetadata; } @Override public final Builder notificationMetadata(String notificationMetadata) { this.notificationMetadata = notificationMetadata; return this; } public final Integer getHeartbeatTimeout() { return heartbeatTimeout; } public final void setHeartbeatTimeout(Integer heartbeatTimeout) { this.heartbeatTimeout = heartbeatTimeout; } @Override public final Builder heartbeatTimeout(Integer heartbeatTimeout) { this.heartbeatTimeout = heartbeatTimeout; return this; } public final Integer getGlobalTimeout() { return globalTimeout; } public final void setGlobalTimeout(Integer globalTimeout) { this.globalTimeout = globalTimeout; } @Override public final Builder globalTimeout(Integer globalTimeout) { this.globalTimeout = globalTimeout; return this; } public final String getDefaultResult() { return defaultResult; } public final void setDefaultResult(String defaultResult) { this.defaultResult = defaultResult; } @Override public final Builder defaultResult(String defaultResult) { this.defaultResult = defaultResult; return this; } @Override public LifecycleHook build() { return new LifecycleHook(this); } @Override public List> sdkFields() { return SDK_FIELDS; } @Override public Map> sdkFieldNameToField() { return SDK_NAME_TO_FIELD; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy