{-# 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.OpsWorks.DescribeStackSummary
-- 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)
--
-- Describes the number of layers and apps in a specified stack, and the
-- number of instances in each state, such as @running_setup@ or @online@.
--
-- __Required Permissions__: To use this action, an IAM user must have a
-- Show, Deploy, or Manage permissions level for the stack, or an attached
-- policy that explicitly grants permissions. For more information about
-- user permissions, see
-- <https://docs.aws.amazon.com/opsworks/latest/userguide/opsworks-security-users.html Managing User Permissions>.
module Amazonka.OpsWorks.DescribeStackSummary
  ( -- * Creating a Request
    DescribeStackSummary (..),
    newDescribeStackSummary,

    -- * Request Lenses
    describeStackSummary_stackId,

    -- * Destructuring the Response
    DescribeStackSummaryResponse (..),
    newDescribeStackSummaryResponse,

    -- * Response Lenses
    describeStackSummaryResponse_stackSummary,
    describeStackSummaryResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.OpsWorks.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDescribeStackSummary' smart constructor.
data DescribeStackSummary = DescribeStackSummary'
  { -- | The stack ID.
    DescribeStackSummary -> Text
stackId :: Prelude.Text
  }
  deriving (DescribeStackSummary -> DescribeStackSummary -> Bool
(DescribeStackSummary -> DescribeStackSummary -> Bool)
-> (DescribeStackSummary -> DescribeStackSummary -> Bool)
-> Eq DescribeStackSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeStackSummary -> DescribeStackSummary -> Bool
$c/= :: DescribeStackSummary -> DescribeStackSummary -> Bool
== :: DescribeStackSummary -> DescribeStackSummary -> Bool
$c== :: DescribeStackSummary -> DescribeStackSummary -> Bool
Prelude.Eq, ReadPrec [DescribeStackSummary]
ReadPrec DescribeStackSummary
Int -> ReadS DescribeStackSummary
ReadS [DescribeStackSummary]
(Int -> ReadS DescribeStackSummary)
-> ReadS [DescribeStackSummary]
-> ReadPrec DescribeStackSummary
-> ReadPrec [DescribeStackSummary]
-> Read DescribeStackSummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeStackSummary]
$creadListPrec :: ReadPrec [DescribeStackSummary]
readPrec :: ReadPrec DescribeStackSummary
$creadPrec :: ReadPrec DescribeStackSummary
readList :: ReadS [DescribeStackSummary]
$creadList :: ReadS [DescribeStackSummary]
readsPrec :: Int -> ReadS DescribeStackSummary
$creadsPrec :: Int -> ReadS DescribeStackSummary
Prelude.Read, Int -> DescribeStackSummary -> ShowS
[DescribeStackSummary] -> ShowS
DescribeStackSummary -> String
(Int -> DescribeStackSummary -> ShowS)
-> (DescribeStackSummary -> String)
-> ([DescribeStackSummary] -> ShowS)
-> Show DescribeStackSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeStackSummary] -> ShowS
$cshowList :: [DescribeStackSummary] -> ShowS
show :: DescribeStackSummary -> String
$cshow :: DescribeStackSummary -> String
showsPrec :: Int -> DescribeStackSummary -> ShowS
$cshowsPrec :: Int -> DescribeStackSummary -> ShowS
Prelude.Show, (forall x. DescribeStackSummary -> Rep DescribeStackSummary x)
-> (forall x. Rep DescribeStackSummary x -> DescribeStackSummary)
-> Generic DescribeStackSummary
forall x. Rep DescribeStackSummary x -> DescribeStackSummary
forall x. DescribeStackSummary -> Rep DescribeStackSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeStackSummary x -> DescribeStackSummary
$cfrom :: forall x. DescribeStackSummary -> Rep DescribeStackSummary x
Prelude.Generic)

-- |
-- Create a value of 'DescribeStackSummary' 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:
--
-- 'stackId', 'describeStackSummary_stackId' - The stack ID.
newDescribeStackSummary ::
  -- | 'stackId'
  Prelude.Text ->
  DescribeStackSummary
newDescribeStackSummary :: Text -> DescribeStackSummary
newDescribeStackSummary Text
pStackId_ =
  DescribeStackSummary' :: Text -> DescribeStackSummary
DescribeStackSummary' {$sel:stackId:DescribeStackSummary' :: Text
stackId = Text
pStackId_}

-- | The stack ID.
describeStackSummary_stackId :: Lens.Lens' DescribeStackSummary Prelude.Text
describeStackSummary_stackId :: (Text -> f Text) -> DescribeStackSummary -> f DescribeStackSummary
describeStackSummary_stackId = (DescribeStackSummary -> Text)
-> (DescribeStackSummary -> Text -> DescribeStackSummary)
-> Lens DescribeStackSummary DescribeStackSummary Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeStackSummary' {Text
stackId :: Text
$sel:stackId:DescribeStackSummary' :: DescribeStackSummary -> Text
stackId} -> Text
stackId) (\s :: DescribeStackSummary
s@DescribeStackSummary' {} Text
a -> DescribeStackSummary
s {$sel:stackId:DescribeStackSummary' :: Text
stackId = Text
a} :: DescribeStackSummary)

instance Core.AWSRequest DescribeStackSummary where
  type
    AWSResponse DescribeStackSummary =
      DescribeStackSummaryResponse
  request :: DescribeStackSummary -> Request DescribeStackSummary
request = Service -> DescribeStackSummary -> Request DescribeStackSummary
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeStackSummary
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeStackSummary)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeStackSummary))
-> Logger
-> Service
-> Proxy DescribeStackSummary
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeStackSummary)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe StackSummary -> Int -> DescribeStackSummaryResponse
DescribeStackSummaryResponse'
            (Maybe StackSummary -> Int -> DescribeStackSummaryResponse)
-> Either String (Maybe StackSummary)
-> Either String (Int -> DescribeStackSummaryResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe StackSummary)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"StackSummary")
            Either String (Int -> DescribeStackSummaryResponse)
-> Either String Int -> Either String DescribeStackSummaryResponse
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 DescribeStackSummary

instance Prelude.NFData DescribeStackSummary

instance Core.ToHeaders DescribeStackSummary where
  toHeaders :: DescribeStackSummary -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeStackSummary -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"OpsWorks_20130218.DescribeStackSummary" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON DescribeStackSummary where
  toJSON :: DescribeStackSummary -> Value
toJSON DescribeStackSummary' {Text
stackId :: Text
$sel:stackId:DescribeStackSummary' :: DescribeStackSummary -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"StackId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
stackId)]
      )

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

instance Core.ToQuery DescribeStackSummary where
  toQuery :: DescribeStackSummary -> QueryString
toQuery = QueryString -> DescribeStackSummary -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | Contains the response to a @DescribeStackSummary@ request.
--
-- /See:/ 'newDescribeStackSummaryResponse' smart constructor.
data DescribeStackSummaryResponse = DescribeStackSummaryResponse'
  { -- | A @StackSummary@ object that contains the results.
    DescribeStackSummaryResponse -> Maybe StackSummary
stackSummary :: Prelude.Maybe StackSummary,
    -- | The response's http status code.
    DescribeStackSummaryResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeStackSummaryResponse
-> DescribeStackSummaryResponse -> Bool
(DescribeStackSummaryResponse
 -> DescribeStackSummaryResponse -> Bool)
-> (DescribeStackSummaryResponse
    -> DescribeStackSummaryResponse -> Bool)
-> Eq DescribeStackSummaryResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeStackSummaryResponse
-> DescribeStackSummaryResponse -> Bool
$c/= :: DescribeStackSummaryResponse
-> DescribeStackSummaryResponse -> Bool
== :: DescribeStackSummaryResponse
-> DescribeStackSummaryResponse -> Bool
$c== :: DescribeStackSummaryResponse
-> DescribeStackSummaryResponse -> Bool
Prelude.Eq, ReadPrec [DescribeStackSummaryResponse]
ReadPrec DescribeStackSummaryResponse
Int -> ReadS DescribeStackSummaryResponse
ReadS [DescribeStackSummaryResponse]
(Int -> ReadS DescribeStackSummaryResponse)
-> ReadS [DescribeStackSummaryResponse]
-> ReadPrec DescribeStackSummaryResponse
-> ReadPrec [DescribeStackSummaryResponse]
-> Read DescribeStackSummaryResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeStackSummaryResponse]
$creadListPrec :: ReadPrec [DescribeStackSummaryResponse]
readPrec :: ReadPrec DescribeStackSummaryResponse
$creadPrec :: ReadPrec DescribeStackSummaryResponse
readList :: ReadS [DescribeStackSummaryResponse]
$creadList :: ReadS [DescribeStackSummaryResponse]
readsPrec :: Int -> ReadS DescribeStackSummaryResponse
$creadsPrec :: Int -> ReadS DescribeStackSummaryResponse
Prelude.Read, Int -> DescribeStackSummaryResponse -> ShowS
[DescribeStackSummaryResponse] -> ShowS
DescribeStackSummaryResponse -> String
(Int -> DescribeStackSummaryResponse -> ShowS)
-> (DescribeStackSummaryResponse -> String)
-> ([DescribeStackSummaryResponse] -> ShowS)
-> Show DescribeStackSummaryResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeStackSummaryResponse] -> ShowS
$cshowList :: [DescribeStackSummaryResponse] -> ShowS
show :: DescribeStackSummaryResponse -> String
$cshow :: DescribeStackSummaryResponse -> String
showsPrec :: Int -> DescribeStackSummaryResponse -> ShowS
$cshowsPrec :: Int -> DescribeStackSummaryResponse -> ShowS
Prelude.Show, (forall x.
 DescribeStackSummaryResponse -> Rep DescribeStackSummaryResponse x)
