{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.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 DescribeStackResource action.
--
-- /See:/ 'newDescribeStackResource' smart constructor.
data DescribeStackResource = DescribeStackResource'
  { -- | The name or the unique stack ID that\'s associated with the stack, which
    -- aren\'t 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
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]
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
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. 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\'s associated with the stack, which
-- aren\'t 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'
      { $sel:stackName:DescribeStackResource' :: Text
stackName = Text
pStackName_,
        $sel:logicalResourceId:DescribeStackResource' :: Text
logicalResourceId = Text
pLogicalResourceId_
      }

-- | The name or the unique stack ID that\'s associated with the stack, which
-- aren\'t 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 :: Lens' DescribeStackResource Text
describeStackResource_stackName = 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 :: Lens' DescribeStackResource Text
describeStackResource_logicalResourceId = 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 :: (Service -> Service)
-> DescribeStackResource -> Request DescribeStackResource
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 DescribeStackResource
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeStackResource)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> 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'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"StackResourceDetail")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DescribeStackResource where
  hashWithSalt :: Int -> DescribeStackResource -> Int
hashWithSalt Int
_salt DescribeStackResource' {Text
logicalResourceId :: Text
stackName :: Text
$sel:logicalResourceId:DescribeStackResource' :: DescribeStackResource -> Text
$sel:stackName:DescribeStackResource' :: DescribeStackResource -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
stackName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
logicalResourceId

instance Prelude.NFData DescribeStackResource where
  rnf :: DescribeStackResource -> ()
rnf DescribeStackResource' {Text
logicalResourceId :: Text
stackName :: Text
$sel:logicalResourceId:DescribeStackResource' :: DescribeStackResource -> Text
$sel:stackName:DescribeStackResource' :: DescribeStackResource -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
stackName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
logicalResourceId

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

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

instance Data.ToQuery DescribeStackResource where
  toQuery :: DescribeStackResource -> QueryString
toQuery DescribeStackResource' {Text
logicalResourceId :: Text
stackName :: Text
$sel:logicalResourceId:DescribeStackResource' :: DescribeStackResource -> Text
$sel:stackName:DescribeStackResource' :: DescribeStackResource -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"DescribeStackResource" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-05-15" :: Prelude.ByteString),
        ByteString
"StackName" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
stackName,
        ByteString
"LogicalResourceId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: 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
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]
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
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.
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'
    { $sel:stackResourceDetail:DescribeStackResourceResponse' :: Maybe StackResourceDetail
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 :: Lens' DescribeStackResourceResponse (Maybe StackResourceDetail)
describeStackResourceResponse_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 :: Lens' DescribeStackResourceResponse Int
describeStackResourceResponse_httpStatus = 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 where
  rnf :: DescribeStackResourceResponse -> ()
rnf DescribeStackResourceResponse' {Int
Maybe StackResourceDetail
httpStatus :: Int
stackResourceDetail :: Maybe StackResourceDetail
$sel:httpStatus:DescribeStackResourceResponse' :: DescribeStackResourceResponse -> Int
$sel:stackResourceDetail:DescribeStackResourceResponse' :: DescribeStackResourceResponse -> Maybe StackResourceDetail
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe StackResourceDetail
stackResourceDetail
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus