{-# 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.CancelUpdateStack
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Cancels an update on the specified stack. If the call completes
-- successfully, the stack rolls back the update and reverts to the
-- previous stack configuration.
--
-- You can cancel only stacks that are in the @UPDATE_IN_PROGRESS@ state.
module Amazonka.CloudFormation.CancelUpdateStack
  ( -- * Creating a Request
    CancelUpdateStack (..),
    newCancelUpdateStack,

    -- * Request Lenses
    cancelUpdateStack_clientRequestToken,
    cancelUpdateStack_stackName,

    -- * Destructuring the Response
    CancelUpdateStackResponse (..),
    newCancelUpdateStackResponse,
  )
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 CancelUpdateStack action.
--
-- /See:/ 'newCancelUpdateStack' smart constructor.
data CancelUpdateStack = CancelUpdateStack'
  { -- | A unique identifier for this @CancelUpdateStack@ request. Specify this
    -- token if you plan to retry requests so that CloudFormation knows that
    -- you\'re not attempting to cancel an update on a stack with the same
    -- name. You might retry @CancelUpdateStack@ requests to ensure that
    -- CloudFormation successfully received them.
    CancelUpdateStack -> Maybe Text
clientRequestToken :: Prelude.Maybe Prelude.Text,
    -- | The name or the unique stack ID that\'s associated with the stack.
    CancelUpdateStack -> Text
stackName :: Prelude.Text
  }
  deriving (CancelUpdateStack -> CancelUpdateStack -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelUpdateStack -> CancelUpdateStack -> Bool
$c/= :: CancelUpdateStack -> CancelUpdateStack -> Bool
== :: CancelUpdateStack -> CancelUpdateStack -> Bool
$c== :: CancelUpdateStack -> CancelUpdateStack -> Bool
Prelude.Eq, ReadPrec [CancelUpdateStack]
ReadPrec CancelUpdateStack
Int -> ReadS CancelUpdateStack
ReadS [CancelUpdateStack]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelUpdateStack]
$creadListPrec :: ReadPrec [CancelUpdateStack]
readPrec :: ReadPrec CancelUpdateStack
$creadPrec :: ReadPrec CancelUpdateStack
readList :: ReadS [CancelUpdateStack]
$creadList :: ReadS [CancelUpdateStack]
readsPrec :: Int -> ReadS CancelUpdateStack
$creadsPrec :: Int -> ReadS CancelUpdateStack
Prelude.Read, Int -> CancelUpdateStack -> ShowS
[CancelUpdateStack] -> ShowS
CancelUpdateStack -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelUpdateStack] -> ShowS
$cshowList :: [CancelUpdateStack] -> ShowS
show :: CancelUpdateStack -> String
$cshow :: CancelUpdateStack -> String
showsPrec :: Int -> CancelUpdateStack -> ShowS
$cshowsPrec :: Int -> CancelUpdateStack -> ShowS
Prelude.Show, forall x. Rep CancelUpdateStack x -> CancelUpdateStack
forall x. CancelUpdateStack -> Rep CancelUpdateStack x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CancelUpdateStack x -> CancelUpdateStack
$cfrom :: forall x. CancelUpdateStack -> Rep CancelUpdateStack x
Prelude.Generic)

-- |
-- Create a value of 'CancelUpdateStack' 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', 'cancelUpdateStack_clientRequestToken' - A unique identifier for this @CancelUpdateStack@ request. Specify this
-- token if you plan to retry requests so that CloudFormation knows that
-- you\'re not attempting to cancel an update on a stack with the same
-- name. You might retry @CancelUpdateStack@ requests to ensure that
-- CloudFormation successfully received them.
--
-- 'stackName', 'cancelUpdateStack_stackName' - The name or the unique stack ID that\'s associated with the stack.
newCancelUpdateStack ::
  -- | 'stackName'
  Prelude.Text ->
  CancelUpdateStack
newCancelUpdateStack :: Text -> CancelUpdateStack
newCancelUpdateStack Text
pStackName_ =
  CancelUpdateStack'
    { $sel:clientRequestToken:CancelUpdateStack' :: Maybe Text
clientRequestToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:stackName:CancelUpdateStack' :: Text
stackName = Text
pStackName_
    }

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

-- | The name or the unique stack ID that\'s associated with the stack.
cancelUpdateStack_stackName :: Lens.Lens' CancelUpdateStack Prelude.Text
cancelUpdateStack_stackName :: Lens' CancelUpdateStack Text
cancelUpdateStack_stackName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelUpdateStack' {Text
stackName :: Text
$sel:stackName:CancelUpdateStack' :: CancelUpdateStack -> Text
stackName} -> Text
stackName) (\s :: CancelUpdateStack
s@CancelUpdateStack' {} Text
a -> CancelUpdateStack
s {$sel:stackName:CancelUpdateStack' :: Text
stackName = Text
a} :: CancelUpdateStack)

