Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010-2015 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 com.amazonaws.services.autoscaling.model;
 

Describes a lifecycle hook, which tells Auto Scaling that you want to perform an action when an instance launches or terminates. When you have a lifecycle hook in place, the Auto Scaling group will either:

  • Pause the instance after it launches, but before it is put into service
  • Pause the instance as it terminates, but before it is fully terminated

For more information, see Auto Scaling Pending State and Auto Scaling Terminating State in the Auto Scaling Developer Guide .

 
 public class LifecycleHook implements SerializableCloneable {

    
The name of the lifecycle hook.

Constraints:
Length: 1 - 255
Pattern: [A-Za-z0-9\-_\/]+

 
     private String lifecycleHookName;

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

Constraints:
Length: 1 - 1600
Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

 
     private String autoScalingGroupName;

    
The state of the EC2 instance to which you want to attach the lifecycle hook. For a list of lifecycle hook types, see DescribeLifecycleHookTypes.
 
     private String lifecycleTransition;

    
The ARN of the notification target that Auto Scaling uses to notify you when an instance is in the transition state for the lifecycle hook. This ARN target can be either an SQS queue or an SNS topic. The notification message sent to the target includes the following:
  • Lifecycle action token
  • User account ID
  • Name of the Auto Scaling group
  • Lifecycle hook name
  • EC2 instance ID
  • Lifecycle transition
  • Notification metadata

Constraints:
Length: 1 - 1600
Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

 
     private String notificationTargetARN;

    
The ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target.

Constraints:
Length: 1 - 1600
Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

 
     private String roleARN;

    
Additional information that you want to include any time Auto Scaling sends a message to the notification target.

Constraints:
Length: 1 - 1023
Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

 
    private String notificationMetadata;

    
The amount of time that can elapse before the lifecycle hook times out. When the lifecycle hook times out, Auto Scaling performs the action defined in the DefaultResult parameter. You can prevent the lifecycle hook from timing out by calling RecordLifecycleActionHeartbeat.
    private Integer heartbeatTimeout;

    
The maximum length of time an instance can remain in a Pending:Wait or Terminating:Wait state. Currently, this value is set at 48 hours.
    private Integer globalTimeout;

    
Defines the action the Auto Scaling group should take when the lifecycle hook timeout elapses or if an unexpected failure occurs. The valid values are CONTINUE and ABANDON. The default value is CONTINUE.
    private String defaultResult;

    
The name of the lifecycle hook.

Constraints:
Length: 1 - 255
Pattern: [A-Za-z0-9\-_\/]+

Returns:
The name of the lifecycle hook.
    public String getLifecycleHookName() {
        return ;
    }
    
    
The name of the lifecycle hook.

Constraints:
Length: 1 - 255
Pattern: [A-Za-z0-9\-_\/]+

Parameters:
lifecycleHookName The name of the lifecycle hook.
    public void setLifecycleHookName(String lifecycleHookName) {
        this. = lifecycleHookName;
    }
    
    
The name of the lifecycle hook.

Returns a reference to this object so that method calls can be chained together.

Constraints:
Length: 1 - 255
Pattern: [A-Za-z0-9\-_\/]+

Parameters:
lifecycleHookName The name of the lifecycle hook.
Returns:
A reference to this updated object so that method calls can be chained together.
    public LifecycleHook withLifecycleHookName(String lifecycleHookName) {
        this. = lifecycleHookName;
        return this;
    }

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

Constraints:
Length: 1 - 1600
Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

Returns:
The name of the Auto Scaling group for the lifecycle hook.
    public String getAutoScalingGroupName() {
        return ;
    }
    
    
The name of the Auto Scaling group for the lifecycle hook.

Constraints:
Length: 1 - 1600
Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

Parameters:
autoScalingGroupName The name of the Auto Scaling group for the lifecycle hook.
    public void setAutoScalingGroupName(String autoScalingGroupName) {
        this. = autoScalingGroupName;
    }
    
    
The name of the Auto Scaling group for the lifecycle hook.

Returns a reference to this object so that method calls can be chained together.

Constraints:
Length: 1 - 1600
Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

Parameters:
autoScalingGroupName The name of the Auto Scaling group for the lifecycle hook.
Returns:
A reference to this updated object so that method calls can be chained together.
    public LifecycleHook withAutoScalingGroupName(String autoScalingGroupName) {
        this. = autoScalingGroupName;
        return this;
    }

    
The state of the EC2 instance to which you want to attach the lifecycle hook. For a list of lifecycle hook types, see DescribeLifecycleHookTypes.

Returns:
The state of the EC2 instance to which you want to attach the lifecycle hook. For a list of lifecycle hook types, see DescribeLifecycleHookTypes.
    public String getLifecycleTransition() {
        return ;
    }
    
    
The state of the EC2 instance to which you want to attach the lifecycle hook. For a list of lifecycle hook types, see DescribeLifecycleHookTypes.

Parameters:
lifecycleTransition The state of the EC2 instance to which you want to attach the lifecycle hook. For a list of lifecycle hook types, see DescribeLifecycleHookTypes.
    public void setLifecycleTransition(String lifecycleTransition) {
        this. = lifecycleTransition;
    }
    
    
The state of the EC2 instance to which you want to attach the lifecycle hook. For a list of lifecycle hook types, see DescribeLifecycleHookTypes.

Returns a reference to this object so that method calls can be chained together.

Parameters:
lifecycleTransition The state of the EC2 instance to which you want to attach the lifecycle hook. For a list of lifecycle hook types, see DescribeLifecycleHookTypes.
Returns:
A reference to this updated object so that method calls can be chained together.
    public LifecycleHook withLifecycleTransition(String lifecycleTransition) {
        this. = lifecycleTransition;
        return this;
    }

    
The ARN of the notification target that Auto Scaling uses to notify you when an instance is in the transition state for the lifecycle hook. This ARN target can be either an SQS queue or an SNS topic. The notification message sent to the target includes the following:
  • Lifecycle action token
  • User account ID
  • Name of the Auto Scaling group
  • Lifecycle hook name
  • EC2 instance ID
  • Lifecycle transition
  • Notification metadata

Constraints:
Length: 1 - 1600
Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

Returns:
The ARN of the notification target that Auto Scaling uses to notify you when an instance is in the transition state for the lifecycle hook. This ARN target can be either an SQS queue or an SNS topic. The notification message sent to the target includes the following:
  • Lifecycle action token
  • User account ID
  • Name of the Auto Scaling group
  • Lifecycle hook name
  • EC2 instance ID
  • Lifecycle transition
  • Notification metadata
    public String getNotificationTargetARN() {
        return ;
    }
    
    
The ARN of the notification target that Auto Scaling uses to notify you when an instance is in the transition state for the lifecycle hook. This ARN target can be either an SQS queue or an SNS topic. The notification message sent to the target includes the following:
  • Lifecycle action token
  • User account ID
  • Name of the Auto Scaling group
  • Lifecycle hook name
  • EC2 instance ID
  • Lifecycle transition
  • Notification metadata

Constraints:
Length: 1 - 1600
Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

Parameters:
notificationTargetARN The ARN of the notification target that Auto Scaling uses to notify you when an instance is in the transition state for the lifecycle hook. This ARN target can be either an SQS queue or an SNS topic. The notification message sent to the target includes the following:
  • Lifecycle action token
  • User account ID
  • Name of the Auto Scaling group
  • Lifecycle hook name
  • EC2 instance ID
  • Lifecycle transition
  • Notification metadata
    public void setNotificationTargetARN(String notificationTargetARN) {
        this. = notificationTargetARN;
    }
    
    
The ARN of the notification target that Auto Scaling uses to notify you when an instance is in the transition state for the lifecycle hook. This ARN target can be either an SQS queue or an SNS topic. The notification message sent to the target includes the following:
  • Lifecycle action token
  • User account ID
  • Name of the Auto Scaling group
  • Lifecycle hook name
  • EC2 instance ID
  • Lifecycle transition
  • Notification metadata

Returns a reference to this object so that method calls can be chained together.

Constraints:
Length: 1 - 1600
Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

Parameters:
notificationTargetARN The ARN of the notification target that Auto Scaling uses to notify you when an instance is in the transition state for the lifecycle hook. This ARN target can be either an SQS queue or an SNS topic. The notification message sent to the target includes the following:
  • Lifecycle action token
  • User account ID
  • Name of the Auto Scaling group
  • Lifecycle hook name
  • EC2 instance ID
  • Lifecycle transition
  • Notification metadata
Returns:
A reference to this updated object so that method calls can be chained together.
    public LifecycleHook withNotificationTargetARN(String notificationTargetARN) {
        this. = notificationTargetARN;
        return this;
    }

    
The ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target.

Constraints:
Length: 1 - 1600
Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

Returns:
The ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target.
    public String getRoleARN() {
        return ;
    }
    
    
The ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target.

Constraints:
Length: 1 - 1600
Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

Parameters:
roleARN The ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target.
    public void setRoleARN(String roleARN) {
        this. = roleARN;
    }
    
    
The ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target.

Returns a reference to this object so that method calls can be chained together.

Constraints:
Length: 1 - 1600
Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

Parameters:
roleARN The ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target.
Returns:
A reference to this updated object so that method calls can be chained together.
    public LifecycleHook withRoleARN(String roleARN) {
        this. = roleARN;
        return this;
    }

    
Additional information that you want to include any time Auto Scaling sends a message to the notification target.

Constraints:
Length: 1 - 1023
Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

Returns:
Additional information that you want to include any time Auto Scaling sends a message to the notification target.
    public String getNotificationMetadata() {
        return ;
    }
    
    
Additional information that you want to include any time Auto Scaling sends a message to the notification target.

Constraints:
Length: 1 - 1023
Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

Parameters:
notificationMetadata Additional information that you want to include any time Auto Scaling sends a message to the notification target.
    public void setNotificationMetadata(String notificationMetadata) {
        this. = notificationMetadata;
    }
    
    
Additional information that you want to include any time Auto Scaling sends a message to the notification target.

Returns a reference to this object so that method calls can be chained together.

Constraints:
Length: 1 - 1023
Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

Parameters:
notificationMetadata Additional information that you want to include any time Auto Scaling sends a message to the notification target.
Returns:
A reference to this updated object so that method calls can be chained together.
    public LifecycleHook withNotificationMetadata(String notificationMetadata) {
        this. = notificationMetadata;
        return this;
    }

    
The amount of time that can elapse before the lifecycle hook times out. When the lifecycle hook times out, Auto Scaling performs the action defined in the DefaultResult parameter. You can prevent the lifecycle hook from timing out by calling RecordLifecycleActionHeartbeat.

Returns:
The amount of time that can elapse before the lifecycle hook times out. When the lifecycle hook times out, Auto Scaling performs the action defined in the DefaultResult parameter. You can prevent the lifecycle hook from timing out by calling RecordLifecycleActionHeartbeat.
    public Integer getHeartbeatTimeout() {
        return ;
    }
    
    
The amount of time that can elapse before the lifecycle hook times out. When the lifecycle hook times out, Auto Scaling performs the action defined in the DefaultResult parameter. You can prevent the lifecycle hook from timing out by calling RecordLifecycleActionHeartbeat.

Parameters:
heartbeatTimeout The amount of time that can elapse before the lifecycle hook times out. When the lifecycle hook times out, Auto Scaling performs the action defined in the DefaultResult parameter. You can prevent the lifecycle hook from timing out by calling RecordLifecycleActionHeartbeat.
    public void setHeartbeatTimeout(Integer heartbeatTimeout) {
        this. = heartbeatTimeout;
    }
    
    
The amount of time that can elapse before the lifecycle hook times out. When the lifecycle hook times out, Auto Scaling performs the action defined in the DefaultResult parameter. You can prevent the lifecycle hook from timing out by calling RecordLifecycleActionHeartbeat.

Returns a reference to this object so that method calls can be chained together.

Parameters:
heartbeatTimeout The amount of time that can elapse before the lifecycle hook times out. When the lifecycle hook times out, Auto Scaling performs the action defined in the DefaultResult parameter. You can prevent the lifecycle hook from timing out by calling RecordLifecycleActionHeartbeat.
Returns:
A reference to this updated object so that method calls can be chained together.
    public LifecycleHook withHeartbeatTimeout(Integer heartbeatTimeout) {
        this. = heartbeatTimeout;
        return this;
    }

    
The maximum length of time an instance can remain in a Pending:Wait or Terminating:Wait state. Currently, this value is set at 48 hours.

Returns:
The maximum length of time an instance can remain in a Pending:Wait or Terminating:Wait state. Currently, this value is set at 48 hours.
    public Integer getGlobalTimeout() {
        return ;
    }
    
    
The maximum length of time an instance can remain in a Pending:Wait or Terminating:Wait state. Currently, this value is set at 48 hours.

Parameters:
globalTimeout The maximum length of time an instance can remain in a Pending:Wait or Terminating:Wait state. Currently, this value is set at 48 hours.
    public void setGlobalTimeout(Integer globalTimeout) {
        this. = globalTimeout;
    }
    
    
The maximum length of time an instance can remain in a Pending:Wait or Terminating:Wait state. Currently, this value is set at 48 hours.

Returns a reference to this object so that method calls can be chained together.

Parameters:
globalTimeout The maximum length of time an instance can remain in a Pending:Wait or Terminating:Wait state. Currently, this value is set at 48 hours.
Returns:
A reference to this updated object so that method calls can be chained together.
    public LifecycleHook withGlobalTimeout(Integer globalTimeout) {
        this. = globalTimeout;
        return this;
    }

    
Defines the action the Auto Scaling group should take when the lifecycle hook timeout elapses or if an unexpected failure occurs. The valid values are CONTINUE and ABANDON. The default value is CONTINUE.

Returns:
Defines the action the Auto Scaling group should take when the lifecycle hook timeout elapses or if an unexpected failure occurs. The valid values are CONTINUE and ABANDON. The default value is CONTINUE.
    public String getDefaultResult() {
        return ;
    }
    
    
Defines the action the Auto Scaling group should take when the lifecycle hook timeout elapses or if an unexpected failure occurs. The valid values are CONTINUE and ABANDON. The default value is CONTINUE.

Parameters:
defaultResult Defines the action the Auto Scaling group should take when the lifecycle hook timeout elapses or if an unexpected failure occurs. The valid values are CONTINUE and ABANDON. The default value is CONTINUE.
    public void setDefaultResult(String defaultResult) {
        this. = defaultResult;
    }
    
    
Defines the action the Auto Scaling group should take when the lifecycle hook timeout elapses or if an unexpected failure occurs. The valid values are CONTINUE and ABANDON. The default value is CONTINUE.

Returns a reference to this object so that method calls can be chained together.

Parameters:
defaultResult Defines the action the Auto Scaling group should take when the lifecycle hook timeout elapses or if an unexpected failure occurs. The valid values are CONTINUE and ABANDON. The default value is CONTINUE.
Returns:
A reference to this updated object so that method calls can be chained together.
    public LifecycleHook withDefaultResult(String defaultResult) {
        this. = defaultResult;
        return this;
    }

    
Returns a string representation of this object; useful for testing and debugging.

Returns:
A string representation of this object.
See also:
java.lang.Object.toString()
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        if (getLifecycleHookName() != nullsb.append("LifecycleHookName: " + getLifecycleHookName() + ",");
        if (getAutoScalingGroupName() != nullsb.append("AutoScalingGroupName: " + getAutoScalingGroupName() + ",");
        if (getLifecycleTransition() != nullsb.append("LifecycleTransition: " + getLifecycleTransition() + ",");
        if (getNotificationTargetARN() != nullsb.append("NotificationTargetARN: " + getNotificationTargetARN() + ",");
        if (getRoleARN() != nullsb.append("RoleARN: " + getRoleARN() + ",");
        if (getNotificationMetadata() != nullsb.append("NotificationMetadata: " + getNotificationMetadata() + ",");
        if (getHeartbeatTimeout() != nullsb.append("HeartbeatTimeout: " + getHeartbeatTimeout() + ",");
        if (getGlobalTimeout() != nullsb.append("GlobalTimeout: " + getGlobalTimeout() + ",");
        if (getDefaultResult() != nullsb.append("DefaultResult: " + getDefaultResult() );
        sb.append("}");
        return sb.toString();
    }
    
    @Override
    public int hashCode() {
        final int prime = 31;
        int hashCode = 1;
        
        hashCode = prime * hashCode + ((getLifecycleHookName() == null) ? 0 : getLifecycleHookName().hashCode()); 
        hashCode = prime * hashCode + ((getAutoScalingGroupName() == null) ? 0 : getAutoScalingGroupName().hashCode()); 
        hashCode = prime * hashCode + ((getLifecycleTransition() == null) ? 0 : getLifecycleTransition().hashCode()); 
        hashCode = prime * hashCode + ((getNotificationTargetARN() == null) ? 0 : getNotificationTargetARN().hashCode()); 
        hashCode = prime * hashCode + ((getRoleARN() == null) ? 0 : getRoleARN().hashCode()); 
        hashCode = prime * hashCode + ((getNotificationMetadata() == null) ? 0 : getNotificationMetadata().hashCode()); 
        hashCode = prime * hashCode + ((getHeartbeatTimeout() == null) ? 0 : getHeartbeatTimeout().hashCode()); 
        hashCode = prime * hashCode + ((getGlobalTimeout() == null) ? 0 : getGlobalTimeout().hashCode()); 
        hashCode = prime * hashCode + ((getDefaultResult() == null) ? 0 : getDefaultResult().hashCode()); 
        return hashCode;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == objreturn true;
        if (obj == nullreturn false;
        if (obj instanceof LifecycleHook == falsereturn false;
        LifecycleHook other = (LifecycleHook)obj;
        
        if (other.getLifecycleHookName() == null ^ this.getLifecycleHookName() == nullreturn false;
        if (other.getLifecycleHookName() != null && other.getLifecycleHookName().equals(this.getLifecycleHookName()) == falsereturn false
        if (other.getAutoScalingGroupName() == null ^ this.getAutoScalingGroupName() == nullreturn false;
        if (other.getAutoScalingGroupName() != null && other.getAutoScalingGroupName().equals(this.getAutoScalingGroupName()) == falsereturn false
        if (other.getLifecycleTransition() == null ^ this.getLifecycleTransition() == nullreturn false;
        if (other.getLifecycleTransition() != null && other.getLifecycleTransition().equals(this.getLifecycleTransition()) == falsereturn false
        if (other.getNotificationTargetARN() == null ^ this.getNotificationTargetARN() == nullreturn false;
        if (other.getNotificationTargetARN() != null && other.getNotificationTargetARN().equals(this.getNotificationTargetARN()) == falsereturn false
        if (other.getRoleARN() == null ^ this.getRoleARN() == nullreturn false;
        if (other.getRoleARN() != null && other.getRoleARN().equals(this.getRoleARN()) == falsereturn false
        if (other.getNotificationMetadata() == null ^ this.getNotificationMetadata() == nullreturn false;
        if (other.getNotificationMetadata() != null && other.getNotificationMetadata().equals(this.getNotificationMetadata()) == falsereturn false
        if (other.getHeartbeatTimeout() == null ^ this.getHeartbeatTimeout() == nullreturn false;
        if (other.getHeartbeatTimeout() != null && other.getHeartbeatTimeout().equals(this.getHeartbeatTimeout()) == falsereturn false
        if (other.getGlobalTimeout() == null ^ this.getGlobalTimeout() == nullreturn false;
        if (other.getGlobalTimeout() != null && other.getGlobalTimeout().equals(this.getGlobalTimeout()) == falsereturn false
        if (other.getDefaultResult() == null ^ this.getDefaultResult() == nullreturn false;
        if (other.getDefaultResult() != null && other.getDefaultResult().equals(this.getDefaultResult()) == falsereturn false
        return true;
    }
    
    @Override
    public LifecycleHook clone() {
        try {
            return (LifecycleHooksuper.clone();
        
        } catch (CloneNotSupportedException e) {
            throw new IllegalStateException(
                    "Got a CloneNotSupportedException from Object.clone() "
                    + "even though we're Cloneable!",
                    e);
        }
        
    }
}
    
New to GrepCode? Check out our FAQ X