{-# 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.StopStackSetOperation
-- 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)
--
-- Stops an in-progress operation on a stack set and its associated stack
-- instances.
module Amazonka.CloudFormation.StopStackSetOperation
  ( -- * Creating a Request
    StopStackSetOperation (..),
    newStopStackSetOperation,

    -- * Request Lenses
    stopStackSetOperation_callAs,
    stopStackSetOperation_stackSetName,
    stopStackSetOperation_operationId,

    -- * Destructuring the Response
    StopStackSetOperationResponse (..),
    newStopStackSetOperationResponse,

    -- * Response Lenses
    stopStackSetOperationResponse_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

-- | /See:/ 'newStopStackSetOperation' smart constructor.
data StopStackSetOperation = StopStackSetOperation'
  { -- | [Service-managed permissions] Specifies whether you are acting as an
    -- account administrator in the organization\'s management account or as a
    -- delegated administrator in a member account.
    --
    -- By default, @SELF@ is specified. Use @SELF@ for stack sets with
    -- self-managed permissions.
    --
    -- -   If you are signed in to the management account, specify @SELF@.
    --
    -- -   If you are signed in to a delegated administrator account, specify
    --     @DELEGATED_ADMIN@.
    --
    --     Your Amazon Web Services account must be registered as a delegated
    --     administrator in the management account. For more information, see
    --     <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-orgs-delegated-admin.html Register a delegated administrator>
    --     in the /CloudFormation User Guide/.
    StopStackSetOperation -> Maybe CallAs
callAs :: Prelude.Maybe CallAs,
    -- | The name or unique ID of the stack set that you want to stop the
    -- operation for.
    StopStackSetOperation -> Text
stackSetName :: Prelude.Text,
    -- | The ID of the stack operation.
    StopStackSetOperation -> Text
operationId :: Prelude.Text
  }
  deriving (StopStackSetOperation -> StopStackSetOperation -> Bool
(StopStackSetOperation -> StopStackSetOperation -> Bool)
-> (StopStackSetOperation -> StopStackSetOperation -> Bool)
-> Eq StopStackSetOperation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopStackSetOperation -> StopStackSetOperation -> Bool
$c/= :: StopStackSetOperation -> StopStackSetOperation -> Bool
== :: StopStackSetOperation -> StopStackSetOperation -> Bool
$c== :: StopStackSetOperation -> StopStackSetOperation -> Bool
Prelude.Eq, ReadPrec [StopStackSetOperation]
ReadPrec StopStackSetOperation
Int -> ReadS StopStackSetOperation
ReadS [StopStackSetOperation]
(Int -> ReadS StopStackSetOperation)
-> ReadS [StopStackSetOperation]
-> ReadPrec StopStackSetOperation
-> ReadPrec [StopStackSetOperation]
-> Read StopStackSetOperation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopStackSetOperation]
$creadListPrec :: ReadPrec [StopStackSetOperation]
readPrec :: ReadPrec StopStackSetOperation
$creadPrec :: ReadPrec StopStackSetOperation
readList :: ReadS [StopStackSetOperation]
$creadList :: ReadS [StopStackSetOperation]
readsPrec :: Int -> ReadS StopStackSetOperation
$creadsPrec :: Int -> ReadS StopStackSetOperation
Prelude.Read, Int -> StopStackSetOperation -> ShowS
[StopStackSetOperation] -> ShowS
StopStackSetOperation -> String
(Int -> StopStackSetOperation -> ShowS)
-> (StopStackSetOperation -> String)
-> ([StopStackSetOperation] -> ShowS)
-> Show StopStackSetOperation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopStackSetOperation] -> ShowS
$cshowList :: [StopStackSetOperation] -> ShowS
show :: StopStackSetOperation -> String
$cshow :: StopStackSetOperation -> String
showsPrec :: Int -> StopStackSetOperation -> ShowS
$cshowsPrec :: Int -> StopStackSetOperation -> ShowS
Prelude.Show, (forall x. StopStackSetOperation -> Rep StopStackSetOperation x)
-> (forall x. Rep StopStackSetOperation x -> StopStackSetOperation)
-> Generic StopStackSetOperation
forall x. Rep StopStackSetOperation x -> StopStackSetOperation
forall x. StopStackSetOperation -> Rep StopStackSetOperation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StopStackSetOperation x -> StopStackSetOperation
$cfrom :: forall x. StopStackSetOperation -> Rep StopStackSetOperation x
Prelude.Generic)

-- |
-- Create a value of 'StopStackSetOperation' 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:
--
-- 'callAs', 'stopStackSetOperation_callAs' - [Service-managed permissions] Specifies whether you are acting as an
-- account administrator in the organization\'s management account or as a
-- delegated administrator in a member account.
--
-- By default, @SELF@ is specified. Use @SELF@ for stack sets with
-- self-managed permissions.
--
-- -   If you are signed in to the management account, specify @SELF@.
--
-- -   If you are signed in to a delegated administrator account, specify
--     @DELEGATED_ADMIN@.
--
--     Your Amazon Web Services account must be registered as a delegated
--     administrator in the management account. For more information, see
--     <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-orgs-delegated-admin.html Register a delegated administrator>
--     in the /CloudFormation User Guide/.
--
-- 'stackSetName', 'stopStackSetOperation_stackSetName' - The name or unique ID of the stack set that you want to stop the
-- operation for.
--
-- 'operationId', 'stopStackSetOperation_operationId' - The ID of the stack operation.
newStopStackSetOperation ::
  -- | 'stackSetName'
  Prelude.Text ->
  -- | 'operationId'
  Prelude.Text ->
  StopStackSetOperation
