{-# 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.CloudFormation.DeleteChangeSet
-- 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 change set. Deleting change sets ensures that no
-- one executes the wrong change set.
--
-- If the call successfully completes, CloudFormation successfully deleted
-- the change set.
--
-- If @IncludeNestedStacks@ specifies @True@ during the creation of the
-- nested change set, then @DeleteChangeSet@ will delete all change sets
-- that belong to the stacks hierarchy and will also delete all change sets
-- for nested stacks with the status of @REVIEW_IN_PROGRESS@.
module Amazonka.CloudFormation.DeleteChangeSet
  ( -- * Creating a Request
    DeleteChangeSet (..),
    newDeleteChangeSet,

    -- * Request Lenses
    deleteChangeSet_stackName,
    deleteChangeSet_changeSetName,

    -- * Destructuring the Response
    DeleteChangeSetResponse (..),
    newDeleteChangeSetResponse,

    -- * Response Lenses
    deleteChangeSetResponse_httpStatus,
  )
where

import Amazonka.CloudFormation.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

-- | The input for the DeleteChangeSet action.
--
-- /See:/ 'newDeleteChangeSet' smart constructor.
data DeleteChangeSet = DeleteChangeSet'
  { -- | If you specified the name of a change set to delete, specify the stack
    -- name or Amazon Resource Name (ARN) that\'s associated with it.
    DeleteChangeSet -> Maybe Text
stackName :: Prelude.Maybe Prelude.Text,
    -- | The name or Amazon Resource Name (ARN) of the change set that you want
    -- to delete.
    DeleteChangeSet -> Text
changeSetName :: Prelude.Text
  }
  deriving (DeleteChangeSet -> DeleteChangeSet -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteChangeSet -> DeleteChangeSet -> Bool
$c/= :: DeleteChangeSet -> DeleteChangeSet -> Bool
== :: DeleteChangeSet -> DeleteChangeSet -> Bool
$c== :: DeleteChangeSet -> DeleteChangeSet -> Bool
Prelude.Eq, ReadPrec [DeleteChangeSet]
ReadPrec DeleteChangeSet
Int -> ReadS DeleteChangeSet
ReadS [DeleteChangeSet]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteChangeSet]
$creadListPrec :: ReadPrec [DeleteChangeSet]
readPrec :: ReadPrec DeleteChangeSet
$creadPrec :: ReadPrec DeleteChangeSet
readList :: ReadS [DeleteChangeSet]
$creadList :: ReadS [DeleteChangeSet]
readsPrec :: Int -> ReadS DeleteChangeSet
$creadsPrec :: Int -> ReadS DeleteChangeSet
Prelude.Read, Int -> DeleteChangeSet -> ShowS
[DeleteChangeSet] -> ShowS
DeleteChangeSet -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteChangeSet] -> ShowS
$cshowList :: [DeleteChangeSet] -> ShowS
show :: DeleteChangeSet -> String
$cshow :: DeleteChangeSet -> String
showsPrec :: Int -> DeleteChangeSet -> ShowS
$cshowsPrec :: Int -> DeleteChangeSet -> ShowS
Prelude.Show, forall x. Rep DeleteChangeSet x -> DeleteChangeSet
forall x. DeleteChangeSet -> Rep DeleteChangeSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteChangeSet x -> DeleteChangeSet
$cfrom :: forall x. DeleteChangeSet -> Rep DeleteChangeSet x
Prelude.Generic)

-- |
-- Create a value of 'DeleteChangeSet' 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:
--
-- 'stackName', 'deleteChangeSet_stackName' - If you specified the name of a change set to delete, specify the stack
-- name or Amazon Resource Name (ARN) that\'s associated with it.
--
-- 'changeSetName', 'deleteChangeSet_changeSetName' - The name or Amazon Resource Name (ARN) of the change set that you want
-- to delete.
newDeleteChangeSet ::
  -- | 'changeSetName'
  Prelude.Text ->
  DeleteChangeSet
