{-# 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-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 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.Lens as Lens
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 ID (ARN) that is 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
(DeleteChangeSet -> DeleteChangeSet -> Bool)
-> (DeleteChangeSet -> DeleteChangeSet -> Bool)
-> Eq DeleteChangeSet
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]
(Int -> ReadS DeleteChangeSet)
-> ReadS [DeleteChangeSet]
-> ReadPrec DeleteChangeSet
-> ReadPrec [DeleteChangeSet]
-> Read 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
(Int -> DeleteChangeSet -> ShowS)
-> (DeleteChangeSet -> String)
-> ([DeleteChangeSet] -> ShowS)
-> Show DeleteChangeSet
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. DeleteChangeSet -> Rep DeleteChangeSet x)
-> (forall x. Rep DeleteChangeSet x -> DeleteChangeSet)
-> Generic DeleteChangeSet
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 ID (ARN) that is 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' :: Maybe Text -> Text -> DeleteChangeSet
DeleteChangeSet'
    { $sel:stackName:DeleteChangeSet' :: Maybe Text
stackName = Maybe Text
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 ID (ARN) that is associated with it.
deleteChangeSet_stackName :: Lens.Lens' DeleteChangeSet (Prelude.Maybe Prelude.Text)
deleteChangeSet_stackName :: (Maybe Text -> f (Maybe Text))
-> DeleteChangeSet -> f DeleteChangeSet
deleteChangeSet_stackName = (DeleteChangeSet -> Maybe Text)
-> (DeleteChangeSet -> Maybe Text -> DeleteChangeSet)
-> Lens DeleteChangeSet DeleteChangeSet (Maybe Text) (Maybe Text)
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 :: (Text -> f Text) -> DeleteChangeSet -> f DeleteChangeSet
deleteChangeSet_changeSetName = (DeleteChangeSet -> Text)
-> (DeleteChangeSet -> Text -> DeleteChangeSet)
-> Lens DeleteChangeSet DeleteChangeSet Text Text
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 :: DeleteChangeSet -> Request DeleteChangeSet
request = Service -> DeleteChangeSet -> Request DeleteChangeSet
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteChangeSet
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteChangeSet)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse DeleteChangeSet))
-> Logger
-> Service
-> Proxy DeleteChangeSet
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteChangeSet)))
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
"DeleteChangeSetResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> DeleteChangeSetResponse
DeleteChangeSetResponse'
            (Int -> DeleteChangeSetResponse)
-> Either String Int -> Either String DeleteChangeSetResponse
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 DeleteChangeSet

instance Prelude.NFData DeleteChangeSet

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

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

instance Core.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
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"DeleteChangeSet" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-05-15" :: Prelude.ByteString),
        ByteString
"StackName" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
stackName,
        ByteString
"ChangeSetName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: 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
(DeleteChangeSetResponse -> DeleteChangeSetResponse -> Bool)
-> (DeleteChangeSetResponse -> DeleteChangeSetResponse -> Bool)
-> Eq DeleteChangeSetResponse
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]
(Int -> ReadS DeleteChangeSetResponse)
-> ReadS [DeleteChangeSetResponse]
-> ReadPrec DeleteChangeSetResponse
-> ReadPrec [DeleteChangeSetResponse]
-> Read 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
(Int -> DeleteChangeSetResponse -> ShowS)
-> (DeleteChangeSetResponse -> String)
-> ([DeleteChangeSetResponse] -> ShowS)
-> Show DeleteChangeSetResponse
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.
 DeleteChangeSetResponse -> Rep DeleteChangeSetResponse x)
-> (forall x.
    Rep DeleteChangeSetResponse x -> DeleteChangeSetResponse)
-> Generic DeleteChangeSetResponse
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' :: Int -> DeleteChangeSetResponse
DeleteChangeSetResponse' {$sel:httpStatus:DeleteChangeSetResponse' :: Int
httpStatus = Int
pHttpStatus_}

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