{-# 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.QLDB.DescribeJournalKinesisStream
-- 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 detailed information about a given Amazon QLDB journal stream.
-- The output includes the Amazon Resource Name (ARN), stream name, current
-- status, creation time, and the parameters of the original stream
-- creation request.
--
-- This action does not return any expired journal streams. For more
-- information, see
-- <https://docs.aws.amazon.com/qldb/latest/developerguide/streams.create.html#streams.create.states.expiration Expiration for terminal streams>
-- in the /Amazon QLDB Developer Guide/.
module Amazonka.QLDB.DescribeJournalKinesisStream
  ( -- * Creating a Request
    DescribeJournalKinesisStream (..),
    newDescribeJournalKinesisStream,

    -- * Request Lenses
    describeJournalKinesisStream_ledgerName,
    describeJournalKinesisStream_streamId,

    -- * Destructuring the Response
    DescribeJournalKinesisStreamResponse (..),
    newDescribeJournalKinesisStreamResponse,

    -- * Response Lenses
    describeJournalKinesisStreamResponse_stream,
    describeJournalKinesisStreamResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDescribeJournalKinesisStream' smart constructor.
data DescribeJournalKinesisStream = DescribeJournalKinesisStream'
  { -- | The name of the ledger.
    DescribeJournalKinesisStream -> Text
ledgerName :: Prelude.Text,
    -- | The UUID (represented in Base62-encoded text) of the QLDB journal stream
    -- to describe.
    DescribeJournalKinesisStream -> Text
streamId :: Prelude.Text
  }
  deriving (DescribeJournalKinesisStream
-> DescribeJournalKinesisStream -> Bool
(DescribeJournalKinesisStream
 -> DescribeJournalKinesisStream -> Bool)
-> (DescribeJournalKinesisStream
    -> DescribeJournalKinesisStream -> Bool)
-> Eq DescribeJournalKinesisStream
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeJournalKinesisStream
-> DescribeJournalKinesisStream -> Bool
$c/= :: DescribeJournalKinesisStream
-> DescribeJournalKinesisStream -> Bool
== :: DescribeJournalKinesisStream
-> DescribeJournalKinesisStream -> Bool
$c== :: DescribeJournalKinesisStream
-> DescribeJournalKinesisStream -> Bool
Prelude.Eq, ReadPrec [DescribeJournalKinesisStream]
ReadPrec DescribeJournalKinesisStream
Int -> ReadS DescribeJournalKinesisStream
ReadS [DescribeJournalKinesisStream]
(Int -> ReadS DescribeJournalKinesisStream)
-> ReadS [DescribeJournalKinesisStream]
-> ReadPrec DescribeJournalKinesisStream
-> ReadPrec [DescribeJournalKinesisStream]
-> Read DescribeJournalKinesisStream
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeJournalKinesisStream]
$creadListPrec :: ReadPrec [DescribeJournalKinesisStream]
readPrec :: ReadPrec DescribeJournalKinesisStream
$creadPrec :: ReadPrec DescribeJournalKinesisStream
readList :: ReadS [DescribeJournalKinesisStream]
$creadList :: ReadS [DescribeJournalKinesisStream]
readsPrec :: Int -> ReadS DescribeJournalKinesisStream
$creadsPrec :: Int -> ReadS DescribeJournalKinesisStream
Prelude.Read, Int -> DescribeJournalKinesisStream -> ShowS
[DescribeJournalKinesisStream] -> ShowS
DescribeJournalKinesisStream -> String
(Int -> DescribeJournalKinesisStream -> ShowS)
-> (DescribeJournalKinesisStream -> String)
-> ([DescribeJournalKinesisStream] -> ShowS)
-> Show DescribeJournalKinesisStream
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeJournalKinesisStream] -> ShowS
$cshowList :: [DescribeJournalKinesisStream] -> ShowS
show :: DescribeJournalKinesisStream -> String
$cshow :: DescribeJournalKinesisStream -> String
showsPrec :: Int -> DescribeJournalKinesisStream -> ShowS
$cshowsPrec :: Int -> DescribeJournalKinesisStream -> ShowS
Prelude.Show, (forall x.
 DescribeJournalKinesisStream -> Rep DescribeJournalKinesisStream x)
-> (forall x.
    Rep DescribeJournalKinesisStream x -> DescribeJournalKinesisStream)
-> Generic DescribeJournalKinesisStream
forall x.
Rep DescribeJournalKinesisStream x -> DescribeJournalKinesisStream
forall x.
DescribeJournalKinesisStream -> Rep DescribeJournalKinesisStream x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeJournalKinesisStream x -> DescribeJournalKinesisStream
$cfrom :: forall x.
DescribeJournalKinesisStream -> Rep DescribeJournalKinesisStream x
Prelude.Generic)

-- |
-- Create a value of 'DescribeJournalKinesisStream' 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:
--
-- 'ledgerName', 'describeJournalKinesisStream_ledgerName' - The name of the ledger.
--
-- 'streamId', 'describeJournalKinesisStream_streamId' - The UUID (represented in Base62-encoded text) of the QLDB journal stream
-- to describe.
newDescribeJournalKinesisStream ::
  -- | 'ledgerName'
  Prelude.Text ->
  -- | 'streamId'
  Prelude.Text ->
  DescribeJournalKinesisStream
newDescribeJournalKinesisStream :: Text -> Text -> DescribeJournalKinesisStream
newDescribeJournalKinesisStream
  Text
pLedgerName_
  Text
pStreamId_ =
    DescribeJournalKinesisStream' :: Text -> Text -> DescribeJournalKinesisStream
DescribeJournalKinesisStream'
      { $sel:ledgerName:DescribeJournalKinesisStream' :: Text
ledgerName =
          Text
pLedgerName_,
        $sel:streamId:DescribeJournalKinesisStream' :: Text
streamId = Text
pStreamId_
      }

-- | The name of the ledger.
describeJournalKinesisStream_ledgerName :: Lens.Lens' DescribeJournalKinesisStream Prelude.Text
describeJournalKinesisStream_ledgerName :: (Text -> f Text)
-> DescribeJournalKinesisStream -> f DescribeJournalKinesisStream
describeJournalKinesisStream_ledgerName = (DescribeJournalKinesisStream -> Text)
-> (DescribeJournalKinesisStream
    -> Text -> DescribeJournalKinesisStream)
-> Lens
     DescribeJournalKinesisStream DescribeJournalKinesisStream Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeJournalKinesisStream' {Text
ledgerName :: Text
$sel:ledgerName:DescribeJournalKinesisStream' :: DescribeJournalKinesisStream -> Text
ledgerName} -> Text
ledgerName) (\s :: DescribeJournalKinesisStream
s@DescribeJournalKinesisStream' {} Text
a -> DescribeJournalKinesisStream
s {$sel:ledgerName:DescribeJournalKinesisStream' :: Text
ledgerName = Text
a} :: DescribeJournalKinesisStream)

-- | The UUID (represented in Base62-encoded text) of the QLDB journal stream
-- to describe.
describeJournalKinesisStream_streamId :: Lens.Lens' DescribeJournalKinesisStream Prelude.Text
describeJournalKinesisStream_streamId :: (Text -> f Text)
-> DescribeJournalKinesisStream -> f DescribeJournalKinesisStream
describeJournalKinesisStream_streamId = (DescribeJournalKinesisStream -> Text)
-> (DescribeJournalKinesisStream
    -> Text -> DescribeJournalKinesisStream)
-> Lens
     DescribeJournalKinesisStream DescribeJournalKinesisStream Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeJournalKinesisStream' {Text
streamId :: Text
$sel:streamId:DescribeJournalKinesisStream' :: DescribeJournalKinesisStream -> Text
streamId} -> Text
streamId) (\s :: DescribeJournalKinesisStream
s@DescribeJournalKinesisStream' {} Text
a -> DescribeJournalKinesisStream
s {$sel:streamId:DescribeJournalKinesisStream' :: Text
streamId = Text
a} :: DescribeJournalKinesisStream)

instance Core.AWSRequest DescribeJournalKinesisStream where
  type
    AWSResponse DescribeJournalKinesisStream =
      DescribeJournalKinesisStreamResponse
  request :: DescribeJournalKinesisStream
-> Request DescribeJournalKinesisStream
request = Service
-> DescribeJournalKinesisStream
-> Request DescribeJournalKinesisStream
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeJournalKinesisStream
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeJournalKinesisStream)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeJournalKinesisStream))
-> Logger
-> Service
-> Proxy DescribeJournalKinesisStream
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeJournalKinesisStream)))
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 JournalKinesisStreamDescription
-> Int -> DescribeJournalKinesisStreamResponse
DescribeJournalKinesisStreamResponse'
            (Maybe JournalKinesisStreamDescription
 -> Int -> DescribeJournalKinesisStreamResponse)
-> Either String (Maybe JournalKinesisStreamDescription)
-> Either String (Int -> DescribeJournalKinesisStreamResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text -> Either String (Maybe JournalKinesisStreamDescription)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Stream")
            Either String (Int -> DescribeJournalKinesisStreamResponse)
-> Either String Int
-> Either String DescribeJournalKinesisStreamResponse
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
    DescribeJournalKinesisStream

instance Prelude.NFData DescribeJournalKinesisStream

instance Core.ToHeaders DescribeJournalKinesisStream where
  toHeaders :: DescribeJournalKinesisStream -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeJournalKinesisStream -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToPath DescribeJournalKinesisStream where
  toPath :: DescribeJournalKinesisStream -> ByteString
toPath DescribeJournalKinesisStream' {Text
streamId :: Text
ledgerName :: Text
$sel:streamId:DescribeJournalKinesisStream' :: DescribeJournalKinesisStream -> Text
$sel:ledgerName:DescribeJournalKinesisStream' :: DescribeJournalKinesisStream -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/ledgers/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
ledgerName,
        ByteString
"/journal-kinesis-streams/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
streamId
      ]

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

-- | /See:/ 'newDescribeJournalKinesisStreamResponse' smart constructor.
data DescribeJournalKinesisStreamResponse = DescribeJournalKinesisStreamResponse'
  { -- | Information about the QLDB journal stream returned by a
    -- @DescribeJournalS3Export@ request.
    DescribeJournalKinesisStreamResponse
-> Maybe JournalKinesisStreamDescription
stream :: Prelude.Maybe JournalKinesisStreamDescription,
    -- | The response's http status code.
    DescribeJournalKinesisStreamResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeJournalKinesisStreamResponse
-> DescribeJournalKinesisStreamResponse -> Bool
(DescribeJournalKinesisStreamResponse
 -> DescribeJournalKinesisStreamResponse -> Bool)
-> (DescribeJournalKinesisStreamResponse
    -> DescribeJournalKinesisStreamResponse -> Bool)
-> Eq DescribeJournalKinesisStreamResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeJournalKinesisStreamResponse
-> DescribeJournalKinesisStreamResponse -> Bool
$c/= :: DescribeJournalKinesisStreamResponse
-> DescribeJournalKinesisStreamResponse -> Bool
== :: DescribeJournalKinesisStreamResponse
-> DescribeJournalKinesisStreamResponse -> Bool
$c== :: DescribeJournalKinesisStreamResponse
-> DescribeJournalKinesisStreamResponse -> Bool
Prelude.Eq, ReadPrec [DescribeJournalKinesisStreamResponse]
ReadPrec DescribeJournalKinesisStreamResponse
Int -> ReadS DescribeJournalKinesisStreamResponse
ReadS [DescribeJournalKinesisStreamResponse]
(Int -> ReadS DescribeJournalKinesisStreamResponse)
-> ReadS [DescribeJournalKinesisStreamResponse]
-> ReadPrec DescribeJournalKinesisStreamResponse
-> ReadPrec [DescribeJournalKinesisStreamResponse]
-> Read DescribeJournalKinesisStreamResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeJournalKinesisStreamResponse]
$creadListPrec :: ReadPrec [DescribeJournalKinesisStreamResponse]
readPrec :: ReadPrec DescribeJournalKinesisStreamResponse
$creadPrec :: ReadPrec DescribeJournalKinesisStreamResponse
readList :: ReadS [DescribeJournalKinesisStreamResponse]
$creadList :: ReadS [DescribeJournalKinesisStreamResponse]
readsPrec :: Int -> ReadS DescribeJournalKinesisStreamResponse
$creadsPrec :: Int -> ReadS DescribeJournalKinesisStreamResponse
Prelude.Read, Int -> DescribeJournalKinesisStreamResponse -> ShowS
[DescribeJournalKinesisStreamResponse] -> ShowS
DescribeJournalKinesisStreamResponse -> String
(Int -> DescribeJournalKinesisStreamResponse -> ShowS)
-> (DescribeJournalKinesisStreamResponse -> String)
-> ([DescribeJournalKinesisStreamResponse] -> ShowS)
-> Show DescribeJournalKinesisStreamResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeJournalKinesisStreamResponse] -> ShowS
$cshowList :: [DescribeJournalKinesisStreamResponse] -> ShowS
show :: DescribeJournalKinesisStreamResponse -> String
$cshow :: DescribeJournalKinesisStreamResponse -> String
showsPrec :: Int -> DescribeJournalKinesisStreamResponse -> ShowS
$cshowsPrec :: Int -> DescribeJournalKinesisStreamResponse -> ShowS
Prelude.Show, (forall x.
 DescribeJournalKinesisStreamResponse
 -> Rep DescribeJournalKinesisStreamResponse x)
-> (forall x.
    Rep DescribeJournalKinesisStreamResponse x
    -> DescribeJournalKinesisStreamResponse)
-> Generic DescribeJournalKinesisStreamResponse
forall x.
Rep DescribeJournalKinesisStreamResponse x
-> DescribeJournalKinesisStreamResponse
forall x.
DescribeJournalKinesisStreamResponse
-> Rep DescribeJournalKinesisStreamResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeJournalKinesisStreamResponse x
-> DescribeJournalKinesisStreamResponse
$cfrom :: forall x.
DescribeJournalKinesisStreamResponse
-> Rep DescribeJournalKinesisStreamResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeJournalKinesisStreamResponse' 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:
--
-- 'stream', 'describeJournalKinesisStreamResponse_stream' - Information about the QLDB journal stream returned by a
-- @DescribeJournalS3Export@ request.
--
-- 'httpStatus', 'describeJournalKinesisStreamResponse_httpStatus' - The response's http status code.
newDescribeJournalKinesisStreamResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeJournalKinesisStreamResponse
newDescribeJournalKinesisStreamResponse :: Int -> DescribeJournalKinesisStreamResponse
newDescribeJournalKinesisStreamResponse Int
pHttpStatus_ =
  DescribeJournalKinesisStreamResponse' :: Maybe JournalKinesisStreamDescription
-> Int -> DescribeJournalKinesisStreamResponse
DescribeJournalKinesisStreamResponse'
    { $sel:stream:DescribeJournalKinesisStreamResponse' :: Maybe JournalKinesisStreamDescription
stream =
        Maybe JournalKinesisStreamDescription
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeJournalKinesisStreamResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the QLDB journal stream returned by a
-- @DescribeJournalS3Export@ request.
describeJournalKinesisStreamResponse_stream :: Lens.Lens' DescribeJournalKinesisStreamResponse (Prelude.Maybe JournalKinesisStreamDescription)
describeJournalKinesisStreamResponse_stream :: (Maybe JournalKinesisStreamDescription
 -> f (Maybe JournalKinesisStreamDescription))
-> DescribeJournalKinesisStreamResponse
-> f DescribeJournalKinesisStreamResponse
describeJournalKinesisStreamResponse_stream = (DescribeJournalKinesisStreamResponse
 -> Maybe JournalKinesisStreamDescription)
-> (DescribeJournalKinesisStreamResponse
    -> Maybe JournalKinesisStreamDescription
    -> DescribeJournalKinesisStreamResponse)
-> Lens
     DescribeJournalKinesisStreamResponse
     DescribeJournalKinesisStreamResponse
     (Maybe JournalKinesisStreamDescription)
     (Maybe JournalKinesisStreamDescription)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeJournalKinesisStreamResponse' {Maybe JournalKinesisStreamDescription
stream :: Maybe JournalKinesisStreamDescription
$sel:stream:DescribeJournalKinesisStreamResponse' :: DescribeJournalKinesisStreamResponse
-> Maybe JournalKinesisStreamDescription
stream} -> Maybe JournalKinesisStreamDescription
stream) (\s :: DescribeJournalKinesisStreamResponse
s@DescribeJournalKinesisStreamResponse' {} Maybe JournalKinesisStreamDescription
a -> DescribeJournalKinesisStreamResponse
s {$sel:stream:DescribeJournalKinesisStreamResponse' :: Maybe JournalKinesisStreamDescription
stream = Maybe JournalKinesisStreamDescription
a} :: DescribeJournalKinesisStreamResponse)

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

instance
  Prelude.NFData
    DescribeJournalKinesisStreamResponse