newDeleteChangeSet :: Text -> DeleteChangeSet
newDeleteChangeSet Text
pChangeSetName_ =
  DeleteChangeSet'
    { $sel:stackName:DeleteChangeSet' :: Maybe Text
stackName = forall a. Maybe a
Prelude.Nothing,
      $sel:changeSetName:DeleteChangeSet' :: Text
changeSetName = Text
pChangeSetName_
    }

-- | If you specified the name of a change set to delete, specify the stack
-- name or Amazon Resource Name (ARN) that\'s associated with it.
deleteChangeSet_stackName :: Lens.Lens' DeleteChangeSet (Prelude.Maybe Prelude.Text)
deleteChangeSet_stackName :: Lens' DeleteChangeSet (Maybe Text)
deleteChangeSet_stackName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteChangeSet' {Maybe Text
stackName :: Maybe Text
$sel:stackName:DeleteChangeSet' :: DeleteChangeSet -> Maybe Text
stackName} -> Maybe Text
stackName) (\s :: DeleteChangeSet
s@DeleteChangeSet' {} Maybe Text
a -> DeleteChangeSet
s {$sel:stackName:DeleteChangeSet' :: Maybe Text
stackName = Maybe Text
a} :: DeleteChangeSet)

-- | The name or Amazon Resource Name (ARN) of the change set that you want
-- to delete.
deleteChangeSet_changeSetName :: Lens.Lens' DeleteChangeSet Prelude.Text
deleteChangeSet_changeSetName :: Lens' DeleteChangeSet Text
deleteChangeSet_changeSetName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteChangeSet' {Text
changeSetName :: Text
$sel:changeSetName:DeleteChangeSet' :: DeleteChangeSet -> Text
changeSetName} -> Text
changeSetName) (\s :: DeleteChangeSet
s@DeleteChangeSet' {} Text
a -> DeleteChangeSet
s {$sel:changeSetName:DeleteChangeSet' :: Text
changeSetName = Text
a} :: DeleteChangeSet)

instance Core.AWSRequest DeleteChangeSet where
  type
    AWSResponse DeleteChangeSet =
      DeleteChangeSetResponse
  request :: (Service -> Service) -> DeleteChangeSet -> Request DeleteChangeSet
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 DeleteChangeSet
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteChangeSet)))
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
"DeleteChangeSetResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> DeleteChangeSetResponse
DeleteChangeSetResponse'
            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 DeleteChangeSet where
  hashWithSalt :: Int -> DeleteChangeSet -> Int
hashWithSalt Int
_salt DeleteChangeSet' {Maybe Text
Text
changeSetName :: Text
stackName :: Maybe Text
$sel:changeSetName:DeleteChangeSet' :: DeleteChangeSet -> Text
$sel:stackName:DeleteChangeSet' :: DeleteChangeSet -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
stackName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
changeSetName

instance Prelude.NFData DeleteChangeSet where
  rnf :: DeleteChangeSet -> ()
rnf DeleteChangeSet' {Maybe Text
Text
changeSetName :: Text
stackName :: Maybe Text
$sel:changeSetName:DeleteChangeSet' :: DeleteChangeSet -> Text
$sel:stackName:DeleteChangeSet' :: DeleteChangeSet -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
stackName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
changeSetName

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

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

instance Data.ToQuery DeleteChangeSet where
  toQuery :: DeleteChangeSet -> QueryString
toQuery DeleteChangeSet' {Maybe Text
Text
changeSetName :: Text
stackName :: Maybe Text
$sel:changeSetName:DeleteChangeSet' :: DeleteChangeSet -> Text
$sel:stackName:DeleteChangeSet' :: DeleteChangeSet -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"DeleteChangeSet" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-05-15" :: Prelude.ByteString),
        ByteString
"StackName" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
stackName,
        ByteString
"ChangeSetName" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
changeSetName
      ]

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

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

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

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