{-# 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.DescribeStackSet
-- 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)
--
-- Returns the description of the specified stack set.
module Amazonka.CloudFormation.DescribeStackSet
  ( -- * Creating a Request
    DescribeStackSet (..),
    newDescribeStackSet,

    -- * Request Lenses
    describeStackSet_callAs,
    describeStackSet_stackSetName,

    -- * Destructuring the Response
    DescribeStackSetResponse (..),
    newDescribeStackSetResponse,

    -- * Response Lenses
    describeStackSetResponse_stackSet,
    describeStackSetResponse_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:/ 'newDescribeStackSet' smart constructor.
data DescribeStackSet = DescribeStackSet'
  { -- | [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/.
    DescribeStackSet -> Maybe CallAs
callAs :: Prelude.Maybe CallAs,
    -- | The name or unique ID of the stack set whose description you want.
    DescribeStackSet -> Text
stackSetName :: Prelude.Text
  }
  deriving (DescribeStackSet -> DescribeStackSet -> Bool
(DescribeStackSet -> DescribeStackSet -> Bool)
-> (DescribeStackSet -> DescribeStackSet -> Bool)
-> Eq DescribeStackSet
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeStackSet -> DescribeStackSet -> Bool
$c/= :: DescribeStackSet -> DescribeStackSet -> Bool
== :: DescribeStackSet -> DescribeStackSet -> Bool
$c== :: DescribeStackSet -> DescribeStackSet -> Bool
Prelude.Eq, ReadPrec [DescribeStackSet]
ReadPrec DescribeStackSet
Int -> ReadS DescribeStackSet
ReadS [DescribeStackSet]
(Int -> ReadS DescribeStackSet)
-> ReadS [DescribeStackSet]
-> ReadPrec DescribeStackSet
-> ReadPrec [DescribeStackSet]
-> Read DescribeStackSet
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeStackSet]
$creadListPrec :: ReadPrec [DescribeStackSet]
readPrec :: ReadPrec DescribeStackSet
$creadPrec :: ReadPrec DescribeStackSet
readList :: ReadS [DescribeStackSet]
$creadList :: ReadS [DescribeStackSet]
readsPrec :: Int -> ReadS DescribeStackSet
$creadsPrec :: Int -> ReadS DescribeStackSet
Prelude.Read, Int -> DescribeStackSet -> ShowS
[DescribeStackSet] -> ShowS
DescribeStackSet -> String
(Int -> DescribeStackSet -> ShowS)
-> (DescribeStackSet -> String)
-> ([DescribeStackSet] -> ShowS)
-> Show DescribeStackSet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeStackSet] -> ShowS
$cshowList :: [DescribeStackSet] -> ShowS
show :: DescribeStackSet -> String
$cshow :: DescribeStackSet -> String
showsPrec :: Int -> DescribeStackSet -> ShowS
$cshowsPrec :: Int -> DescribeStackSet -> ShowS
Prelude.Show, (forall x. DescribeStackSet -> Rep DescribeStackSet x)
-> (forall x. Rep DescribeStackSet x -> DescribeStackSet)
-> Generic DescribeStackSet
forall x. Rep DescribeStackSet x -> DescribeStackSet
forall x. DescribeStackSet -> Rep DescribeStackSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeStackSet x -> DescribeStackSet
$cfrom :: forall x. DescribeStackSet -> Rep DescribeStackSet x
Prelude.Generic)

-- |
-- Create a value of 'DescribeStackSet' 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', 'describeStackSet_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', 'describeStackSet_stackSetName' - The name or unique ID of the stack set whose description you want.
newDescribeStackSet ::
  -- | 'stackSetName'
  Prelude.Text ->
  DescribeStackSet
newDescribeStackSet :: Text -> DescribeStackSet
newDescribeStackSet Text
pStackSetName_ =
  DescribeStackSet' :: Maybe CallAs -> Text -> DescribeStackSet
DescribeStackSet'
    { $sel:callAs:DescribeStackSet' :: Maybe CallAs
callAs = Maybe CallAs
forall a. Maybe a
Prelude.Nothing,
      $sel:stackSetName:DescribeStackSet' :: Text
stackSetName = Text
pStackSetName_
    }

-- | [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/.
describeStackSet_callAs :: Lens.Lens' DescribeStackSet (Prelude.Maybe CallAs)
describeStackSet_callAs :: (Maybe CallAs -> f (Maybe CallAs))
-> DescribeStackSet -> f DescribeStackSet
describeStackSet_callAs = (DescribeStackSet -> Maybe CallAs)
-> (DescribeStackSet -> Maybe CallAs -> DescribeStackSet)
-> Lens
     DescribeStackSet DescribeStackSet (Maybe CallAs) (Maybe CallAs)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeStackSet' {Maybe CallAs
callAs :: Maybe CallAs
$sel:callAs:DescribeStackSet' :: DescribeStackSet -> Maybe CallAs
callAs} -> Maybe CallAs
callAs) (\s :: DescribeStackSet
s@DescribeStackSet' {} Maybe CallAs
a -> DescribeStackSet
s {$sel:callAs:DescribeStackSet' :: Maybe CallAs
callAs = Maybe CallAs
a} :: DescribeStackSet)