instance Core.AWSRequest CancelUpdateStack where
  type
    AWSResponse CancelUpdateStack =
      CancelUpdateStackResponse
  request :: (Service -> Service)
-> CancelUpdateStack -> Request CancelUpdateStack
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 CancelUpdateStack
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CancelUpdateStack)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull CancelUpdateStackResponse
CancelUpdateStackResponse'

instance Prelude.Hashable CancelUpdateStack where
  hashWithSalt :: Int -> CancelUpdateStack -> Int
hashWithSalt Int
_salt CancelUpdateStack' {Maybe Text
Text
stackName :: Text
clientRequestToken :: Maybe Text
$sel:stackName:CancelUpdateStack' :: CancelUpdateStack -> Text
$sel:clientRequestToken:CancelUpdateStack' :: CancelUpdateStack -> 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` Text
stackName

instance Prelude.NFData CancelUpdateStack where
  rnf :: CancelUpdateStack -> ()
rnf CancelUpdateStack' {Maybe Text
Text
stackName :: Text
clientRequestToken :: Maybe Text
$sel:stackName:CancelUpdateStack' :: CancelUpdateStack -> Text
$sel:clientRequestToken:CancelUpdateStack' :: CancelUpdateStack -> 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 Text
stackName

instance Data.ToHeaders CancelUpdateStack where
  toHeaders :: CancelUpdateStack -> [Header]
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

instance Data.ToQuery CancelUpdateStack where
  toQuery :: CancelUpdateStack -> QueryString
toQuery CancelUpdateStack' {Maybe Text
Text
stackName :: Text
clientRequestToken :: Maybe Text
$sel:stackName:CancelUpdateStack' :: CancelUpdateStack -> Text
$sel:clientRequestToken:CancelUpdateStack' :: CancelUpdateStack -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"CancelUpdateStack" :: 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
"StackName" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
stackName
      ]

-- | /See:/ 'newCancelUpdateStackResponse' smart constructor.
data CancelUpdateStackResponse = CancelUpdateStackResponse'
  {
  }
  deriving (CancelUpdateStackResponse -> CancelUpdateStackResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelUpdateStackResponse -> CancelUpdateStackResponse -> Bool
$c/= :: CancelUpdateStackResponse -> CancelUpdateStackResponse -> Bool
== :: CancelUpdateStackResponse -> CancelUpdateStackResponse -> Bool
$c== :: CancelUpdateStackResponse -> CancelUpdateStackResponse -> Bool
Prelude.Eq, ReadPrec [CancelUpdateStackResponse]
ReadPrec CancelUpdateStackResponse
Int -> ReadS CancelUpdateStackResponse
ReadS [CancelUpdateStackResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelUpdateStackResponse]
$creadListPrec :: ReadPrec [CancelUpdateStackResponse]
readPrec :: ReadPrec CancelUpdateStackResponse
$creadPrec :: ReadPrec CancelUpdateStackResponse
readList :: ReadS [CancelUpdateStackResponse]
$creadList :: ReadS [CancelUpdateStackResponse]
readsPrec :: Int -> ReadS CancelUpdateStackResponse
$creadsPrec :: Int -> ReadS CancelUpdateStackResponse
Prelude.Read, Int -> CancelUpdateStackResponse -> ShowS
[CancelUpdateStackResponse] -> ShowS
CancelUpdateStackResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelUpdateStackResponse] -> ShowS
$cshowList :: [CancelUpdateStackResponse] -> ShowS
show :: CancelUpdateStackResponse -> String
$cshow :: CancelUpdateStackResponse -> String
showsPrec :: Int -> CancelUpdateStackResponse -> ShowS
$cshowsPrec :: Int -> CancelUpdateStackResponse -> ShowS
Prelude.Show, forall x.
Rep CancelUpdateStackResponse x -> CancelUpdateStackResponse
forall x.
CancelUpdateStackResponse -> Rep CancelUpdateStackResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CancelUpdateStackResponse x -> CancelUpdateStackResponse
$cfrom :: forall x.
CancelUpdateStackResponse -> Rep CancelUpdateStackResponse x
Prelude.Generic)

-- |
-- Create a value of 'CancelUpdateStackResponse' 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.
newCancelUpdateStackResponse ::
  CancelUpdateStackResponse
newCancelUpdateStackResponse :: CancelUpdateStackResponse
newCancelUpdateStackResponse =
  CancelUpdateStackResponse
CancelUpdateStackResponse'

instance Prelude.NFData CancelUpdateStackResponse where
  rnf :: CancelUpdateStackResponse -> ()
rnf CancelUpdateStackResponse
_ = ()