{-# 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.CloudFront.GetStreamingDistribution
-- 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)
--
-- Gets information about a specified RTMP distribution, including the
-- distribution configuration.
module Amazonka.CloudFront.GetStreamingDistribution
  ( -- * Creating a Request
    GetStreamingDistribution (..),
    newGetStreamingDistribution,

    -- * Request Lenses
    getStreamingDistribution_id,

    -- * Destructuring the Response
    GetStreamingDistributionResponse (..),
    newGetStreamingDistributionResponse,

    -- * Response Lenses
    getStreamingDistributionResponse_eTag,
    getStreamingDistributionResponse_streamingDistribution,
    getStreamingDistributionResponse_httpStatus,
  )
where

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

-- | The request to get a streaming distribution\'s information.
--
-- /See:/ 'newGetStreamingDistribution' smart constructor.
data GetStreamingDistribution = GetStreamingDistribution'
  { -- | The streaming distribution\'s ID.
    GetStreamingDistribution -> Text
id :: Prelude.Text
  }
  deriving (GetStreamingDistribution -> GetStreamingDistribution -> Bool
(GetStreamingDistribution -> GetStreamingDistribution -> Bool)
-> (GetStreamingDistribution -> GetStreamingDistribution -> Bool)
-> Eq GetStreamingDistribution
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetStreamingDistribution -> GetStreamingDistribution -> Bool
$c/= :: GetStreamingDistribution -> GetStreamingDistribution -> Bool
== :: GetStreamingDistribution -> GetStreamingDistribution -> Bool
$c== :: GetStreamingDistribution -> GetStreamingDistribution -> Bool
Prelude.Eq, ReadPrec [GetStreamingDistribution]
ReadPrec GetStreamingDistribution
Int -> ReadS GetStreamingDistribution
ReadS [GetStreamingDistribution]
(Int -> ReadS GetStreamingDistribution)
-> ReadS [GetStreamingDistribution]
-> ReadPrec GetStreamingDistribution
-> ReadPrec [GetStreamingDistribution]
-> Read GetStreamingDistribution
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetStreamingDistribution]
$creadListPrec :: ReadPrec [GetStreamingDistribution]
readPrec :: ReadPrec GetStreamingDistribution
$creadPrec :: ReadPrec GetStreamingDistribution
readList :: ReadS [GetStreamingDistribution]
$creadList :: ReadS [GetStreamingDistribution]
readsPrec :: Int -> ReadS GetStreamingDistribution
$creadsPrec :: Int -> ReadS GetStreamingDistribution
Prelude.Read, Int -> GetStreamingDistribution -> ShowS
[GetStreamingDistribution] -> ShowS
GetStreamingDistribution -> String
(Int -> GetStreamingDistribution -> ShowS)
-> (GetStreamingDistribution -> String)
-> ([GetStreamingDistribution] -> ShowS)
-> Show GetStreamingDistribution
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetStreamingDistribution] -> ShowS
$cshowList :: [GetStreamingDistribution] -> ShowS
show :: GetStreamingDistribution -> String
$cshow :: GetStreamingDistribution -> String
showsPrec :: Int -> GetStreamingDistribution -> ShowS
$cshowsPrec :: Int -> GetStreamingDistribution -> ShowS
Prelude.Show, (forall x.
 GetStreamingDistribution -> Rep GetStreamingDistribution x)
-> (forall x.
    Rep GetStreamingDistribution x -> GetStreamingDistribution)
-> Generic GetStreamingDistribution
forall x.
Rep GetStreamingDistribution x -> GetStreamingDistribution
forall x.
GetStreamingDistribution -> Rep GetStreamingDistribution x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetStreamingDistribution x -> GetStreamingDistribution
$cfrom :: forall x.
GetStreamingDistribution -> Rep GetStreamingDistribution x
Prelude.Generic)

-- |
-- Create a value of 'GetStreamingDistribution' 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:
--
-- 'id', 'getStreamingDistribution_id' - The streaming distribution\'s ID.
newGetStreamingDistribution ::
  -- | 'id'
  Prelude.Text ->
  GetStreamingDistribution
newGetStreamingDistribution :: Text -> GetStreamingDistribution
newGetStreamingDistribution Text
pId_ =
  GetStreamingDistribution' :: Text -> GetStreamingDistribution
GetStreamingDistribution' {$sel:id:GetStreamingDistribution' :: Text
id = Text
pId_}

-- | The streaming distribution\'s ID.
getStreamingDistribution_id :: Lens.Lens' GetStreamingDistribution Prelude.Text
getStreamingDistribution_id :: (Text -> f Text)
-> GetStreamingDistribution -> f GetStreamingDistribution
getStreamingDistribution_id = (GetStreamingDistribution -> Text)
-> (GetStreamingDistribution -> Text -> GetStreamingDistribution)
-> Lens GetStreamingDistribution GetStreamingDistribution Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetStreamingDistribution' {Text
id :: Text
$sel:id:GetStreamingDistribution' :: GetStreamingDistribution -> Text
id} -> Text
id) (\s :: GetStreamingDistribution
s@GetStreamingDistribution' {} Text
a -> GetStreamingDistribution
s {$sel:id:GetStreamingDistribution' :: Text
id = Text
a} :: GetStreamingDistribution)

instance Core.AWSRequest GetStreamingDistribution where
  type
    AWSResponse GetStreamingDistribution =
      GetStreamingDistributionResponse
  request :: GetStreamingDistribution -> Request GetStreamingDistribution
request = Service
-> GetStreamingDistribution -> Request GetStreamingDistribution
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetStreamingDistribution
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetStreamingDistribution)))
response =
    (Int
 -> ResponseHeaders
 -> [Node]
 -> Either String (AWSResponse GetStreamingDistribution))
-> Logger
-> Service
-> Proxy GetStreamingDistribution
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetStreamingDistribution)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXML
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Text
-> Maybe StreamingDistribution
-> Int
-> GetStreamingDistributionResponse
GetStreamingDistributionResponse'
            (Maybe Text
 -> Maybe StreamingDistribution
 -> Int
 -> GetStreamingDistributionResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe StreamingDistribution
      -> Int -> GetStreamingDistributionResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (ResponseHeaders
h ResponseHeaders -> HeaderName -> Either String (Maybe Text)
forall a.
FromText a =>
ResponseHeaders -> HeaderName -> Either String (Maybe a)
Core..#? HeaderName
"ETag")
            Either
  String
  (Maybe StreamingDistribution
   -> Int -> GetStreamingDistributionResponse)
-> Either String (Maybe StreamingDistribution)
-> Either String (Int -> GetStreamingDistributionResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node] -> Either String (Maybe StreamingDistribution)
forall a. FromXML a => [Node] -> Either String a
Core.parseXML [Node]
x)
            Either String (Int -> GetStreamingDistributionResponse)
-> Either String Int
-> Either String GetStreamingDistributionResponse
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 GetStreamingDistribution

instance Prelude.NFData GetStreamingDistribution

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

instance Core.ToPath GetStreamingDistribution where
  toPath :: GetStreamingDistribution -> ByteString
toPath GetStreamingDistribution' {Text
id :: Text
$sel:id:GetStreamingDistribution' :: GetStreamingDistribution -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/2020-05-31/streaming-distribution/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
id]

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

-- | The returned result of the corresponding request.
--
-- /See:/ 'newGetStreamingDistributionResponse' smart constructor.
data GetStreamingDistributionResponse = GetStreamingDistributionResponse'
  { -- | The current version of the streaming distribution\'s information. For
    -- example: @E2QWRUHAPOMQZL@.
    GetStreamingDistributionResponse -> Maybe Text
eTag :: Prelude.Maybe Prelude.Text,
    -- | The streaming distribution\'s information.
    GetStreamingDistributionResponse -> Maybe StreamingDistribution
streamingDistribution :: Prelude.Maybe StreamingDistribution,
    -- | The response's http status code.
    GetStreamingDistributionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetStreamingDistributionResponse
-> GetStreamingDistributionResponse -> Bool
(GetStreamingDistributionResponse
 -> GetStreamingDistributionResponse -> Bool)
-> (GetStreamingDistributionResponse
    -> GetStreamingDistributionResponse -> Bool)
-> Eq GetStreamingDistributionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetStreamingDistributionResponse
-> GetStreamingDistributionResponse -> Bool
$c/= :: GetStreamingDistributionResponse
-> GetStreamingDistributionResponse -> Bool
== :: GetStreamingDistributionResponse
-> GetStreamingDistributionResponse -> Bool
$c== :: GetStreamingDistributionResponse
-> GetStreamingDistributionResponse -> Bool
Prelude.Eq, ReadPrec [GetStreamingDistributionResponse]
ReadPrec GetStreamingDistributionResponse
Int -> ReadS GetStreamingDistributionResponse
ReadS [GetStreamingDistributionResponse]
(Int -> ReadS GetStreamingDistributionResponse)
-> ReadS [GetStreamingDistributionResponse]
-> ReadPrec GetStreamingDistributionResponse
-> ReadPrec [GetStreamingDistributionResponse]
-> Read GetStreamingDistributionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetStreamingDistributionResponse]
$creadListPrec :: ReadPrec [GetStreamingDistributionResponse]
readPrec :: ReadPrec GetStreamingDistributionResponse
$creadPrec :: ReadPrec GetStreamingDistributionResponse
readList :: ReadS [GetStreamingDistributionResponse]
$creadList :: ReadS [GetStreamingDistributionResponse]
readsPrec :: Int -> ReadS GetStreamingDistributionResponse
$creadsPrec :: Int -> ReadS GetStreamingDistributionResponse
Prelude.Read, Int -> GetStreamingDistributionResponse -> ShowS
[GetStreamingDistributionResponse] -> ShowS
GetStreamingDistributionResponse -> String
(Int -> GetStreamingDistributionResponse -> ShowS)
-> (GetStreamingDistributionResponse -> String)
-> ([GetStreamingDistributionResponse] -> ShowS)
-> Show GetStreamingDistributionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetStreamingDistributionResponse] -> ShowS
$cshowList :: [GetStreamingDistributionResponse] -> ShowS
show :: GetStreamingDistributionResponse -> String
$cshow :: GetStreamingDistributionResponse -> String
showsPrec :: Int -> GetStreamingDistributionResponse -> ShowS
$cshowsPrec :: Int -> GetStreamingDistributionResponse -> ShowS
Prelude.Show, (forall x.
 GetStreamingDistributionResponse
 -> Rep GetStreamingDistributionResponse x)
