{-# 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.DescribeStackResource
-- 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 a description of the specified resource in the specified stack.
--
-- For deleted stacks, DescribeStackResource returns resource information
-- for up to 90 days after the stack has been deleted.
module Amazonka.CloudFormation.DescribeStackResource
  ( -- * Creating a Request
    DescribeStackResource (..),
    newDescribeStackResource,

    -- * Request Lenses
    describeStackResource_stackName,
    describeStackResource_logicalResourceId,

    -- * Destructuring the Response
    DescribeStackResourceResponse (..),
    newDescribeStackResourceResponse,

    -- * Response Lenses
    describeStackResourceResponse_stackResourceDetail,
    describeStackResourceResponse_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

-- | The input for DescribeStackResource action.
--
-- /See:/ 'newDescribeStackResource' smart constructor.
data DescribeStackResource = DescribeStackResource'
  { -- | The name or the unique stack ID that is associated with the stack, which
    -- are not always interchangeable:
    --
    -- -   Running stacks: You can specify either the stack\'s name or its
    --     unique stack ID.
    --
    -- -   Deleted stacks: You must specify the unique stack ID.
    --
    -- Default: There is no default value.
    DescribeStackResource -> Text
stackName :: Prelude.Text,
    -- | The logical name of the resource as specified in the template.
    --
    -- Default: There is no default value.
    DescribeStackResource -> Text
logicalResourceId :: Prelude.Text
  }
  deriving (DescribeStackResource -> DescribeStackResource -> Bool
(DescribeStackResource -> DescribeStackResource -> Bool)
-> (DescribeStackResource -> DescribeStackResource -> Bool)
-> Eq DescribeStackResource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeStackResource -> DescribeStackResource -> Bool
$c/= :: DescribeStackResource -> DescribeStackResource -> Bool
== :: DescribeStackResource -> DescribeStackResource -> Bool
$c== :: DescribeStackResource -> DescribeStackResource -> Bool
Prelude.Eq, ReadPrec [DescribeStackResource]
ReadPrec DescribeStackResource
Int -> ReadS DescribeStackResource
ReadS [DescribeStackResource]
(Int -> ReadS DescribeStackResource)
-> ReadS [DescribeStackResource]
-> ReadPrec DescribeStackResource
-> ReadPrec [DescribeStackResource]
-> Read DescribeStackResource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeStackResource]
$creadListPrec :: ReadPrec [DescribeStackResource]
readPrec :: ReadPrec DescribeStackResource
$creadPrec :: ReadPrec DescribeStackResource
readList :: ReadS [DescribeStackResource]
$creadList :: ReadS [DescribeStackResource]
readsPrec :: Int -> ReadS DescribeStackResource
$creadsPrec :: Int -> ReadS DescribeStackResource
Prelude.Read, Int -> DescribeStackResource -> ShowS
[DescribeStackResource] -> ShowS
DescribeStackResource -> String
(Int -> DescribeStackResource -> ShowS)
-> (DescribeStackResource -> String)
-> ([DescribeStackResource] -> ShowS)
-> Show DescribeStackResource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeStackResource] -> ShowS
$cshowList :: [DescribeStackResource] -> ShowS
show :: DescribeStackResource -> String
$cshow :: DescribeStackResource -> String
showsPrec :: Int -> DescribeStackResource -> ShowS
$cshowsPrec :: Int -> DescribeStackResource -> ShowS
Prelude.Show, (forall x. DescribeStackResource -> Rep DescribeStackResource x)
-> (forall x. Rep DescribeStackResource x -> DescribeStackResource)
-> Generic DescribeStackResource
forall x. Rep DescribeStackResource x -> DescribeStackResource
forall x. DescribeStackResource -> Rep DescribeStackResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeStackResource x -> DescribeStackResource
$cfrom :: forall x. DescribeStackResource -> Rep DescribeStackResource x
Prelude.Generic)

-- |
-- Create a value of 'DescribeStackResource' 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:
--
-- 'stackName', 'describeStackResource_stackName' - The name or the unique stack ID that is associated with the stack, which
-- are not always interchangeable:
--
-- -   Running stacks: You can specify either the stack\'s name or its
--     unique stack ID.
--
-- -   Deleted stacks: You must specify the unique stack ID.
--
-- Default: There is no default value.
--
-- 'logicalResourceId', 'describeStackResource_logicalResourceId' - The logical name of the resource as specified in the template.
--
-- Default: There is no default value.
newDescribeStackResource ::
  -- | 'stackName'
  Prelude.Text ->
  -- | 'logicalResourceId'
  Prelude.Text ->
  DescribeStackResource