newStopStackSetOperation :: Text -> Text -> StopStackSetOperation
newStopStackSetOperation Text
pStackSetName_ Text
pOperationId_ =
  StopStackSetOperation' :: Maybe CallAs -> Text -> Text -> StopStackSetOperation
StopStackSetOperation'
    { $sel:callAs:StopStackSetOperation' :: Maybe CallAs
callAs = Maybe CallAs
forall a. Maybe a
Prelude.Nothing,
      $sel:stackSetName:StopStackSetOperation' :: Text
stackSetName = Text
pStackSetName_,
      $sel:operationId:StopStackSetOperation' :: Text
operationId = Text
pOperationId_
    }

-- | [Service-managed permissions] Specifies whether you are acting as an
-- account administrator in the organization\'s management account or as a
-- delegated administrator in a member account.
--
-- By default, @SELF@ is specified. Use @SELF@ for stack sets with
-- self-managed permissions.
--
-- -   If you are signed in to the management account, specify @SELF@.
--
-- -   If you are signed in to a delegated administrator account, specify
--     @DELEGATED_ADMIN@.
--
--     Your Amazon Web Services account must be registered as a delegated
--     administrator in the management account. For more information, see
--     <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-orgs-delegated-admin.html Register a delegated administrator>
--     in the /CloudFormation User Guide/.
stopStackSetOperation_callAs :: Lens.Lens' StopStackSetOperation (Prelude.Maybe CallAs)
stopStackSetOperation_callAs :: (Maybe CallAs -> f (Maybe CallAs))
-> StopStackSetOperation -> f StopStackSetOperation
stopStackSetOperation_callAs = (StopStackSetOperation -> Maybe CallAs)
-> (StopStackSetOperation -> Maybe CallAs -> StopStackSetOperation)
-> Lens
     StopStackSetOperation
     StopStackSetOperation
     (Maybe CallAs)
     (Maybe CallAs)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopStackSetOperation' {Maybe CallAs
callAs :: Maybe CallAs
$sel:callAs:StopStackSetOperation' :: StopStackSetOperation -> Maybe CallAs
callAs} -> Maybe CallAs
callAs) (\s :: StopStackSetOperation
s@StopStackSetOperation' {} Maybe CallAs
a -> StopStackSetOperation
s {$sel:callAs:StopStackSetOperation' :: Maybe CallAs
callAs = Maybe CallAs
a} :: StopStackSetOperation)

-- | The name or unique ID of the stack set that you want to stop the
-- operation for.
stopStackSetOperation_stackSetName :: Lens.Lens' StopStackSetOperation Prelude.Text
stopStackSetOperation_stackSetName :: (Text -> f Text)
-> StopStackSetOperation -> f StopStackSetOperation
stopStackSetOperation_stackSetName = (StopStackSetOperation -> Text)
-> (StopStackSetOperation -> Text -> StopStackSetOperation)
-> Lens StopStackSetOperation StopStackSetOperation Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopStackSetOperation' {Text
stackSetName :: Text
$sel:stackSetName:StopStackSetOperation' :: StopStackSetOperation -> Text
stackSetName} -> Text
stackSetName) (\s :: StopStackSetOperation
s@StopStackSetOperation' {} Text
a -> StopStackSetOperation
s {$sel:stackSetName:StopStackSetOperation' :: Text
stackSetName = Text
a} :: StopStackSetOperation)

-- | The ID of the stack operation.
stopStackSetOperation_operationId :: Lens.Lens' StopStackSetOperation Prelude.Text
stopStackSetOperation_operationId :: (Text -> f Text)
-> StopStackSetOperation -> f StopStackSetOperation
stopStackSetOperation_operationId = (StopStackSetOperation -> Text)
-> (StopStackSetOperation -> Text -> StopStackSetOperation)
-> Lens StopStackSetOperation StopStackSetOperation Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopStackSetOperation' {Text
operationId :: Text
$sel:operationId:StopStackSetOperation' :: StopStackSetOperation -> Text
operationId} -> Text
operationId) (\s :: StopStackSetOperation
s@StopStackSetOperation' {} Text
a -> StopStackSetOperation
s {$sel:operationId:StopStackSetOperation' :: Text
operationId = Text
a} :: StopStackSetOperation)

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

instance Prelude.NFData StopStackSetOperation

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

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

instance Core.ToQuery StopStackSetOperation where
  toQuery :: StopStackSetOperation -> QueryString
toQuery StopStackSetOperation' {Maybe CallAs
Text
operationId :: Text
stackSetName :: Text
callAs :: Maybe CallAs
$sel:operationId:StopStackSetOperation' :: StopStackSetOperation -> Text
$sel:stackSetName:StopStackSetOperation' :: StopStackSetOperation -> Text
$sel:callAs:StopStackSetOperation' :: StopStackSetOperation -> Maybe CallAs
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"StopStackSetOperation" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-05-15" :: Prelude.ByteString),
        ByteString
"CallAs" ByteString -> Maybe CallAs -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe CallAs
callAs,
        ByteString
"StackSetName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
stackSetName,
        ByteString
"OperationId" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
operationId
      ]

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

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

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

instance Prelude.NFData StopStackSetOperationResponse