{-# 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-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)
--
-- 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.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 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 is associated with the stack.
    CancelUpdateStack -> Text
stackName :: Prelude.Text
  }
  deriving (CancelUpdateStack -> CancelUpdateStack -> Bool
(CancelUpdateStack -> CancelUpdateStack -> Bool)
-> (CancelUpdateStack -> CancelUpdateStack -> Bool)
-> Eq CancelUpdateStack
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]
(Int -> ReadS CancelUpdateStack)
-> ReadS [CancelUpdateStack]
-> ReadPrec CancelUpdateStack
-> ReadPrec [CancelUpdateStack]
-> Read 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
(Int -> CancelUpdateStack -> ShowS)
-> (CancelUpdateStack -> String)
-> ([CancelUpdateStack] -> ShowS)
-> Show CancelUpdateStack
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. CancelUpdateStack -> Rep CancelUpdateStack x)
-> (forall x. Rep CancelUpdateStack x -> CancelUpdateStack)
-> Generic CancelUpdateStack
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 is associated with the stack.
newCancelUpdateStack ::
  -- | 'stackName'
  Prelude.Text ->
  CancelUpdateStack
newCancelUpdateStack :: Text -> CancelUpdateStack
newCancelUpdateStack Text
pStackName_ =
  CancelUpdateStack' :: Maybe Text -> Text -> CancelUpdateStack
CancelUpdateStack'
    { $sel:clientRequestToken:CancelUpdateStack' :: Maybe Text
clientRequestToken =
        Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> CancelUpdateStack -> f CancelUpdateStack
cancelUpdateStack_clientRequestToken = (CancelUpdateStack -> Maybe Text)
-> (CancelUpdateStack -> Maybe Text -> CancelUpdateStack)
-> Lens
     CancelUpdateStack CancelUpdateStack (Maybe Text) (Maybe Text)
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 is associated with the stack.
cancelUpdateStack_stackName :: Lens.Lens' CancelUpdateStack Prelude.Text
cancelUpdateStack_stackName :: (Text -> f Text) -> CancelUpdateStack -> f CancelUpdateStack
cancelUpdateStack_stackName = (CancelUpdateStack -> Text)
-> (CancelUpdateStack -> Text -> CancelUpdateStack)
-> Lens CancelUpdateStack CancelUpdateStack Text Text
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 :: CancelUpdateStack -> Request CancelUpdateStack
request = Service -> CancelUpdateStack -> Request CancelUpdateStack
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy CancelUpdateStack
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CancelUpdateStack)))
response =
    AWSResponse CancelUpdateStack
-> Logger
-> Service
-> Proxy CancelUpdateStack
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CancelUpdateStack)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse CancelUpdateStack
CancelUpdateStackResponse
CancelUpdateStackResponse'

instance Prelude.Hashable CancelUpdateStack

instance Prelude.NFData CancelUpdateStack

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

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

instance Core.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
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"CancelUpdateStack" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-05-15" :: Prelude.ByteString),
        ByteString
"ClientRequestToken" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
clientRequestToken,
        ByteString
"StackName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
stackName
      ]

-- | /See:/ 'newCancelUpdateStackResponse' smart constructor.
data CancelUpdateStackResponse = CancelUpdateStackResponse'
  {
  }
  deriving (CancelUpdateStackResponse -> CancelUpdateStackResponse -> Bool
(CancelUpdateStackResponse -> CancelUpdateStackResponse -> Bool)
-> (CancelUpdateStackResponse -> CancelUpdateStackResponse -> Bool)
-> Eq CancelUpdateStackResponse
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]
(Int -> ReadS CancelUpdateStackResponse)
-> ReadS [CancelUpdateStackResponse]
-> ReadPrec CancelUpdateStackResponse
-> ReadPrec [CancelUpdateStackResponse]
-> Read 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
(Int -> CancelUpdateStackResponse -> ShowS)
-> (CancelUpdateStackResponse -> String)
-> ([CancelUpdateStackResponse] -> ShowS)
-> Show CancelUpdateStackResponse
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.
 CancelUpdateStackResponse -> Rep CancelUpdateStackResponse x)
-> (forall x.
    Rep CancelUpdateStackResponse x -> CancelUpdateStackResponse)
-> Generic CancelUpdateStackResponse
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