{-# 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.KinesisVideo.DescribeStream
-- 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 the most current information about the specified stream. You
-- must specify either the @StreamName@ or the @StreamARN@.
module Amazonka.KinesisVideo.DescribeStream
  ( -- * Creating a Request
    DescribeStream (..),
    newDescribeStream,

    -- * Request Lenses
    describeStream_streamARN,
    describeStream_streamName,

    -- * Destructuring the Response
    DescribeStreamResponse (..),
    newDescribeStreamResponse,

    -- * Response Lenses
    describeStreamResponse_streamInfo,
    describeStreamResponse_httpStatus,
  )
where

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

-- |
-- Create a value of 'DescribeStream' 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:
--
-- 'streamARN', 'describeStream_streamARN' - The Amazon Resource Name (ARN) of the stream.
--
-- 'streamName', 'describeStream_streamName' - The name of the stream.
newDescribeStream ::
  DescribeStream
newDescribeStream :: DescribeStream
newDescribeStream =
  DescribeStream' :: Maybe Text -> Maybe Text -> DescribeStream
DescribeStream'
    { $sel:streamARN:DescribeStream' :: Maybe Text
streamARN = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:streamName:DescribeStream' :: Maybe Text
streamName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the stream.
describeStream_streamARN :: Lens.Lens' DescribeStream (Prelude.Maybe Prelude.Text)
describeStream_streamARN :: (Maybe Text -> f (Maybe Text))
-> DescribeStream -> f DescribeStream
describeStream_streamARN = (DescribeStream -> Maybe Text)
-> (DescribeStream -> Maybe Text -> DescribeStream)
-> Lens DescribeStream DescribeStream (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeStream' {Maybe Text
streamARN :: Maybe Text
$sel:streamARN:DescribeStream' :: DescribeStream -> Maybe Text
streamARN} -> Maybe Text
streamARN) (\s :: DescribeStream
s@DescribeStream' {} Maybe Text
a -> DescribeStream
s {$sel:streamARN:DescribeStream' :: Maybe Text
streamARN = Maybe Text
a} :: DescribeStream)

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

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

instance Prelude.NFData DescribeStream

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

instance Core.ToJSON DescribeStream where
  toJSON :: DescribeStream -> Value
toJSON DescribeStream' {Maybe Text
streamName :: Maybe Text
streamARN :: Maybe Text
$sel:streamName:DescribeStream' :: DescribeStream -> Maybe Text
$sel:streamARN:DescribeStream' :: DescribeStream -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"StreamARN" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
streamARN,
            (Text
"StreamName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
streamName
          ]
      )

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

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

-- | /See:/ 'newDescribeStreamResponse' smart constructor.
data DescribeStreamResponse = DescribeStreamResponse'
  { -- | An object that describes the stream.
    DescribeStreamResponse -> Maybe StreamInfo
streamInfo :: Prelude.Maybe StreamInfo,
    -- | The response's http status code.
    DescribeStreamResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeStreamResponse -> DescribeStreamResponse -> Bool
(DescribeStreamResponse -> DescribeStreamResponse -> Bool)
-> (DescribeStreamResponse -> DescribeStreamResponse -> Bool)
-> Eq DescribeStreamResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeStreamResponse -> DescribeStreamResponse -> Bool
$c/= :: DescribeStreamResponse -> DescribeStreamResponse -> Bool
== :: DescribeStreamResponse -> DescribeStreamResponse -> Bool
$c== :: DescribeStreamResponse -> DescribeStreamResponse -> Bool
Prelude.Eq, ReadPrec [DescribeStreamResponse]
ReadPrec DescribeStreamResponse
Int -> ReadS DescribeStreamResponse
ReadS [DescribeStreamResponse]
(Int -> ReadS DescribeStreamResponse)
-> ReadS [DescribeStreamResponse]
-> ReadPrec DescribeStreamResponse
-> ReadPrec [DescribeStreamResponse]
-> Read DescribeStreamResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeStreamResponse]
$creadListPrec :: ReadPrec [DescribeStreamResponse]
readPrec :: ReadPrec DescribeStreamResponse
$creadPrec :: ReadPrec DescribeStreamResponse
readList :: ReadS [DescribeStreamResponse]
$creadList :: ReadS [DescribeStreamResponse]
readsPrec :: Int -> ReadS DescribeStreamResponse
$creadsPrec :: Int -> ReadS DescribeStreamResponse
Prelude.Read, Int -> DescribeStreamResponse -> ShowS
[DescribeStreamResponse] -> ShowS
DescribeStreamResponse -> String
(Int -> DescribeStreamResponse -> ShowS)
-> (DescribeStreamResponse -> String)
-> ([DescribeStreamResponse] -> ShowS)
-> Show DescribeStreamResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeStreamResponse] -> ShowS
$cshowList :: [DescribeStreamResponse] -> ShowS
show :: DescribeStreamResponse -> String
$cshow :: DescribeStreamResponse -> String
showsPrec :: Int -> DescribeStreamResponse -> ShowS
$cshowsPrec :: Int -> DescribeStreamResponse -> ShowS
Prelude.Show, (forall x. DescribeStreamResponse -> Rep DescribeStreamResponse x)
-> (forall x.
    Rep DescribeStreamResponse x -> DescribeStreamResponse)
-> Generic DescribeStreamResponse
forall x. Rep DescribeStreamResponse x -> DescribeStreamResponse
forall x. DescribeStreamResponse -> Rep DescribeStreamResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeStreamResponse x -> DescribeStreamResponse
$cfrom :: forall x. DescribeStreamResponse -> Rep DescribeStreamResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeStreamResponse' 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:
--
-- 'streamInfo', 'describeStreamResponse_streamInfo' - An object that describes the stream.
--
-- 'httpStatus', 'describeStreamResponse_httpStatus' - The response's http status code.
newDescribeStreamResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeStreamResponse
newDescribeStreamResponse :: Int -> DescribeStreamResponse
newDescribeStreamResponse Int
pHttpStatus_ =
  DescribeStreamResponse' :: Maybe StreamInfo -> Int -> DescribeStreamResponse
DescribeStreamResponse'
    { $sel:streamInfo:DescribeStreamResponse' :: Maybe StreamInfo
streamInfo =
        Maybe StreamInfo
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeStreamResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An object that describes the stream.
describeStreamResponse_streamInfo :: Lens.Lens' DescribeStreamResponse (Prelude.Maybe StreamInfo)
describeStreamResponse_streamInfo :: (Maybe StreamInfo -> f (Maybe StreamInfo))
-> DescribeStreamResponse -> f DescribeStreamResponse
describeStreamResponse_streamInfo = (DescribeStreamResponse -> Maybe StreamInfo)
-> (DescribeStreamResponse
    -> Maybe StreamInfo -> DescribeStreamResponse)
-> Lens
     DescribeStreamResponse
     DescribeStreamResponse
     (Maybe StreamInfo)
     (Maybe StreamInfo)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeStreamResponse' {Maybe StreamInfo
streamInfo :: Maybe StreamInfo
$sel:streamInfo:DescribeStreamResponse' :: DescribeStreamResponse -> Maybe StreamInfo
streamInfo} -> Maybe StreamInfo
streamInfo) (\s :: DescribeStreamResponse
s@DescribeStreamResponse' {} Maybe StreamInfo
a -> DescribeStreamResponse
s {$sel:streamInfo:DescribeStreamResponse' :: Maybe StreamInfo
streamInfo = Maybe StreamInfo
a} :: DescribeStreamResponse)

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

instance Prelude.NFData DescribeStreamResponse