newDescribeStackResource :: Text -> Text -> DescribeStackResource
newDescribeStackResource
  Text
pStackName_
  Text
pLogicalResourceId_ =
    DescribeStackResource' :: Text -> Text -> DescribeStackResource
DescribeStackResource'
      { $sel:stackName:DescribeStackResource' :: Text
stackName = Text
pStackName_,
        $sel:logicalResourceId:DescribeStackResource' :: Text
logicalResourceId = Text
pLogicalResourceId_
      }

-- | The name or the unique stack ID that is associated with the stack, which
-- are not always interchangeable:
--
-- -   Running stacks: You can specify either the stack\'s name or its
--     unique stack ID.
--
-- -   Deleted stacks: You must specify the unique stack ID.
--
-- Default: There is no default value.
describeStackResource_stackName :: Lens.Lens' DescribeStackResource Prelude.Text
describeStackResource_stackName :: (Text -> f Text)
-> DescribeStackResource -> f DescribeStackResource
describeStackResource_stackName = (DescribeStackResource -> Text)
-> (DescribeStackResource -> Text -> DescribeStackResource)
-> Lens DescribeStackResource DescribeStackResource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeStackResource' {Text
stackName :: Text
$sel:stackName:DescribeStackResource' :: DescribeStackResource -> Text
stackName} -> Text
stackName) (\s :: DescribeStackResource
s@DescribeStackResource' {} Text
a -> DescribeStackResource
s {$sel:stackName:DescribeStackResource' :: Text
stackName = Text
a} :: DescribeStackResource)

-- | The logical name of the resource as specified in the template.
--
-- Default: There is no default value.
describeStackResource_logicalResourceId :: Lens.Lens' DescribeStackResource Prelude.Text
describeStackResource_logicalResourceId :: (Text -> f Text)
-> DescribeStackResource -> f DescribeStackResource
describeStackResource_logicalResourceId = (DescribeStackResource -> Text)
-> (DescribeStackResource -> Text -> DescribeStackResource)
-> Lens DescribeStackResource DescribeStackResource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeStackResource' {Text
logicalResourceId :: Text
$sel:logicalResourceId:DescribeStackResource' :: DescribeStackResource -> Text
logicalResourceId} -> Text
logicalResourceId) (\s :: DescribeStackResource
s@DescribeStackResource' {} Text
a -> DescribeStackResource
s {$sel:logicalResourceId:DescribeStackResource' :: Text
logicalResourceId = Text
a} :: DescribeStackResource)

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

instance Prelude.NFData DescribeStackResource

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

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

instance Core.ToQuery DescribeStackResource where
  toQuery :: DescribeStackResource -> QueryString
toQuery DescribeStackResource' {Text
logicalResourceId :: Text
stackName :: Text
$sel:logicalResourceId:DescribeStackResource' :: DescribeStackResource -> Text
$sel:stackName:DescribeStackResource' :: DescribeStackResource -> 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
"DescribeStackResource" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-05-15" :: Prelude.ByteString),
        ByteString
"StackName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
stackName,
        ByteString
"LogicalResourceId" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
logicalResourceId
      ]

-- | The output for a DescribeStackResource action.
--
-- /See:/ 'newDescribeStackResourceResponse' smart constructor.
data DescribeStackResourceResponse = DescribeStackResourceResponse'
  { -- | A @StackResourceDetail@ structure containing the description of the
    -- specified resource in the specified stack.
    DescribeStackResourceResponse -> Maybe StackResourceDetail
stackResourceDetail :: Prelude.Maybe StackResourceDetail,
    -- | The response's http status code.
    DescribeStackResourceResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeStackResourceResponse
-> DescribeStackResourceResponse -> Bool
(DescribeStackResourceResponse
 -> DescribeStackResourceResponse -> Bool)
-> (DescribeStackResourceResponse
    -> DescribeStackResourceResponse -> Bool)
-> Eq DescribeStackResourceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeStackResourceResponse
-> DescribeStackResourceResponse -> Bool
$c/= :: DescribeStackResourceResponse
-> DescribeStackResourceResponse -> Bool
== :: DescribeStackResourceResponse
-> DescribeStackResourceResponse -> Bool
$c== :: DescribeStackResourceResponse
-> DescribeStackResourceResponse -> Bool
Prelude.Eq, ReadPrec [DescribeStackResourceResponse]
ReadPrec DescribeStackResourceResponse
Int -> ReadS DescribeStackResourceResponse
ReadS [DescribeStackResourceResponse]
(Int -> ReadS DescribeStackResourceResponse)
-> ReadS [DescribeStackResourceResponse]
-> ReadPrec DescribeStackResourceResponse
-> ReadPrec [DescribeStackResourceResponse]
-> Read DescribeStackResourceResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeStackResourceResponse]
$creadListPrec :: ReadPrec [DescribeStackResourceResponse]
readPrec :: ReadPrec DescribeStackResourceResponse
$creadPrec :: ReadPrec DescribeStackResourceResponse
readList :: ReadS [DescribeStackResourceResponse]
$creadList :: ReadS [DescribeStackResourceResponse]
readsPrec :: Int -> ReadS DescribeStackResourceResponse
$creadsPrec :: Int -> ReadS DescribeStackResourceResponse
Prelude.Read, Int -> DescribeStackResourceResponse -> ShowS
[DescribeStackResourceResponse] -> ShowS
DescribeStackResourceResponse -> String
(Int -> DescribeStackResourceResponse -> ShowS)
-> (DescribeStackResourceResponse -> String)
-> ([DescribeStackResourceResponse] -> ShowS)
-> Show DescribeStackResourceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeStackResourceResponse] -> ShowS
$cshowList :: [DescribeStackResourceResponse] -> ShowS
show :: DescribeStackResourceResponse -> String
$cshow :: DescribeStackResourceResponse -> String
showsPrec :: Int -> DescribeStackResourceResponse -> ShowS
$cshowsPrec :: Int -> DescribeStackResourceResponse -> ShowS
Prelude.Show, (forall x.
 DescribeStackResourceResponse
 -> Rep DescribeStackResourceResponse x)
-> (forall x.
    Rep DescribeStackResourceResponse x
    -> DescribeStackResourceResponse)
-> Generic DescribeStackResourceResponse
forall x.
Rep DescribeStackResourceResponse x
-> DescribeStackResourceResponse
forall x.
DescribeStackResourceResponse
-> Rep DescribeStackResourceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeStackResourceResponse x
-> DescribeStackResourceResponse
$cfrom :: forall x.
DescribeStackResourceResponse
-> Rep DescribeStackResourceResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeStackResourceResponse' 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:
--
-- 'stackResourceDetail', 'describeStackResourceResponse_stackResourceDetail' - A @StackResourceDetail@ structure containing the description of the
-- specified resource in the specified stack.
--
-- 'httpStatus', 'describeStackResourceResponse_httpStatus' - The response's http status code.
newDescribeStackResourceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeStackResourceResponse
newDescribeStackResourceResponse :: Int -> DescribeStackResourceResponse
newDescribeStackResourceResponse Int
pHttpStatus_ =
  DescribeStackResourceResponse' :: Maybe StackResourceDetail -> Int -> DescribeStackResourceResponse
DescribeStackResourceResponse'
    { $sel:stackResourceDetail:DescribeStackResourceResponse' :: Maybe StackResourceDetail
stackResourceDetail =
        Maybe StackResourceDetail
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeStackResourceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A @StackResourceDetail@ structure containing the description of the
-- specified resource in the specified stack.
describeStackResourceResponse_stackResourceDetail :: Lens.Lens' DescribeStackResourceResponse (Prelude.Maybe StackResourceDetail)
describeStackResourceResponse_stackResourceDetail :: (Maybe StackResourceDetail -> f (Maybe StackResourceDetail))
-> DescribeStackResourceResponse -> f DescribeStackResourceResponse
describeStackResourceResponse_stackResourceDetail = (DescribeStackResourceResponse -> Maybe StackResourceDetail)
-> (DescribeStackResourceResponse
    -> Maybe StackResourceDetail -> DescribeStackResourceResponse)
-> Lens
     DescribeStackResourceResponse
     DescribeStackResourceResponse
     (Maybe StackResourceDetail)
     (Maybe StackResourceDetail)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeStackResourceResponse' {Maybe StackResourceDetail
stackResourceDetail :: Maybe StackResourceDetail
$sel:stackResourceDetail:DescribeStackResourceResponse' :: DescribeStackResourceResponse -> Maybe StackResourceDetail
stackResourceDetail} -> Maybe StackResourceDetail
stackResourceDetail) (\s :: DescribeStackResourceResponse
s@DescribeStackResourceResponse' {} Maybe StackResourceDetail
a -> DescribeStackResourceResponse
s {$sel:stackResourceDetail:DescribeStackResourceResponse' :: Maybe StackResourceDetail
stackResourceDetail = Maybe StackResourceDetail
a} :: DescribeStackResourceResponse)

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

instance Prelude.NFData DescribeStackResourceResponse