{-# 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.ExecuteChangeSet
-- 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)
--
-- Updates a stack using the input information that was provided when the
-- specified change set was created. After the call successfully completes,
-- CloudFormation starts updating the stack. Use the DescribeStacks action
-- to view the status of the update.
--
-- When you execute a change set, CloudFormation deletes all other change
-- sets associated with the stack because they aren\'t valid for the
-- updated stack.
--
-- If a stack policy is associated with the stack, CloudFormation enforces
-- the policy during the update. You can\'t specify a temporary stack
-- policy that overrides the current policy.
--
-- To create a change set for the entire stack hierachy,
-- @IncludeNestedStacks@ must have been set to @True@.
module Amazonka.CloudFormation.ExecuteChangeSet
  ( -- * Creating a Request
    ExecuteChangeSet (..),
    newExecuteChangeSet,

    -- * Request Lenses
    executeChangeSet_disableRollback,
    executeChangeSet_clientRequestToken,
    executeChangeSet_stackName,
    executeChangeSet_changeSetName,

    -- * Destructuring the Response
    ExecuteChangeSetResponse (..),
    newExecuteChangeSetResponse,

    -- * Response Lenses
    executeChangeSetResponse_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 ExecuteChangeSet action.
--
-- /See:/ 'newExecuteChangeSet' smart constructor.
data ExecuteChangeSet = ExecuteChangeSet'
  { -- | Preserves the state of previously provisioned resources when an
    -- operation fails.
    --
    -- Default: @True@
    ExecuteChangeSet -> Maybe Bool
disableRollback :: Prelude.Maybe Prelude.Bool,
    -- | A unique identifier for this @ExecuteChangeSet@ request. Specify this
    -- token if you plan to retry requests so that CloudFormation knows that
    -- you\'re not attempting to execute a change set to update a stack with
    -- the same name. You might retry @ExecuteChangeSet@ requests to ensure
    -- that CloudFormation successfully received them.
    ExecuteChangeSet -> Maybe Text
clientRequestToken :: Prelude.Maybe Prelude.Text,
    -- | If you specified the name of a change set, specify the stack name or ID
    -- (ARN) that is associated with the change set you want to execute.
    ExecuteChangeSet -> Maybe Text
stackName :: Prelude.Maybe Prelude.Text,
    -- | The name or ARN of the change set that you want use to update the
    -- specified stack.
    ExecuteChangeSet -> Text
changeSetName :: Prelude.Text
  }
  deriving (ExecuteChangeSet -> ExecuteChangeSet -> Bool
(ExecuteChangeSet -> ExecuteChangeSet -> Bool)
-> (ExecuteChangeSet -> ExecuteChangeSet -> Bool)
-> Eq ExecuteChangeSet
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExecuteChangeSet -> ExecuteChangeSet -> Bool
$c/= :: ExecuteChangeSet -> ExecuteChangeSet -> Bool
== :: ExecuteChangeSet -> ExecuteChangeSet -> Bool
$c== :: ExecuteChangeSet -> ExecuteChangeSet -> Bool
Prelude.Eq, ReadPrec [ExecuteChangeSet]
ReadPrec ExecuteChangeSet
Int -> ReadS ExecuteChangeSet
ReadS [ExecuteChangeSet]
(Int -> ReadS ExecuteChangeSet)
-> ReadS [ExecuteChangeSet]
-> ReadPrec ExecuteChangeSet
-> ReadPrec [ExecuteChangeSet]
-> Read ExecuteChangeSet
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExecuteChangeSet]
$creadListPrec :: ReadPrec [ExecuteChangeSet]
readPrec :: ReadPrec ExecuteChangeSet
$creadPrec :: ReadPrec ExecuteChangeSet
readList :: ReadS [ExecuteChangeSet]
$creadList :: ReadS [ExecuteChangeSet]
readsPrec :: Int -> ReadS ExecuteChangeSet
$creadsPrec :: Int -> ReadS ExecuteChangeSet
Prelude.Read, Int -> ExecuteChangeSet -> ShowS
[ExecuteChangeSet] -> ShowS
ExecuteChangeSet -> String
(Int -> ExecuteChangeSet -> ShowS)
-> (ExecuteChangeSet -> String)
-> ([ExecuteChangeSet] -> ShowS)
-> Show ExecuteChangeSet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExecuteChangeSet] -> ShowS
$cshowList :: [ExecuteChangeSet] -> ShowS
show :: ExecuteChangeSet -> String
$cshow :: ExecuteChangeSet -> String
showsPrec :: Int -> ExecuteChangeSet -> ShowS
$cshowsPrec :: Int -> ExecuteChangeSet -> ShowS
Prelude.Show, (forall x. ExecuteChangeSet -> Rep ExecuteChangeSet x)
-> (forall x. Rep ExecuteChangeSet x -> ExecuteChangeSet)
-> Generic ExecuteChangeSet
forall x. Rep ExecuteChangeSet x -> ExecuteChangeSet
forall x. ExecuteChangeSet -> Rep ExecuteChangeSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExecuteChangeSet x -> ExecuteChangeSet
$cfrom :: forall x. ExecuteChangeSet -> Rep ExecuteChangeSet x
Prelude.Generic)

-- |
-- Create a value of 'ExecuteChangeSet' 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:
--
-- 'disableRollback', 'executeChangeSet_disableRollback' - Preserves the state of previously provisioned resources when an
-- operation fails.
--
-- Default: @True@
--
-- 'clientRequestToken', 'executeChangeSet_clientRequestToken' - A unique identifier for this @ExecuteChangeSet@ request. Specify this
-- token if you plan to retry requests so that CloudFormation knows that
-- you\'re not attempting to execute a change set to update a stack with
-- the same name. You might retry @ExecuteChangeSet@ requests to ensure
-- that CloudFormation successfully received them.
--
-- 'stackName', 'executeChangeSet_stackName' - If you specified the name of a change set, specify the stack name or ID
-- (ARN) that is associated with the change set you want to execute.
--
-- 'changeSetName', 'executeChangeSet_changeSetName' - The name or ARN of the change set that you want use to update the
-- specified stack.
newExecuteChangeSet ::
  -- | 'changeSetName'
  Prelude.Text ->
  ExecuteChangeSet
newExecuteChangeSet :: Text -> ExecuteChangeSet
newExecuteChangeSet Text
pChangeSetName_ =
  ExecuteChangeSet' :: Maybe Bool -> Maybe Text -> Maybe Text -> Text -> ExecuteChangeSet
ExecuteChangeSet'
    { $sel:disableRollback:ExecuteChangeSet' :: Maybe Bool
disableRollback =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:clientRequestToken:ExecuteChangeSet' :: Maybe Text
clientRequestToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:stackName:ExecuteChangeSet' :: Maybe Text
stackName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:changeSetName:ExecuteChangeSet' :: Text
changeSetName = Text
pChangeSetName_
    }

-- | Preserves the state of previously provisioned resources when an
-- operation fails.
--
-- Default: @True@
executeChangeSet_disableRollback :: Lens.Lens' ExecuteChangeSet (Prelude.Maybe Prelude.Bool)
executeChangeSet_disableRollback :: (Maybe Bool -> f (Maybe Bool))
-> ExecuteChangeSet -> f ExecuteChangeSet
executeChangeSet_disableRollback = (ExecuteChangeSet -> Maybe Bool)
-> (ExecuteChangeSet -> Maybe Bool -> ExecuteChangeSet)
-> Lens ExecuteChangeSet ExecuteChangeSet (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecuteChangeSet' {Maybe Bool
disableRollback :: Maybe Bool
$sel:disableRollback:ExecuteChangeSet' :: ExecuteChangeSet -> Maybe Bool
disableRollback} -> Maybe Bool
disableRollback) (\s :: ExecuteChangeSet
s@ExecuteChangeSet' {} Maybe Bool
a -> ExecuteChangeSet
s {$sel:disableRollback:ExecuteChangeSet' :: Maybe Bool
disableRollback = Maybe Bool
a} :: ExecuteChangeSet)