-- | The name or unique ID of the stack set whose description you want.
describeStackSet_stackSetName :: Lens.Lens' DescribeStackSet Prelude.Text
describeStackSet_stackSetName :: (Text -> f Text) -> DescribeStackSet -> f DescribeStackSet
describeStackSet_stackSetName = (DescribeStackSet -> Text)
-> (DescribeStackSet -> Text -> DescribeStackSet)
-> Lens DescribeStackSet DescribeStackSet Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeStackSet' {Text
stackSetName :: Text
$sel:stackSetName:DescribeStackSet' :: DescribeStackSet -> Text
stackSetName} -> Text
stackSetName) (\s :: DescribeStackSet
s@DescribeStackSet' {} Text
a -> DescribeStackSet
s {$sel:stackSetName:DescribeStackSet' :: Text
stackSetName = Text
a} :: DescribeStackSet)

instance Core.AWSRequest DescribeStackSet where
  type
    AWSResponse DescribeStackSet =
      DescribeStackSetResponse
  request :: DescribeStackSet -> Request DescribeStackSet
request = Service -> DescribeStackSet -> Request DescribeStackSet
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeStackSet
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeStackSet)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse DescribeStackSet))
-> Logger
-> Service
-> Proxy DescribeStackSet
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeStackSet)))
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
"DescribeStackSetResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe StackSet -> Int -> DescribeStackSetResponse
DescribeStackSetResponse'
            (Maybe StackSet -> Int -> DescribeStackSetResponse)
-> Either String (Maybe StackSet)
-> Either String (Int -> DescribeStackSetResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe StackSet)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"StackSet")
            Either String (Int -> DescribeStackSetResponse)
-> Either String Int -> Either String DescribeStackSetResponse
forall (f :: * -> *) a b. Applicative f => 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 DescribeStackSet

instance Prelude.NFData DescribeStackSet

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

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

instance Core.ToQuery DescribeStackSet where
  toQuery :: DescribeStackSet -> QueryString
toQuery DescribeStackSet' {Maybe CallAs
Text
stackSetName :: Text
callAs :: Maybe CallAs
$sel:stackSetName:DescribeStackSet' :: DescribeStackSet -> Text
$sel:callAs:DescribeStackSet' :: DescribeStackSet -> 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
"DescribeStackSet" :: 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
      ]

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

-- |
-- Create a value of 'DescribeStackSetResponse' 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:
--
-- 'stackSet', 'describeStackSetResponse_stackSet' - The specified stack set.
--
-- 'httpStatus', 'describeStackSetResponse_httpStatus' - The response's http status code.
newDescribeStackSetResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeStackSetResponse
newDescribeStackSetResponse :: Int -> DescribeStackSetResponse
newDescribeStackSetResponse Int
pHttpStatus_ =
  DescribeStackSetResponse' :: Maybe StackSet -> Int -> DescribeStackSetResponse
DescribeStackSetResponse'
    { $sel:stackSet:DescribeStackSetResponse' :: Maybe StackSet
stackSet =
        Maybe StackSet
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeStackSetResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The specified stack set.
describeStackSetResponse_stackSet :: Lens.Lens' DescribeStackSetResponse (Prelude.Maybe StackSet)
describeStackSetResponse_stackSet :: (Maybe StackSet -> f (Maybe StackSet))
-> DescribeStackSetResponse -> f DescribeStackSetResponse
describeStackSetResponse_stackSet = (DescribeStackSetResponse -> Maybe StackSet)
-> (DescribeStackSetResponse
    -> Maybe StackSet -> DescribeStackSetResponse)
-> Lens
     DescribeStackSetResponse
     DescribeStackSetResponse
     (Maybe StackSet)
     (Maybe StackSet)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeStackSetResponse' {Maybe StackSet
stackSet :: Maybe StackSet
$sel:stackSet:DescribeStackSetResponse' :: DescribeStackSetResponse -> Maybe StackSet
stackSet} -> Maybe StackSet
stackSet) (\s :: DescribeStackSetResponse
s@DescribeStackSetResponse' {} Maybe StackSet
a -> DescribeStackSetResponse
s {$sel:stackSet:DescribeStackSetResponse' :: Maybe StackSet
stackSet = Maybe StackSet
a} :: DescribeStackSetResponse)

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

instance Prelude.NFData DescribeStackSetResponse