{-# 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.DeleteLifecycleHook
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes the specified lifecycle hook.
--
-- If there are any outstanding lifecycle actions, they are completed first
-- (@ABANDON@ for launching instances, @CONTINUE@ for terminating
-- instances).
module Amazonka.AutoScaling.DeleteLifecycleHook
  ( -- * Creating a Request
    DeleteLifecycleHook (..),
    newDeleteLifecycleHook,

    -- * Request Lenses
    deleteLifecycleHook_lifecycleHookName,
    deleteLifecycleHook_autoScalingGroupName,

    -- * Destructuring the Response
    DeleteLifecycleHookResponse (..),
    newDeleteLifecycleHookResponse,

    -- * Response Lenses
    deleteLifecycleHookResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDeleteLifecycleHook' smart constructor.
data DeleteLifecycleHook = DeleteLifecycleHook'
  { -- | The name of the lifecycle hook.
    DeleteLifecycleHook -> Text
lifecycleHookName :: Prelude.Text,
    -- | The name of the Auto Scaling group.
    DeleteLifecycleHook -> Text
autoScalingGroupName :: Prelude.Text
  }
  deriving (DeleteLifecycleHook -> DeleteLifecycleHook -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteLifecycleHook -> DeleteLifecycleHook -> Bool
$c/= :: DeleteLifecycleHook -> DeleteLifecycleHook -> Bool
== :: DeleteLifecycleHook -> DeleteLifecycleHook -> Bool
$c== :: DeleteLifecycleHook -> DeleteLifecycleHook -> Bool
Prelude.Eq, ReadPrec [DeleteLifecycleHook]
ReadPrec DeleteLifecycleHook
Int -> ReadS DeleteLifecycleHook
ReadS [DeleteLifecycleHook]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteLifecycleHook]
$creadListPrec :: ReadPrec [DeleteLifecycleHook]
readPrec :: ReadPrec DeleteLifecycleHook
$creadPrec :: ReadPrec DeleteLifecycleHook
readList :: ReadS [DeleteLifecycleHook]
$creadList :: ReadS [DeleteLifecycleHook]
readsPrec :: Int -> ReadS DeleteLifecycleHook
$creadsPrec :: Int -> ReadS DeleteLifecycleHook
Prelude.Read, Int -> DeleteLifecycleHook -> ShowS
[DeleteLifecycleHook] -> ShowS
DeleteLifecycleHook -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteLifecycleHook] -> ShowS
$cshowList :: [DeleteLifecycleHook] -> ShowS
show :: DeleteLifecycleHook -> String
$cshow :: DeleteLifecycleHook -> String
showsPrec :: Int -> DeleteLifecycleHook -> ShowS
$cshowsPrec :: Int -> DeleteLifecycleHook -> ShowS
Prelude.Show, forall x. Rep DeleteLifecycleHook x -> DeleteLifecycleHook
forall x. DeleteLifecycleHook -> Rep DeleteLifecycleHook x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteLifecycleHook x -> DeleteLifecycleHook
$cfrom :: forall x. DeleteLifecycleHook -> Rep DeleteLifecycleHook x
Prelude.Generic)

-- |
-- Create a value of 'DeleteLifecycleHook' 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:
--
-- 'lifecycleHookName', 'deleteLifecycleHook_lifecycleHookName' - The name of the lifecycle hook.
--
-- 'autoScalingGroupName', 'deleteLifecycleHook_autoScalingGroupName' - The name of the Auto Scaling group.
newDeleteLifecycleHook ::
  -- | 'lifecycleHookName'
  Prelude.Text ->
  -- | 'autoScalingGroupName'
  Prelude.Text ->
  DeleteLifecycleHook
newDeleteLifecycleHook :: Text -> Text -> DeleteLifecycleHook
newDeleteLifecycleHook
  Text
pLifecycleHookName_
  Text
pAutoScalingGroupName_ =
    DeleteLifecycleHook'
      { $sel:lifecycleHookName:DeleteLifecycleHook' :: Text
lifecycleHookName =
          Text
pLifecycleHookName_,
        $sel:autoScalingGroupName:DeleteLifecycleHook' :: Text
autoScalingGroupName = Text
pAutoScalingGroupName_
      }

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

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

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

instance Prelude.Hashable DeleteLifecycleHook where
  hashWithSalt :: Int -> DeleteLifecycleHook -> Int
hashWithSalt Int
_salt DeleteLifecycleHook' {Text
autoScalingGroupName :: Text
lifecycleHookName :: Text
$sel:autoScalingGroupName:DeleteLifecycleHook' :: DeleteLifecycleHook -> Text
$sel:lifecycleHookName:DeleteLifecycleHook' :: DeleteLifecycleHook -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
lifecycleHookName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
autoScalingGroupName

instance Prelude.NFData DeleteLifecycleHook where
  rnf :: DeleteLifecycleHook -> ()
rnf DeleteLifecycleHook' {Text
autoScalingGroupName :: Text
lifecycleHookName :: Text
$sel:autoScalingGroupName:DeleteLifecycleHook' :: DeleteLifecycleHook -> Text
$sel:lifecycleHookName:DeleteLifecycleHook' :: DeleteLifecycleHook -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
lifecycleHookName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
autoScalingGroupName

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

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

instance Data.ToQuery DeleteLifecycleHook where
  toQuery :: DeleteLifecycleHook -> QueryString
toQuery DeleteLifecycleHook' {Text
autoScalingGroupName :: Text
lifecycleHookName :: Text
$sel:autoScalingGroupName:DeleteLifecycleHook' :: DeleteLifecycleHook -> Text
$sel:lifecycleHookName:DeleteLifecycleHook' :: DeleteLifecycleHook -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"DeleteLifecycleHook" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2011-01-01" :: Prelude.ByteString),
        ByteString
"LifecycleHookName" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
lifecycleHookName,
        ByteString
"AutoScalingGroupName" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
autoScalingGroupName
      ]

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

-- |
-- Create a value of 'DeleteLifecycleHookResponse' 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', 'deleteLifecycleHookResponse_httpStatus' - The response's http status code.
newDeleteLifecycleHookResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteLifecycleHookResponse
newDeleteLifecycleHookResponse :: Int -> DeleteLifecycleHookResponse
newDeleteLifecycleHookResponse Int
pHttpStatus_ =
  DeleteLifecycleHookResponse'
    { $sel:httpStatus:DeleteLifecycleHookResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData DeleteLifecycleHookResponse where
  rnf :: DeleteLifecycleHookResponse -> ()
rnf DeleteLifecycleHookResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeleteLifecycleHookResponse' :: DeleteLifecycleHookResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus