{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.AutoScaling.PutLifecycleHook
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates or updates a lifecycle hook for the specified Auto Scaling
-- group.
--
-- A lifecycle hook tells Amazon EC2 Auto Scaling to perform an action on
-- an instance when the instance launches (before it is put into service)
-- or as the instance terminates (before it is fully terminated).
--
-- This step is a part of the procedure for adding a lifecycle hook to an
-- Auto Scaling group:
--
-- 1.  (Optional) Create a Lambda function and a rule that allows
--     CloudWatch Events to invoke your Lambda function when Amazon EC2
--     Auto Scaling launches or terminates instances.
--
-- 2.  (Optional) Create a notification target and an IAM role. The target
--     can be either an Amazon SQS queue or an Amazon SNS topic. The role
--     allows Amazon EC2 Auto Scaling to publish lifecycle notifications to
--     the target.
--
-- 3.  __Create the lifecycle hook. Specify whether the hook is used when
--     the instances launch or terminate.__
--
-- 4.  If you need more time, record the lifecycle action heartbeat to keep
--     the instance in a pending state using the
--     RecordLifecycleActionHeartbeat API call.
--
-- 5.  If you finish before the timeout period ends, complete the lifecycle
--     action using the CompleteLifecycleAction API call.
--
-- For more information, see
-- <https://docs.aws.amazon.com/autoscaling/ec2/userguide/lifecycle-hooks.html Amazon EC2 Auto Scaling lifecycle hooks>
-- in the /Amazon EC2 Auto Scaling User Guide/.
--
-- If you exceed your maximum limit of lifecycle hooks, which by default is
-- 50 per Auto Scaling group, the call fails.
--
-- You can view the lifecycle hooks for an Auto Scaling group using the
-- DescribeLifecycleHooks API call. If you are no longer using a lifecycle
-- hook, you can delete it by calling the DeleteLifecycleHook API.
module Amazonka.AutoScaling.PutLifecycleHook
  ( -- * Creating a Request
    PutLifecycleHook (..),
    newPutLifecycleHook,

    -- * Request Lenses
    putLifecycleHook_defaultResult,
    putLifecycleHook_heartbeatTimeout,
    putLifecycleHook_notificationMetadata,
    putLifecycleHook_notificationTargetARN,
    putLifecycleHook_lifecycleTransition,
    putLifecycleHook_roleARN,
    putLifecycleHook_lifecycleHookName,
    putLifecycleHook_autoScalingGroupName,

    -- * Destructuring the Response
    PutLifecycleHookResponse (..),
    newPutLifecycleHookResponse,

    -- * Response Lenses
    putLifecycleHookResponse_httpStatus,
  )
where

import Amazonka.AutoScaling.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newPutLifecycleHook' smart constructor.
data PutLifecycleHook = PutLifecycleHook'
  { -- | Defines the action the Auto Scaling group should take when the lifecycle
    -- hook timeout elapses or if an unexpected failure occurs. This parameter
    -- can be either @CONTINUE@ or @ABANDON@. The default value is @ABANDON@.
    PutLifecycleHook -> Maybe Text
defaultResult :: Prelude.Maybe Prelude.Text,
    -- | The maximum time, in seconds, that can elapse before the lifecycle hook
    -- times out. The range is from @30@ to @7200@ seconds. The default value
    -- is @3600@ seconds (1 hour).
    --
    -- If the lifecycle hook times out, Amazon EC2 Auto Scaling performs the
    -- action that you specified in the @DefaultResult@ parameter. You can
    -- prevent the lifecycle hook from timing out by calling the
    -- RecordLifecycleActionHeartbeat API.
    PutLifecycleHook -> Maybe Int
heartbeatTimeout :: Prelude.Maybe Prelude.Int,
    -- | Additional information that you want to include any time Amazon EC2 Auto
    -- Scaling sends a message to the notification target.
    PutLifecycleHook -> Maybe Text
notificationMetadata :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the notification target that Amazon EC2 Auto Scaling uses to
    -- notify you when an instance is in the transition state for the lifecycle
    -- hook. This target can be either an SQS queue or an SNS topic.
    --
    -- If you specify an empty string, this overrides the current ARN.
    --
    -- This operation uses the JSON format when sending notifications to an
    -- Amazon SQS queue, and an email key-value pair format when sending
    -- notifications to an Amazon SNS topic.
    --
    -- When you specify a notification target, Amazon EC2 Auto Scaling sends it
    -- a test message. Test messages contain the following additional key-value
    -- pair: @\"Event\": \"autoscaling:TEST_NOTIFICATION\"@.
    PutLifecycleHook -> Maybe Text
notificationTargetARN :: Prelude.Maybe Prelude.Text,
    -- | The instance state to which you want to attach the lifecycle hook. The
    -- valid values are:
    --
    -- -   autoscaling:EC2_INSTANCE_LAUNCHING
    --
    -- -   autoscaling:EC2_INSTANCE_TERMINATING
    --
    -- Required for new lifecycle hooks, but optional when updating existing
    -- hooks.
    PutLifecycleHook -> Maybe Text
lifecycleTransition :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the IAM role that allows the Auto Scaling group to publish to
    -- the specified notification target, for example, an Amazon SNS topic or
    -- an Amazon SQS queue.
    --
    -- Required for new lifecycle hooks, but optional when updating existing
    -- hooks.
    PutLifecycleHook -> Maybe Text
roleARN :: Prelude.Maybe Prelude.Text,
    -- | The name of the lifecycle hook.
    PutLifecycleHook -> Text
lifecycleHookName :: Prelude.Text,
    -- | The name of the Auto Scaling group.
    PutLifecycleHook -> Text
autoScalingGroupName :: Prelude.Text
  }
  deriving (PutLifecycleHook -> PutLifecycleHook -> Bool
(PutLifecycleHook -> PutLifecycleHook -> Bool)
-> (PutLifecycleHook -> PutLifecycleHook -> Bool)
-> Eq PutLifecycleHook
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutLifecycleHook -> PutLifecycleHook -> Bool
$c/= :: PutLifecycleHook -> PutLifecycleHook -> Bool
== :: PutLifecycleHook -> PutLifecycleHook -> Bool
$c== :: PutLifecycleHook -> PutLifecycleHook -> Bool
Prelude.Eq, ReadPrec [PutLifecycleHook]
ReadPrec PutLifecycleHook
Int -> ReadS PutLifecycleHook
ReadS [PutLifecycleHook]
(Int -> ReadS PutLifecycleHook)
-> ReadS [PutLifecycleHook]
-> ReadPrec PutLifecycleHook
-> ReadPrec [PutLifecycleHook]
-> Read PutLifecycleHook
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutLifecycleHook]
$creadListPrec :: ReadPrec [PutLifecycleHook]
readPrec :: ReadPrec PutLifecycleHook
$creadPrec :: ReadPrec PutLifecycleHook
readList :: ReadS [PutLifecycleHook]
$creadList :: ReadS [PutLifecycleHook]
readsPrec :: Int -> ReadS PutLifecycleHook
$creadsPrec :: Int -> ReadS PutLifecycleHook
Prelude.Read, Int -> PutLifecycleHook -> ShowS
[PutLifecycleHook] -> ShowS
PutLifecycleHook -> String
(Int -> PutLifecycleHook -> ShowS)
-> (PutLifecycleHook -> String)
-> ([PutLifecycleHook] -> ShowS)
-> Show PutLifecycleHook
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutLifecycleHook] -> ShowS
$cshowList :: [PutLifecycleHook] -> ShowS
show :: PutLifecycleHook -> String
$cshow :: PutLifecycleHook -> String
showsPrec :: Int -> PutLifecycleHook -> ShowS
$cshowsPrec :: Int -> PutLifecycleHook -> ShowS
Prelude.Show, (forall x. PutLifecycleHook -> Rep PutLifecycleHook x)
-> (forall x. Rep PutLifecycleHook x -> PutLifecycleHook)
-> Generic PutLifecycleHook
forall x. Rep PutLifecycleHook x -> PutLifecycleHook
forall x. PutLifecycleHook -> Rep PutLifecycleHook x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutLifecycleHook x -> PutLifecycleHook
$cfrom :: forall x. PutLifecycleHook -> Rep PutLifecycleHook x
Prelude.Generic)

