{-# 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-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)
--
-- 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.Lens as Lens
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
(DeleteLifecycleHook -> DeleteLifecycleHook -> Bool)
-> (DeleteLifecycleHook -> DeleteLifecycleHook -> Bool)
-> Eq DeleteLifecycleHook
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]
(Int -> ReadS DeleteLifecycleHook)
-> ReadS [DeleteLifecycleHook]
-> ReadPrec DeleteLifecycleHook
-> ReadPrec [DeleteLifecycleHook]
-> Read 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
(Int -> DeleteLifecycleHook -> ShowS)
-> (DeleteLifecycleHook -> String)
-> ([DeleteLifecycleHook] -> ShowS)
-> Show DeleteLifecycleHook
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. DeleteLifecycleHook -> Rep DeleteLifecycleHook x)
-> (forall x. Rep DeleteLifecycleHook x -> DeleteLifecycleHook)
-> Generic DeleteLifecycleHook
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' :: Text -> Text -> DeleteLifecycleHook
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 :: (Text -> f Text) -> DeleteLifecycleHook -> f DeleteLifecycleHook
deleteLifecycleHook_lifecycleHookName = (DeleteLifecycleHook -> Text)
-> (DeleteLifecycleHook -> Text -> DeleteLifecycleHook)
-> Lens DeleteLifecycleHook DeleteLifecycleHook Text Text
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 :: (Text -> f Text) -> DeleteLifecycleHook -> f DeleteLifecycleHook
deleteLifecycleHook_autoScalingGroupName = (DeleteLifecycleHook -> Text)
-> (DeleteLifecycleHook -> Text -> DeleteLifecycleHook)
-> Lens DeleteLifecycleHook DeleteLifecycleHook Text Text
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 :: DeleteLifecycleHook -> Request DeleteLifecycleHook
request = Service -> DeleteLifecycleHook -> Request DeleteLifecycleHook
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteLifecycleHook
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteLifecycleHook)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse DeleteLifecycleHook))
-> Logger
-> Service
-> Proxy DeleteLifecycleHook
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteLifecycleHook)))
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
"DeleteLifecycleHookResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> DeleteLifecycleHookResponse
DeleteLifecycleHookResponse'
            (Int -> DeleteLifecycleHookResponse)
-> Either String Int -> Either String DeleteLifecycleHookResponse
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 DeleteLifecycleHook

instance Prelude.NFData DeleteLifecycleHook

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

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

instance Core.ToQuery DeleteLifecycleHook where
  toQuery :: DeleteLifecycleHook -> QueryString
toQuery DeleteLifecycleHook' {Text
autoScalingGroupName :: Text
lifecycleHookName :: Text
$sel:autoScalingGroupName:DeleteLifecycleHook' :: DeleteLifecycleHook -> Text
$sel:lifecycleHookName:DeleteLifecycleHook' :: DeleteLifecycleHook -> 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
"DeleteLifecycleHook" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2011-01-01" :: Prelude.ByteString),
        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:/ 'newDeleteLifecycleHookResponse' smart constructor.
data DeleteLifecycleHookResponse = DeleteLifecycleHookResponse'
  { -- | The response's http status code.
    DeleteLifecycleHookResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteLifecycleHookResponse -> DeleteLifecycleHookResponse -> Bool
(DeleteLifecycleHookResponse
 -> DeleteLifecycleHookResponse -> Bool)
-> (DeleteLifecycleHookResponse
    -> DeleteLifecycleHookResponse -> Bool)
-> Eq DeleteLifecycleHookResponse
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]
(Int -> ReadS DeleteLifecycleHookResponse)
-> ReadS [DeleteLifecycleHookResponse]
-> ReadPrec DeleteLifecycleHookResponse
-> ReadPrec [DeleteLifecycleHookResponse]
-> Read 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
(Int -> DeleteLifecycleHookResponse -> ShowS)
-> (DeleteLifecycleHookResponse -> String)
-> ([DeleteLifecycleHookResponse] -> ShowS)
-> Show DeleteLifecycleHookResponse
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.
 DeleteLifecycleHookResponse -> Rep DeleteLifecycleHookResponse x)
-> (forall x.
    Rep DeleteLifecycleHookResponse x -> DeleteLifecycleHookResponse)
-> Generic DeleteLifecycleHookResponse
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' :: Int -> DeleteLifecycleHookResponse
DeleteLifecycleHookResponse'
    { $sel:httpStatus:DeleteLifecycleHookResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
deleteLifecycleHookResponse_httpStatus :: Lens.Lens' DeleteLifecycleHookResponse Prelude.Int
deleteLifecycleHookResponse_httpStatus :: (Int -> f Int)
-> DeleteLifecycleHookResponse -> f DeleteLifecycleHookResponse
deleteLifecycleHookResponse_httpStatus = (DeleteLifecycleHookResponse -> Int)
-> (DeleteLifecycleHookResponse
    -> Int -> DeleteLifecycleHookResponse)
-> Lens
     DeleteLifecycleHookResponse DeleteLifecycleHookResponse Int Int
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