-- | A unique identifier for this @ExecuteChangeSet@ request. Specify this
-- token if you plan to retry requests so that CloudFormation knows that
-- you\'re not attempting to execute a change set to update a stack with
-- the same name. You might retry @ExecuteChangeSet@ requests to ensure
-- that CloudFormation successfully received them.
executeChangeSet_clientRequestToken :: Lens.Lens' ExecuteChangeSet (Prelude.Maybe Prelude.Text)
executeChangeSet_clientRequestToken :: (Maybe Text -> f (Maybe Text))
-> ExecuteChangeSet -> f ExecuteChangeSet
executeChangeSet_clientRequestToken = (ExecuteChangeSet -> Maybe Text)
-> (ExecuteChangeSet -> Maybe Text -> ExecuteChangeSet)
-> Lens ExecuteChangeSet ExecuteChangeSet (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecuteChangeSet' {Maybe Text
clientRequestToken :: Maybe Text
$sel:clientRequestToken:ExecuteChangeSet' :: ExecuteChangeSet -> Maybe Text
clientRequestToken} -> Maybe Text
clientRequestToken) (\s :: ExecuteChangeSet
s@ExecuteChangeSet' {} Maybe Text
a -> ExecuteChangeSet
s {$sel:clientRequestToken:ExecuteChangeSet' :: Maybe Text
clientRequestToken = Maybe Text
a} :: ExecuteChangeSet)

-- | If you specified the name of a change set, specify the stack name or ID
-- (ARN) that is associated with the change set you want to execute.
executeChangeSet_stackName :: Lens.Lens' ExecuteChangeSet (Prelude.Maybe Prelude.Text)
executeChangeSet_stackName :: (Maybe Text -> f (Maybe Text))
-> ExecuteChangeSet -> f ExecuteChangeSet
executeChangeSet_stackName = (ExecuteChangeSet -> Maybe Text)
-> (ExecuteChangeSet -> Maybe Text -> ExecuteChangeSet)
-> Lens ExecuteChangeSet ExecuteChangeSet (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecuteChangeSet' {Maybe Text
stackName :: Maybe Text
$sel:stackName:ExecuteChangeSet' :: ExecuteChangeSet -> Maybe Text
stackName} -> Maybe Text
stackName) (\s :: ExecuteChangeSet
s@ExecuteChangeSet' {} Maybe Text
a -> ExecuteChangeSet
s {$sel:stackName:ExecuteChangeSet' :: Maybe Text
stackName = Maybe Text
a} :: ExecuteChangeSet)

-- | The name or ARN of the change set that you want use to update the
-- specified stack.
executeChangeSet_changeSetName :: Lens.Lens' ExecuteChangeSet Prelude.Text
executeChangeSet_changeSetName :: (Text -> f Text) -> ExecuteChangeSet -> f ExecuteChangeSet
executeChangeSet_changeSetName = (ExecuteChangeSet -> Text)
-> (ExecuteChangeSet -> Text -> ExecuteChangeSet)
-> Lens ExecuteChangeSet ExecuteChangeSet Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecuteChangeSet' {Text
changeSetName :: Text
$sel:changeSetName:ExecuteChangeSet' :: ExecuteChangeSet -> Text
changeSetName} -> Text
changeSetName) (\s :: ExecuteChangeSet
s@ExecuteChangeSet' {} Text
a -> ExecuteChangeSet
s {$sel:changeSetName:ExecuteChangeSet' :: Text
changeSetName = Text
a} :: ExecuteChangeSet)

instance Core.AWSRequest ExecuteChangeSet where
  type
    AWSResponse ExecuteChangeSet =
      ExecuteChangeSetResponse
  request :: ExecuteChangeSet -> Request ExecuteChangeSet
request = Service -> ExecuteChangeSet -> Request ExecuteChangeSet
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy ExecuteChangeSet
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ExecuteChangeSet)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse ExecuteChangeSet))
-> Logger
-> Service
-> Proxy ExecuteChangeSet
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ExecuteChangeSet)))
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
"ExecuteChangeSetResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> ExecuteChangeSetResponse
ExecuteChangeSetResponse'
            (Int -> ExecuteChangeSetResponse)
-> Either String Int -> Either String ExecuteChangeSetResponse
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 ExecuteChangeSet

instance Prelude.NFData ExecuteChangeSet

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

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

instance Core.ToQuery ExecuteChangeSet where
  toQuery :: ExecuteChangeSet -> QueryString
toQuery ExecuteChangeSet' {Maybe Bool
Maybe Text
Text
changeSetName :: Text
stackName :: Maybe Text
clientRequestToken :: Maybe Text
disableRollback :: Maybe Bool
$sel:changeSetName:ExecuteChangeSet' :: ExecuteChangeSet -> Text
$sel:stackName:ExecuteChangeSet' :: ExecuteChangeSet -> Maybe Text
$sel:clientRequestToken:ExecuteChangeSet' :: ExecuteChangeSet -> Maybe Text
$sel:disableRollback:ExecuteChangeSet' :: ExecuteChangeSet -> Maybe Bool
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"ExecuteChangeSet" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-05-15" :: Prelude.ByteString),
        ByteString
"DisableRollback" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
disableRollback,
        ByteString
"ClientRequestToken" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
clientRequestToken,
        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 ExecuteChangeSet action.
--
-- /See:/ 'newExecuteChangeSetResponse' smart constructor.
data ExecuteChangeSetResponse = ExecuteChangeSetResponse'
  { -- | The response's http status code.
    ExecuteChangeSetResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ExecuteChangeSetResponse -> ExecuteChangeSetResponse -> Bool
(ExecuteChangeSetResponse -> ExecuteChangeSetResponse -> Bool)
-> (ExecuteChangeSetResponse -> ExecuteChangeSetResponse -> Bool)
-> Eq ExecuteChangeSetResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExecuteChangeSetResponse -> ExecuteChangeSetResponse -> Bool
$c/= :: ExecuteChangeSetResponse -> ExecuteChangeSetResponse -> Bool
== :: ExecuteChangeSetResponse -> ExecuteChangeSetResponse -> Bool
$c== :: ExecuteChangeSetResponse -> ExecuteChangeSetResponse -> Bool
Prelude.Eq, ReadPrec [ExecuteChangeSetResponse]
ReadPrec ExecuteChangeSetResponse
Int -> ReadS ExecuteChangeSetResponse
ReadS [ExecuteChangeSetResponse]
(Int -> ReadS ExecuteChangeSetResponse)
-> ReadS [ExecuteChangeSetResponse]
-> ReadPrec ExecuteChangeSetResponse
-> ReadPrec [ExecuteChangeSetResponse]
-> Read ExecuteChangeSetResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExecuteChangeSetResponse]
$creadListPrec :: ReadPrec [ExecuteChangeSetResponse]
readPrec :: ReadPrec ExecuteChangeSetResponse
$creadPrec :: ReadPrec ExecuteChangeSetResponse
readList :: ReadS [ExecuteChangeSetResponse]
$creadList :: ReadS [ExecuteChangeSetResponse]
readsPrec :: Int -> ReadS ExecuteChangeSetResponse
$creadsPrec :: Int -> ReadS ExecuteChangeSetResponse
Prelude.Read, Int -> ExecuteChangeSetResponse -> ShowS
[ExecuteChangeSetResponse] -> ShowS
ExecuteChangeSetResponse -> String
(Int -> ExecuteChangeSetResponse -> ShowS)
-> (ExecuteChangeSetResponse -> String)
-> ([ExecuteChangeSetResponse] -> ShowS)
-> Show ExecuteChangeSetResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExecuteChangeSetResponse] -> ShowS
$cshowList :: [ExecuteChangeSetResponse] -> ShowS
show :: ExecuteChangeSetResponse -> String
$cshow :: ExecuteChangeSetResponse -> String
showsPrec :: Int -> ExecuteChangeSetResponse -> ShowS
$cshowsPrec :: Int -> ExecuteChangeSetResponse -> ShowS
Prelude.Show, (forall x.
 ExecuteChangeSetResponse -> Rep ExecuteChangeSetResponse x)
-> (forall x.
    Rep ExecuteChangeSetResponse x -> ExecuteChangeSetResponse)
-> Generic ExecuteChangeSetResponse
forall x.
Rep ExecuteChangeSetResponse x -> ExecuteChangeSetResponse
forall x.
ExecuteChangeSetResponse -> Rep ExecuteChangeSetResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ExecuteChangeSetResponse x -> ExecuteChangeSetResponse
$cfrom :: forall x.
ExecuteChangeSetResponse -> Rep ExecuteChangeSetResponse x
Prelude.Generic)

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

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

instance Prelude.NFData ExecuteChangeSetResponse