-- |
-- Create a value of 'PutLifecycleHook' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'defaultResult', 'putLifecycleHook_defaultResult' - Defines the action the Auto Scaling group should take when the lifecycle
-- hook timeout elapses or if an unexpected failure occurs. This parameter
-- can be either @CONTINUE@ or @ABANDON@. The default value is @ABANDON@.
--
-- 'heartbeatTimeout', 'putLifecycleHook_heartbeatTimeout' - The maximum time, in seconds, that can elapse before the lifecycle hook
-- times out. The range is from @30@ to @7200@ seconds. The default value
-- is @3600@ seconds (1 hour).
--
-- If the lifecycle hook times out, Amazon EC2 Auto Scaling performs the
-- action that you specified in the @DefaultResult@ parameter. You can
-- prevent the lifecycle hook from timing out by calling the
-- RecordLifecycleActionHeartbeat API.
--
-- 'notificationMetadata', 'putLifecycleHook_notificationMetadata' - Additional information that you want to include any time Amazon EC2 Auto
-- Scaling sends a message to the notification target.
--
-- 'notificationTargetARN', 'putLifecycleHook_notificationTargetARN' - The ARN of the notification target that Amazon EC2 Auto Scaling uses to
-- notify you when an instance is in the transition state for the lifecycle
-- hook. This target can be either an SQS queue or an SNS topic.
--
-- If you specify an empty string, this overrides the current ARN.
--
-- This operation uses the JSON format when sending notifications to an
-- Amazon SQS queue, and an email key-value pair format when sending
-- notifications to an Amazon SNS topic.
--
-- When you specify a notification target, Amazon EC2 Auto Scaling sends it
-- a test message. Test messages contain the following additional key-value
-- pair: @\"Event\": \"autoscaling:TEST_NOTIFICATION\"@.
--
-- 'lifecycleTransition', 'putLifecycleHook_lifecycleTransition' - The instance state to which you want to attach the lifecycle hook. The
-- valid values are:
--
-- -   autoscaling:EC2_INSTANCE_LAUNCHING
--
-- -   autoscaling:EC2_INSTANCE_TERMINATING
--
-- Required for new lifecycle hooks, but optional when updating existing
-- hooks.
--
-- 'roleARN', 'putLifecycleHook_roleARN' - The ARN of the IAM role that allows the Auto Scaling group to publish to
-- the specified notification target, for example, an Amazon SNS topic or
-- an Amazon SQS queue.
--
-- Required for new lifecycle hooks, but optional when updating existing
-- hooks.
--
-- 'lifecycleHookName', 'putLifecycleHook_lifecycleHookName' - The name of the lifecycle hook.
--
-- 'autoScalingGroupName', 'putLifecycleHook_autoScalingGroupName' - The name of the Auto Scaling group.
newPutLifecycleHook ::
  -- | 'lifecycleHookName'
  Prelude.Text ->
  -- | 'autoScalingGroupName'
  Prelude.Text ->
  PutLifecycleHook
newPutLifecycleHook :: Text -> Text -> PutLifecycleHook
newPutLifecycleHook
  Text
pLifecycleHookName_
  Text
pAutoScalingGroupName_ =
    PutLifecycleHook' :: Maybe Text
-> Maybe Int
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Text
-> Text
-> PutLifecycleHook
PutLifecycleHook'
      { $sel:defaultResult:PutLifecycleHook' :: Maybe Text
defaultResult = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:heartbeatTimeout:PutLifecycleHook' :: Maybe Int
heartbeatTimeout = Maybe Int
forall a. Maybe a
Prelude.Nothing,
        $sel:notificationMetadata:PutLifecycleHook' :: Maybe Text
notificationMetadata = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:notificationTargetARN:PutLifecycleHook' :: Maybe Text
notificationTargetARN = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:lifecycleTransition:PutLifecycleHook' :: Maybe Text
lifecycleTransition = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:roleARN:PutLifecycleHook' :: Maybe Text
roleARN = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:lifecycleHookName:PutLifecycleHook' :: Text
lifecycleHookName = Text
pLifecycleHookName_,
        $sel:autoScalingGroupName:PutLifecycleHook' :: Text
autoScalingGroupName = Text
pAutoScalingGroupName_
      }

-- | Defines the action the Auto Scaling group should take when the lifecycle
-- hook timeout elapses or if an unexpected failure occurs. This parameter
-- can be either @CONTINUE@ or @ABANDON@. The default value is @ABANDON@.
putLifecycleHook_defaultResult :: Lens.Lens' PutLifecycleHook (Prelude.Maybe Prelude.Text)
putLifecycleHook_defaultResult :: (Maybe Text -> f (Maybe Text))
-> PutLifecycleHook -> f PutLifecycleHook
putLifecycleHook_defaultResult = (PutLifecycleHook -> Maybe Text)
-> (PutLifecycleHook -> Maybe Text -> PutLifecycleHook)
-> Lens PutLifecycleHook PutLifecycleHook (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutLifecycleHook' {Maybe Text
defaultResult :: Maybe Text
$sel:defaultResult:PutLifecycleHook' :: PutLifecycleHook -> Maybe Text
defaultResult} -> Maybe Text
defaultResult) (\s :: PutLifecycleHook
s@PutLifecycleHook' {} Maybe Text
a -> PutLifecycleHook
s {$sel:defaultResult:PutLifecycleHook' :: Maybe Text
defaultResult = Maybe Text
a} :: PutLifecycleHook)

-- | The maximum time, in seconds, that can elapse before the lifecycle hook
-- times out. The range is from @30@ to @7200@ seconds. The default value
-- is @3600@ seconds (1 hour).
--
-- If the lifecycle hook times out, Amazon EC2 Auto Scaling performs the
-- action that you specified in the @DefaultResult@ parameter. You can
-- prevent the lifecycle hook from timing out by calling the
-- RecordLifecycleActionHeartbeat API.
putLifecycleHook_heartbeatTimeout :: Lens.Lens' PutLifecycleHook (Prelude.Maybe Prelude.Int)
putLifecycleHook_heartbeatTimeout :: (Maybe Int -> f (Maybe Int))
-> PutLifecycleHook -> f PutLifecycleHook
putLifecycleHook_heartbeatTimeout = (PutLifecycleHook -> Maybe Int)
-> (PutLifecycleHook -> Maybe Int -> PutLifecycleHook)
-> Lens PutLifecycleHook PutLifecycleHook (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutLifecycleHook' {Maybe Int
heartbeatTimeout :: Maybe Int
$sel:heartbeatTimeout:PutLifecycleHook' :: PutLifecycleHook -> Maybe Int
heartbeatTimeout} -> Maybe Int
heartbeatTimeout) (\s :: PutLifecycleHook
s@PutLifecycleHook' {} Maybe Int
a -> PutLifecycleHook
s {$sel:heartbeatTimeout:PutLifecycleHook' :: Maybe Int
heartbeatTimeout = Maybe Int
a} :: PutLifecycleHook)

-- | Additional information that you want to include any time Amazon EC2 Auto
-- Scaling sends a message to the notification target.
putLifecycleHook_notificationMetadata :: Lens.Lens' PutLifecycleHook (Prelude.Maybe Prelude.Text)
putLifecycleHook_notificationMetadata :: (Maybe Text -> f (Maybe Text))
-> PutLifecycleHook -> f PutLifecycleHook
putLifecycleHook_notificationMetadata = (PutLifecycleHook -> Maybe Text)
-> (PutLifecycleHook -> Maybe Text -> PutLifecycleHook)
-> Lens PutLifecycleHook PutLifecycleHook (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutLifecycleHook' {Maybe Text
notificationMetadata :: Maybe Text
$sel:notificationMetadata:PutLifecycleHook' :: PutLifecycleHook -> Maybe Text
notificationMetadata} -> Maybe Text
notificationMetadata) (\s :: PutLifecycleHook
s@PutLifecycleHook' {} Maybe Text
a -> PutLifecycleHook
s {$sel:notificationMetadata:PutLifecycleHook' :: Maybe Text
notificationMetadata = Maybe Text
a} :: PutLifecycleHook)

-- | The ARN of the notification target that Amazon EC2 Auto Scaling uses to
-- notify you when an instance is in the transition state for the lifecycle
-- hook. This target can be either an SQS queue or an SNS topic.
--
-- If you specify an empty string, this overrides the current ARN.
--
-- This operation uses the JSON format when sending notifications to an
-- Amazon SQS queue, and an email key-value pair format when sending
-- notifications to an Amazon SNS topic.
--
-- When you specify a notification target, Amazon EC2 Auto Scaling sends it
-- a test message. Test messages contain the following additional key-value
-- pair: @\"Event\": \"autoscaling:TEST_NOTIFICATION\"@.
putLifecycleHook_notificationTargetARN :: Lens.Lens' PutLifecycleHook (Prelude.Maybe Prelude.Text)
putLifecycleHook_notificationTargetARN :: (Maybe Text -> f (Maybe Text))
-> PutLifecycleHook -> f PutLifecycleHook
putLifecycleHook_notificationTargetARN = (PutLifecycleHook -> Maybe Text)
-> (PutLifecycleHook -> Maybe Text -> PutLifecycleHook)
-> Lens PutLifecycleHook PutLifecycleHook (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutLifecycleHook' {Maybe Text
notificationTargetARN :: Maybe Text
$sel:notificationTargetARN:PutLifecycleHook' :: PutLifecycleHook -> Maybe Text
notificationTargetARN} -> Maybe Text
notificationTargetARN) (\s :: PutLifecycleHook
s@PutLifecycleHook' {} Maybe Text
a -> PutLifecycleHook
s {$sel:notificationTargetARN:PutLifecycleHook' :: Maybe Text
notificationTargetARN = Maybe Text
a} :: PutLifecycleHook)

