{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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 hierarchy,
-- @IncludeNestedStacks@ must have been set to @True@.
module Amazonka.CloudFormation.ExecuteChangeSet
  ( -- * Creating a Request
    ExecuteChangeSet (..),
    newExecuteChangeSet,

    -- * Request Lenses
    executeChangeSet_clientRequestToken,
    executeChangeSet_disableRollback,
    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.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 ExecuteChangeSet action.
--
-- /See:/ 'newExecuteChangeSet' smart constructor.
data ExecuteChangeSet = 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 -> Maybe Text
clientRequestToken :: Prelude.Maybe Prelude.Text,
    -- | Preserves the state of previously provisioned resources when an
    -- operation fails.
    --
    -- Default: @True@
    ExecuteChangeSet -> Maybe Bool
disableRollback :: Prelude.Maybe Prelude.Bool,
    -- | If you specified the name of a change set, specify the stack name or
    -- Amazon Resource Name (ARN) that\'s associated with the change set you
    -- want to execute.
    ExecuteChangeSet -> Maybe Text
stackName :: Prelude.Maybe Prelude.Text,
    -- | The name or Amazon Resource Name (ARN) of the change set that you want
    -- use to update the specified stack.
    ExecuteChangeSet -> Text
changeSetName :: Prelude.Text
  }
  deriving (ExecuteChangeSet -> ExecuteChangeSet -> Bool
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]
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
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. 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:
--
-- '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.
--
-- 'disableRollback', 'executeChangeSet_disableRollback' - Preserves the state of previously provisioned resources when an
-- operation fails.
--
-- Default: @True@
--
-- 'stackName', 'executeChangeSet_stackName' - If you specified the name of a change set, specify the stack name or
-- Amazon Resource Name (ARN) that\'s associated with the change set you
-- want to execute.
--
-- 'changeSetName', 'executeChangeSet_changeSetName' - The name or Amazon Resource Name (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'
    { $sel:clientRequestToken:ExecuteChangeSet' :: Maybe Text
clientRequestToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:disableRollback:ExecuteChangeSet' :: Maybe Bool
disableRollback = forall a. Maybe a
Prelude.Nothing,
      $sel:stackName:ExecuteChangeSet' :: Maybe Text
stackName = forall a. Maybe a
Prelude.Nothing,
      $sel:changeSetName:ExecuteChangeSet' :: Text
changeSetName = Text
pChangeSetName_
    }

-- | 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 :: Lens' ExecuteChangeSet (Maybe Text)
executeChangeSet_clientRequestToken = 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)

-- | Preserves the state of previously provisioned resources when an
-- operation fails.
--
-- Default: @True@
executeChangeSet_disableRollback :: Lens.Lens' ExecuteChangeSet (Prelude.Maybe Prelude.Bool)
executeChangeSet_disableRollback :: Lens' ExecuteChangeSet (Maybe Bool)
executeChangeSet_disableRollback = 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)

-- | If you specified the name of a change set, specify the stack name or
-- Amazon Resource Name (ARN) that\'s associated with the change set you
-- want to execute.
executeChangeSet_stackName :: Lens.Lens' ExecuteChangeSet (Prelude.Maybe Prelude.Text)
executeChangeSet_stackName :: Lens' ExecuteChangeSet (Maybe Text)
executeChangeSet_stackName = 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 Amazon Resource Name (ARN) of the change set that you want
-- use to update the specified stack.
executeChangeSet_changeSetName :: Lens.Lens' ExecuteChangeSet Prelude.Text
executeChangeSet_changeSetName :: Lens' ExecuteChangeSet Text
executeChangeSet_changeSetName = 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 :: (Service -> Service)
-> ExecuteChangeSet -> Request ExecuteChangeSet
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 ExecuteChangeSet
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ExecuteChangeSet)))
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
"ExecuteChangeSetResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> ExecuteChangeSetResponse
ExecuteChangeSetResponse'
            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 ExecuteChangeSet where
  hashWithSalt :: Int -> ExecuteChangeSet -> Int
hashWithSalt Int
_salt ExecuteChangeSet' {Maybe Bool
Maybe Text
Text
changeSetName :: Text
stackName :: Maybe Text
disableRollback :: Maybe Bool
clientRequestToken :: Maybe Text
$sel:changeSetName:ExecuteChangeSet' :: ExecuteChangeSet -> Text
$sel:stackName:ExecuteChangeSet' :: ExecuteChangeSet -> Maybe Text
$sel:disableRollback:ExecuteChangeSet' :: ExecuteChangeSet -> Maybe Bool
$sel:clientRequestToken:ExecuteChangeSet' :: ExecuteChangeSet -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
clientRequestToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
disableRollback
      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 ExecuteChangeSet where
  rnf :: ExecuteChangeSet -> ()
rnf ExecuteChangeSet' {Maybe Bool
Maybe Text
Text
changeSetName :: Text
stackName :: Maybe Text
disableRollback :: Maybe Bool
clientRequestToken :: Maybe Text
$sel:changeSetName:ExecuteChangeSet' :: ExecuteChangeSet -> Text
$sel:stackName:ExecuteChangeSet' :: ExecuteChangeSet -> Maybe Text
$sel:disableRollback:ExecuteChangeSet' :: ExecuteChangeSet -> Maybe Bool
$sel:clientRequestToken:ExecuteChangeSet' :: ExecuteChangeSet -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clientRequestToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
disableRollback
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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 ExecuteChangeSet where
  toHeaders :: ExecuteChangeSet -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

instance Data.ToQuery ExecuteChangeSet where
  toQuery :: ExecuteChangeSet -> QueryString
toQuery ExecuteChangeSet' {Maybe Bool
Maybe Text
Text
changeSetName :: Text
stackName :: Maybe Text
disableRollback :: Maybe Bool
clientRequestToken :: Maybe Text
$sel:changeSetName:ExecuteChangeSet' :: ExecuteChangeSet -> Text
$sel:stackName:ExecuteChangeSet' :: ExecuteChangeSet -> Maybe Text
$sel:disableRollback:ExecuteChangeSet' :: ExecuteChangeSet -> Maybe Bool
$sel:clientRequestToken:ExecuteChangeSet' :: ExecuteChangeSet -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"ExecuteChangeSet" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-05-15" :: Prelude.ByteString),
        ByteString
"ClientRequestToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
clientRequestToken,
        ByteString
"DisableRollback" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Bool
disableRollback,
        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 ExecuteChangeSet action.
--
-- /See:/ 'newExecuteChangeSetResponse' smart constructor.
data ExecuteChangeSetResponse = ExecuteChangeSetResponse'
  { -- | The response's http status code.
    ExecuteChangeSetResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ExecuteChangeSetResponse -> ExecuteChangeSetResponse -> Bool
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]
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
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.
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'
    { $sel:httpStatus:ExecuteChangeSetResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
executeChangeSetResponse_httpStatus :: Lens.Lens' ExecuteChangeSetResponse Prelude.Int
executeChangeSetResponse_httpStatus :: Lens' ExecuteChangeSetResponse Int
executeChangeSetResponse_httpStatus = 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 where
  rnf :: ExecuteChangeSetResponse -> ()
rnf ExecuteChangeSetResponse' {Int
httpStatus :: Int
$sel:httpStatus:ExecuteChangeSetResponse' :: ExecuteChangeSetResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus