{-# 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.Kinesis.DescribeStreamSummary
-- 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)
--
-- Provides a summarized description of the specified Kinesis data stream
-- without the shard list.
--
-- The information returned includes the stream name, Amazon Resource Name
-- (ARN), status, record retention period, approximate creation time,
-- monitoring, encryption details, and open shard count.
--
-- DescribeStreamSummary has a limit of 20 transactions per second per
-- account.
module Amazonka.Kinesis.DescribeStreamSummary
  ( -- * Creating a Request
    DescribeStreamSummary (..),
    newDescribeStreamSummary,

    -- * Request Lenses
    describeStreamSummary_streamName,

    -- * Destructuring the Response
    DescribeStreamSummaryResponse (..),
    newDescribeStreamSummaryResponse,

    -- * Response Lenses
    describeStreamSummaryResponse_httpStatus,
    describeStreamSummaryResponse_streamDescriptionSummary,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.Kinesis.Types
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:/ 'newDescribeStreamSummary' smart constructor.
data DescribeStreamSummary = DescribeStreamSummary'
  { -- | The name of the stream to describe.
    DescribeStreamSummary -> Text
streamName :: Prelude.Text
  }
  deriving (DescribeStreamSummary -> DescribeStreamSummary -> Bool
(DescribeStreamSummary -> DescribeStreamSummary -> Bool)
-> (DescribeStreamSummary -> DescribeStreamSummary -> Bool)
-> Eq DescribeStreamSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeStreamSummary -> DescribeStreamSummary -> Bool
$c/= :: DescribeStreamSummary -> DescribeStreamSummary -> Bool
== :: DescribeStreamSummary -> DescribeStreamSummary -> Bool
$c== :: DescribeStreamSummary -> DescribeStreamSummary -> Bool
Prelude.Eq, ReadPrec [DescribeStreamSummary]
ReadPrec DescribeStreamSummary
Int -> ReadS DescribeStreamSummary
ReadS [DescribeStreamSummary]
(Int -> ReadS DescribeStreamSummary)
-> ReadS [DescribeStreamSummary]
-> ReadPrec DescribeStreamSummary
-> ReadPrec [DescribeStreamSummary]
-> Read DescribeStreamSummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeStreamSummary]
$creadListPrec :: ReadPrec [DescribeStreamSummary]
readPrec :: ReadPrec DescribeStreamSummary
$creadPrec :: ReadPrec DescribeStreamSummary
readList :: ReadS [DescribeStreamSummary]
$creadList :: ReadS [DescribeStreamSummary]
readsPrec :: Int -> ReadS DescribeStreamSummary
$creadsPrec :: Int -> ReadS DescribeStreamSummary
Prelude.Read, Int -> DescribeStreamSummary -> ShowS
[DescribeStreamSummary] -> ShowS
DescribeStreamSummary -> String
(Int -> DescribeStreamSummary -> ShowS)
-> (DescribeStreamSummary -> String)
-> ([DescribeStreamSummary] -> ShowS)
-> Show DescribeStreamSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeStreamSummary] -> ShowS
$cshowList :: [DescribeStreamSummary] -> ShowS
show :: DescribeStreamSummary -> String
$cshow :: DescribeStreamSummary -> String
showsPrec :: Int -> DescribeStreamSummary -> ShowS
$cshowsPrec :: Int -> DescribeStreamSummary -> ShowS
Prelude.Show, (forall x. DescribeStreamSummary -> Rep DescribeStreamSummary x)
-> (forall x. Rep DescribeStreamSummary x -> DescribeStreamSummary)
-> Generic DescribeStreamSummary
forall x. Rep DescribeStreamSummary x -> DescribeStreamSummary
forall x. DescribeStreamSummary -> Rep DescribeStreamSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeStreamSummary x -> DescribeStreamSummary
$cfrom :: forall x. DescribeStreamSummary -> Rep DescribeStreamSummary x
Prelude.Generic)

-- |
-- Create a value of 'DescribeStreamSummary' 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:
--
-- 'streamName', 'describeStreamSummary_streamName' - The name of the stream to describe.
newDescribeStreamSummary ::
  -- | 'streamName'
  Prelude.Text ->
  DescribeStreamSummary
newDescribeStreamSummary :: Text -> DescribeStreamSummary
newDescribeStreamSummary Text
pStreamName_ =
  DescribeStreamSummary' :: Text -> DescribeStreamSummary
DescribeStreamSummary' {$sel:streamName:DescribeStreamSummary' :: Text
streamName = Text
pStreamName_}

-- | The name of the stream to describe.
describeStreamSummary_streamName :: Lens.Lens' DescribeStreamSummary Prelude.Text
describeStreamSummary_streamName :: (Text -> f Text)
-> DescribeStreamSummary -> f DescribeStreamSummary
describeStreamSummary_streamName = (DescribeStreamSummary -> Text)
-> (DescribeStreamSummary -> Text -> DescribeStreamSummary)
-> Lens DescribeStreamSummary DescribeStreamSummary Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeStreamSummary' {Text
streamName :: Text
$sel:streamName:DescribeStreamSummary' :: DescribeStreamSummary -> Text
streamName} -> Text
streamName) (\s :: DescribeStreamSummary
s@DescribeStreamSummary' {} Text
a -> DescribeStreamSummary
s {$sel:streamName:DescribeStreamSummary' :: Text
streamName = Text
a} :: DescribeStreamSummary)

instance Core.AWSRequest DescribeStreamSummary where
  type
    AWSResponse DescribeStreamSummary =
      DescribeStreamSummaryResponse
  request :: DescribeStreamSummary -> Request DescribeStreamSummary
request = Service -> DescribeStreamSummary -> Request DescribeStreamSummary
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeStreamSummary
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeStreamSummary)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeStreamSummary))
-> Logger
-> Service
-> Proxy DescribeStreamSummary
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeStreamSummary)))
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 ->
          Int -> StreamDescriptionSummary -> DescribeStreamSummaryResponse
DescribeStreamSummaryResponse'
            (Int -> StreamDescriptionSummary -> DescribeStreamSummaryResponse)
-> Either String Int
-> Either
     String (StreamDescriptionSummary -> DescribeStreamSummaryResponse)
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))
            Either
  String (StreamDescriptionSummary -> DescribeStreamSummaryResponse)
-> Either String StreamDescriptionSummary
-> Either String DescribeStreamSummaryResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String StreamDescriptionSummary
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"StreamDescriptionSummary")
      )

instance Prelude.Hashable DescribeStreamSummary

instance Prelude.NFData DescribeStreamSummary

instance Core.ToHeaders DescribeStreamSummary where
  toHeaders :: DescribeStreamSummary -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeStreamSummary -> 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
"Kinesis_20131202.DescribeStreamSummary" ::
                          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 DescribeStreamSummary where
  toJSON :: DescribeStreamSummary -> Value
toJSON DescribeStreamSummary' {Text
streamName :: Text
$sel:streamName:DescribeStreamSummary' :: DescribeStreamSummary -> 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
"StreamName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
streamName)]
      )

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

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

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

-- |
-- Create a value of 'DescribeStreamSummaryResponse' 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', 'describeStreamSummaryResponse_httpStatus' - The response's http status code.
--
-- 'streamDescriptionSummary', 'describeStreamSummaryResponse_streamDescriptionSummary' - A StreamDescriptionSummary containing information about the stream.
newDescribeStreamSummaryResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'streamDescriptionSummary'
  StreamDescriptionSummary ->
  DescribeStreamSummaryResponse
newDescribeStreamSummaryResponse :: Int -> StreamDescriptionSummary -> DescribeStreamSummaryResponse
newDescribeStreamSummaryResponse
  Int
pHttpStatus_
  StreamDescriptionSummary
pStreamDescriptionSummary_ =
    DescribeStreamSummaryResponse' :: Int -> StreamDescriptionSummary -> DescribeStreamSummaryResponse
DescribeStreamSummaryResponse'
      { $sel:httpStatus:DescribeStreamSummaryResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:streamDescriptionSummary:DescribeStreamSummaryResponse' :: StreamDescriptionSummary
streamDescriptionSummary =
          StreamDescriptionSummary
pStreamDescriptionSummary_
      }

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

-- | A StreamDescriptionSummary containing information about the stream.
describeStreamSummaryResponse_streamDescriptionSummary :: Lens.Lens' DescribeStreamSummaryResponse StreamDescriptionSummary
describeStreamSummaryResponse_streamDescriptionSummary :: (StreamDescriptionSummary -> f StreamDescriptionSummary)
-> DescribeStreamSummaryResponse -> f DescribeStreamSummaryResponse
describeStreamSummaryResponse_streamDescriptionSummary = (DescribeStreamSummaryResponse -> StreamDescriptionSummary)
-> (DescribeStreamSummaryResponse
    -> StreamDescriptionSummary -> DescribeStreamSummaryResponse)
-> Lens
     DescribeStreamSummaryResponse
     DescribeStreamSummaryResponse
     StreamDescriptionSummary
     StreamDescriptionSummary
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeStreamSummaryResponse' {StreamDescriptionSummary
streamDescriptionSummary :: StreamDescriptionSummary
$sel:streamDescriptionSummary:DescribeStreamSummaryResponse' :: DescribeStreamSummaryResponse -> StreamDescriptionSummary
streamDescriptionSummary} -> StreamDescriptionSummary
streamDescriptionSummary) (\s :: DescribeStreamSummaryResponse
s@DescribeStreamSummaryResponse' {} StreamDescriptionSummary
a -> DescribeStreamSummaryResponse
s {$sel:streamDescriptionSummary:DescribeStreamSummaryResponse' :: StreamDescriptionSummary
streamDescriptionSummary = StreamDescriptionSummary
a} :: DescribeStreamSummaryResponse)

instance Prelude.NFData DescribeStreamSummaryResponse