-> (forall x.
    Rep GetStreamingDistributionResponse x
    -> GetStreamingDistributionResponse)
-> Generic GetStreamingDistributionResponse
forall x.
Rep GetStreamingDistributionResponse x
-> GetStreamingDistributionResponse
forall x.
GetStreamingDistributionResponse
-> Rep GetStreamingDistributionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetStreamingDistributionResponse x
-> GetStreamingDistributionResponse
$cfrom :: forall x.
GetStreamingDistributionResponse
-> Rep GetStreamingDistributionResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetStreamingDistributionResponse' 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:
--
-- 'eTag', 'getStreamingDistributionResponse_eTag' - The current version of the streaming distribution\'s information. For
-- example: @E2QWRUHAPOMQZL@.
--
-- 'streamingDistribution', 'getStreamingDistributionResponse_streamingDistribution' - The streaming distribution\'s information.
--
-- 'httpStatus', 'getStreamingDistributionResponse_httpStatus' - The response's http status code.
newGetStreamingDistributionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetStreamingDistributionResponse
newGetStreamingDistributionResponse :: Int -> GetStreamingDistributionResponse
newGetStreamingDistributionResponse Int
pHttpStatus_ =
  GetStreamingDistributionResponse' :: Maybe Text
-> Maybe StreamingDistribution
-> Int
-> GetStreamingDistributionResponse
GetStreamingDistributionResponse'
    { $sel:eTag:GetStreamingDistributionResponse' :: Maybe Text
eTag =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:streamingDistribution:GetStreamingDistributionResponse' :: Maybe StreamingDistribution
streamingDistribution = Maybe StreamingDistribution
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetStreamingDistributionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The current version of the streaming distribution\'s information. For
-- example: @E2QWRUHAPOMQZL@.
getStreamingDistributionResponse_eTag :: Lens.Lens' GetStreamingDistributionResponse (Prelude.Maybe Prelude.Text)
getStreamingDistributionResponse_eTag :: (Maybe Text -> f (Maybe Text))
-> GetStreamingDistributionResponse
-> f GetStreamingDistributionResponse
getStreamingDistributionResponse_eTag = (GetStreamingDistributionResponse -> Maybe Text)
-> (GetStreamingDistributionResponse
    -> Maybe Text -> GetStreamingDistributionResponse)
-> Lens
     GetStreamingDistributionResponse
     GetStreamingDistributionResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetStreamingDistributionResponse' {Maybe Text
eTag :: Maybe Text
$sel:eTag:GetStreamingDistributionResponse' :: GetStreamingDistributionResponse -> Maybe Text
eTag} -> Maybe Text
eTag) (\s :: GetStreamingDistributionResponse
s@GetStreamingDistributionResponse' {} Maybe Text
a -> GetStreamingDistributionResponse
s {$sel:eTag:GetStreamingDistributionResponse' :: Maybe Text
eTag = Maybe Text
a} :: GetStreamingDistributionResponse)

-- | The streaming distribution\'s information.
getStreamingDistributionResponse_streamingDistribution :: Lens.Lens' GetStreamingDistributionResponse (Prelude.Maybe StreamingDistribution)
getStreamingDistributionResponse_streamingDistribution :: (Maybe StreamingDistribution -> f (Maybe StreamingDistribution))
-> GetStreamingDistributionResponse
-> f GetStreamingDistributionResponse
getStreamingDistributionResponse_streamingDistribution = (GetStreamingDistributionResponse -> Maybe StreamingDistribution)
-> (GetStreamingDistributionResponse
    -> Maybe StreamingDistribution -> GetStreamingDistributionResponse)
-> Lens
     GetStreamingDistributionResponse
     GetStreamingDistributionResponse
     (Maybe StreamingDistribution)
     (Maybe StreamingDistribution)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetStreamingDistributionResponse' {Maybe StreamingDistribution
streamingDistribution :: Maybe StreamingDistribution
$sel:streamingDistribution:GetStreamingDistributionResponse' :: GetStreamingDistributionResponse -> Maybe StreamingDistribution
streamingDistribution} -> Maybe StreamingDistribution
streamingDistribution) (\s :: GetStreamingDistributionResponse
s@GetStreamingDistributionResponse' {} Maybe StreamingDistribution
a -> GetStreamingDistributionResponse
s {$sel:streamingDistribution:GetStreamingDistributionResponse' :: Maybe StreamingDistribution
streamingDistribution = Maybe StreamingDistribution
a} :: GetStreamingDistributionResponse)

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

instance
  Prelude.NFData
    GetStreamingDistributionResponse