-> (forall x.
    Rep DescribeStackSummaryResponse x -> DescribeStackSummaryResponse)
-> Generic DescribeStackSummaryResponse
forall x.
Rep DescribeStackSummaryResponse x -> DescribeStackSummaryResponse
forall x.
DescribeStackSummaryResponse -> Rep DescribeStackSummaryResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeStackSummaryResponse x -> DescribeStackSummaryResponse
$cfrom :: forall x.
DescribeStackSummaryResponse -> Rep DescribeStackSummaryResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeStackSummaryResponse' 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:
--
-- 'stackSummary', 'describeStackSummaryResponse_stackSummary' - A @StackSummary@ object that contains the results.
--
-- 'httpStatus', 'describeStackSummaryResponse_httpStatus' - The response's http status code.
newDescribeStackSummaryResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeStackSummaryResponse
newDescribeStackSummaryResponse :: Int -> DescribeStackSummaryResponse
newDescribeStackSummaryResponse Int
pHttpStatus_ =
  DescribeStackSummaryResponse' :: Maybe StackSummary -> Int -> DescribeStackSummaryResponse
DescribeStackSummaryResponse'
    { $sel:stackSummary:DescribeStackSummaryResponse' :: Maybe StackSummary
stackSummary =
        Maybe StackSummary
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeStackSummaryResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A @StackSummary@ object that contains the results.
describeStackSummaryResponse_stackSummary :: Lens.Lens' DescribeStackSummaryResponse (Prelude.Maybe StackSummary)
describeStackSummaryResponse_stackSummary :: (Maybe StackSummary -> f (Maybe StackSummary))
-> DescribeStackSummaryResponse -> f DescribeStackSummaryResponse
describeStackSummaryResponse_stackSummary = (DescribeStackSummaryResponse -> Maybe StackSummary)
-> (DescribeStackSummaryResponse
    -> Maybe StackSummary -> DescribeStackSummaryResponse)
-> Lens
     DescribeStackSummaryResponse
     DescribeStackSummaryResponse
     (Maybe StackSummary)
     (Maybe StackSummary)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeStackSummaryResponse' {Maybe StackSummary
stackSummary :: Maybe StackSummary
$sel:stackSummary:DescribeStackSummaryResponse' :: DescribeStackSummaryResponse -> Maybe StackSummary
stackSummary} -> Maybe StackSummary
stackSummary) (\s :: DescribeStackSummaryResponse
s@DescribeStackSummaryResponse' {} Maybe StackSummary
a -> DescribeStackSummaryResponse
s {$sel:stackSummary:DescribeStackSummaryResponse' :: Maybe StackSummary
stackSummary = Maybe StackSummary
a} :: DescribeStackSummaryResponse)

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

instance Prelude.NFData DescribeStackSummaryResponse