-- | The instance state to which you want to attach the lifecycle hook. The
-- valid values are:
--
-- -   autoscaling:EC2_INSTANCE_LAUNCHING
--
-- -   autoscaling:EC2_INSTANCE_TERMINATING
--
-- Required for new lifecycle hooks, but optional when updating existing
-- hooks.
putLifecycleHook_lifecycleTransition :: Lens.Lens' PutLifecycleHook (Prelude.Maybe Prelude.Text)
putLifecycleHook_lifecycleTransition :: (Maybe Text -> f (Maybe Text))
-> PutLifecycleHook -> f PutLifecycleHook
putLifecycleHook_lifecycleTransition = (PutLifecycleHook -> Maybe Text)
-> (PutLifecycleHook -> Maybe Text -> PutLifecycleHook)
-> Lens PutLifecycleHook PutLifecycleHook (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutLifecycleHook' {Maybe Text
lifecycleTransition :: Maybe Text
$sel:lifecycleTransition:PutLifecycleHook' :: PutLifecycleHook -> Maybe Text
lifecycleTransition} -> Maybe Text
lifecycleTransition) (\s :: PutLifecycleHook
s@PutLifecycleHook' {} Maybe Text
a -> PutLifecycleHook
s {$sel:lifecycleTransition:PutLifecycleHook' :: Maybe Text
lifecycleTransition = Maybe Text
a} :: PutLifecycleHook)

-- | The ARN of the IAM role that allows the Auto Scaling group to publish to
-- the specified notification target, for example, an Amazon SNS topic or
-- an Amazon SQS queue.
--
-- Required for new lifecycle hooks, but optional when updating existing
-- hooks.
putLifecycleHook_roleARN :: Lens.Lens' PutLifecycleHook (Prelude.Maybe Prelude.Text)
putLifecycleHook_roleARN :: (Maybe Text -> f (Maybe Text))
-> PutLifecycleHook -> f PutLifecycleHook
putLifecycleHook_roleARN = (PutLifecycleHook -> Maybe Text)
-> (PutLifecycleHook -> Maybe Text -> PutLifecycleHook)
-> Lens PutLifecycleHook PutLifecycleHook (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutLifecycleHook' {Maybe Text
roleARN :: Maybe Text
$sel:roleARN:PutLifecycleHook' :: PutLifecycleHook -> Maybe Text
roleARN} -> Maybe Text
roleARN) (\s :: PutLifecycleHook
s@PutLifecycleHook' {} Maybe Text
a -> PutLifecycleHook
s {$sel:roleARN:PutLifecycleHook' :: Maybe Text
roleARN = Maybe Text
a} :: PutLifecycleHook)

-- | The name of the lifecycle hook.
putLifecycleHook_lifecycleHookName :: Lens.Lens' PutLifecycleHook Prelude.Text
putLifecycleHook_lifecycleHookName :: (Text -> f Text) -> PutLifecycleHook -> f PutLifecycleHook
putLifecycleHook_lifecycleHookName = (PutLifecycleHook -> Text)
-> (PutLifecycleHook -> Text -> PutLifecycleHook)
-> Lens PutLifecycleHook PutLifecycleHook Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutLifecycleHook' {Text
lifecycleHookName :: Text
$sel:lifecycleHookName:PutLifecycleHook' :: PutLifecycleHook -> Text
lifecycleHookName} -> Text
lifecycleHookName) (\s :: PutLifecycleHook
s@PutLifecycleHook' {} Text
a -> PutLifecycleHook
s {$sel:lifecycleHookName:PutLifecycleHook' :: Text
lifecycleHookName = Text
a} :: PutLifecycleHook)

-- | The name of the Auto Scaling group.
putLifecycleHook_autoScalingGroupName :: Lens.Lens' PutLifecycleHook Prelude.Text
putLifecycleHook_autoScalingGroupName :: (Text -> f Text) -> PutLifecycleHook -> f PutLifecycleHook
putLifecycleHook_autoScalingGroupName = (PutLifecycleHook -> Text)
-> (PutLifecycleHook -> Text -> PutLifecycleHook)
-> Lens PutLifecycleHook PutLifecycleHook Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutLifecycleHook' {Text
autoScalingGroupName :: Text
$sel:autoScalingGroupName:PutLifecycleHook' :: PutLifecycleHook -> Text
autoScalingGroupName} -> Text
autoScalingGroupName) (\s :: PutLifecycleHook
s@PutLifecycleHook' {} Text
a -> PutLifecycleHook
s {$sel:autoScalingGroupName:PutLifecycleHook' :: Text
autoScalingGroupName = Text
a} :: PutLifecycleHook)

instance Core.AWSRequest PutLifecycleHook where
  type
    AWSResponse PutLifecycleHook =
      PutLifecycleHookResponse
  request :: PutLifecycleHook -> Request PutLifecycleHook
request = Service -> PutLifecycleHook -> Request PutLifecycleHook
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy PutLifecycleHook
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutLifecycleHook)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse PutLifecycleHook))
-> Logger
-> Service
-> Proxy PutLifecycleHook
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutLifecycleHook)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"PutLifecycleHookResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> PutLifecycleHookResponse
PutLifecycleHookResponse'
            (Int -> PutLifecycleHookResponse)
-> Either String Int -> Either String PutLifecycleHookResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable PutLifecycleHook

instance Prelude.NFData PutLifecycleHook

instance Core.ToHeaders PutLifecycleHook where
  toHeaders :: PutLifecycleHook -> ResponseHeaders
toHeaders = ResponseHeaders -> PutLifecycleHook -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath PutLifecycleHook where
  toPath :: PutLifecycleHook -> ByteString
toPath = ByteString -> PutLifecycleHook -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery PutLifecycleHook where
  toQuery :: PutLifecycleHook -> QueryString
toQuery PutLifecycleHook' {Maybe Int
Maybe Text
Text
autoScalingGroupName :: Text
lifecycleHookName :: Text
roleARN :: Maybe Text
lifecycleTransition :: Maybe Text
notificationTargetARN :: Maybe Text
notificationMetadata :: Maybe Text
heartbeatTimeout :: Maybe Int
defaultResult :: Maybe Text
$sel:autoScalingGroupName:PutLifecycleHook' :: PutLifecycleHook -> Text
$sel:lifecycleHookName:PutLifecycleHook' :: PutLifecycleHook -> Text
$sel:roleARN:PutLifecycleHook' :: PutLifecycleHook -> Maybe Text
$sel:lifecycleTransition:PutLifecycleHook' :: PutLifecycleHook -> Maybe Text
$sel:notificationTargetARN:PutLifecycleHook' :: PutLifecycleHook -> Maybe Text
$sel:notificationMetadata:PutLifecycleHook' :: PutLifecycleHook -> Maybe Text
$sel:heartbeatTimeout:PutLifecycleHook' :: PutLifecycleHook -> Maybe Int
$sel:defaultResult:PutLifecycleHook' :: PutLifecycleHook -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"PutLifecycleHook" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2011-01-01" :: Prelude.ByteString),
        ByteString
"DefaultResult" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
defaultResult,
        ByteString
"HeartbeatTimeout" ByteString -> Maybe Int -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Int
heartbeatTimeout,
        ByteString
"NotificationMetadata" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
notificationMetadata,
        ByteString
"NotificationTargetARN"
          ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
notificationTargetARN,
        ByteString
"LifecycleTransition" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
lifecycleTransition,
        ByteString
"RoleARN" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
roleARN,
        ByteString
"LifecycleHookName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
lifecycleHookName,
        ByteString
"AutoScalingGroupName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
autoScalingGroupName
      ]

-- | /See:/ 'newPutLifecycleHookResponse' smart constructor.
data PutLifecycleHookResponse = PutLifecycleHookResponse'
  { -- | The response's http status code.
    PutLifecycleHookResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (PutLifecycleHookResponse -> PutLifecycleHookResponse -> Bool
(PutLifecycleHookResponse -> PutLifecycleHookResponse -> Bool)
-> (PutLifecycleHookResponse -> PutLifecycleHookResponse -> Bool)
-> Eq PutLifecycleHookResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutLifecycleHookResponse -> PutLifecycleHookResponse -> Bool
$c/= :: PutLifecycleHookResponse -> PutLifecycleHookResponse -> Bool
== :: PutLifecycleHookResponse -> PutLifecycleHookResponse -> Bool
$c== :: PutLifecycleHookResponse -> PutLifecycleHookResponse -> Bool
Prelude.Eq, ReadPrec [PutLifecycleHookResponse]
ReadPrec PutLifecycleHookResponse
Int -> ReadS PutLifecycleHookResponse
ReadS [PutLifecycleHookResponse]
(Int -> ReadS PutLifecycleHookResponse)
-> ReadS [PutLifecycleHookResponse]
-> ReadPrec PutLifecycleHookResponse
-> ReadPrec [PutLifecycleHookResponse]
-> Read PutLifecycleHookResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutLifecycleHookResponse]
$creadListPrec :: ReadPrec [PutLifecycleHookResponse]
readPrec :: ReadPrec PutLifecycleHookResponse
$creadPrec :: ReadPrec PutLifecycleHookResponse
readList :: ReadS [PutLifecycleHookResponse]
$creadList :: ReadS [PutLifecycleHookResponse]
readsPrec :: Int -> ReadS PutLifecycleHookResponse
$creadsPrec :: Int -> ReadS PutLifecycleHookResponse
Prelude.Read, Int -> PutLifecycleHookResponse -> ShowS
[PutLifecycleHookResponse] -> ShowS
PutLifecycleHookResponse -> String
(Int -> PutLifecycleHookResponse -> ShowS)
-> (PutLifecycleHookResponse -> String)
-> ([PutLifecycleHookResponse] -> ShowS)
-> Show PutLifecycleHookResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutLifecycleHookResponse] -> ShowS
$cshowList :: [PutLifecycleHookResponse] -> ShowS
show :: PutLifecycleHookResponse -> String
$cshow :: PutLifecycleHookResponse -> String
showsPrec :: Int -> PutLifecycleHookResponse -> ShowS
$cshowsPrec :: Int -> PutLifecycleHookResponse -> ShowS
Prelude.Show, (forall x.
 PutLifecycleHookResponse -> Rep PutLifecycleHookResponse x)
-> (forall x.
    Rep PutLifecycleHookResponse x -> PutLifecycleHookResponse)
-> Generic PutLifecycleHookResponse
forall x.
Rep PutLifecycleHookResponse x -> PutLifecycleHookResponse
forall x.
PutLifecycleHookResponse -> Rep PutLifecycleHookResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutLifecycleHookResponse x -> PutLifecycleHookResponse
$cfrom :: forall x.
PutLifecycleHookResponse -> Rep PutLifecycleHookResponse x
Prelude.Generic)

-- |
-- Create a value of 'PutLifecycleHookResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'httpStatus', 'putLifecycleHookResponse_httpStatus' - The response's http status code.
newPutLifecycleHookResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  PutLifecycleHookResponse
newPutLifecycleHookResponse :: Int -> PutLifecycleHookResponse
newPutLifecycleHookResponse Int
pHttpStatus_ =
  PutLifecycleHookResponse' :: Int -> PutLifecycleHookResponse
PutLifecycleHookResponse'
    { $sel:httpStatus:PutLifecycleHookResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
putLifecycleHookResponse_httpStatus :: Lens.Lens' PutLifecycleHookResponse Prelude.Int
putLifecycleHookResponse_httpStatus :: (Int -> f Int)
-> PutLifecycleHookResponse -> f PutLifecycleHookResponse
putLifecycleHookResponse_httpStatus = (PutLifecycleHookResponse -> Int)
-> (PutLifecycleHookResponse -> Int -> PutLifecycleHookResponse)
-> Lens PutLifecycleHookResponse PutLifecycleHookResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutLifecycleHookResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutLifecycleHookResponse' :: PutLifecycleHookResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: PutLifecycleHookResponse
s@PutLifecycleHookResponse' {} Int
a -> PutLifecycleHookResponse
s {$sel:httpStatus:PutLifecycleHookResponse' :: Int
httpStatus = Int
a} :: PutLifecycleHookResponse)

instance Prelude.NFData PutLifecycleHookResponse