{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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.
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' {$sel:id:GetStreamingDistribution' :: Text
id = Text
pId_}

-- | The streaming distribution\'s ID.
getStreamingDistribution_id :: Lens.Lens' GetStreamingDistribution Prelude.Text
getStreamingDistribution_id :: Lens' GetStreamingDistribution Text
getStreamingDistribution_id = 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 :: (Service -> Service)
-> GetStreamingDistribution -> Request GetStreamingDistribution
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetStreamingDistribution
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetStreamingDistribution)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> 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'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (ResponseHeaders
h forall a.
FromText a =>
ResponseHeaders -> HeaderName -> Either String (Maybe a)
Data..#? HeaderName
"ETag")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall a. FromXML a => [Node] -> Either String a
Data.parseXML [Node]
x)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetStreamingDistribution where
  hashWithSalt :: Int -> GetStreamingDistribution -> Int
hashWithSalt Int
_salt GetStreamingDistribution' {Text
id :: Text
$sel:id:GetStreamingDistribution' :: GetStreamingDistribution -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id

instance Prelude.NFData GetStreamingDistribution where
  rnf :: GetStreamingDistribution -> ()
rnf GetStreamingDistribution' {Text
id :: Text
$sel:id:GetStreamingDistribution' :: GetStreamingDistribution -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
id

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

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

instance Data.ToQuery GetStreamingDistribution where
  toQuery :: GetStreamingDistribution -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:eTag:GetStreamingDistributionResponse' :: Maybe Text
eTag =
        forall a. Maybe a
Prelude.Nothing,
      $sel:streamingDistribution:GetStreamingDistributionResponse' :: Maybe StreamingDistribution
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 :: Lens' GetStreamingDistributionResponse (Maybe Text)
getStreamingDistributionResponse_eTag = 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 :: Lens'
  GetStreamingDistributionResponse (Maybe StreamingDistribution)
getStreamingDistributionResponse_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 :: Lens' GetStreamingDistributionResponse Int
getStreamingDistributionResponse_httpStatus = 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
  where
  rnf :: GetStreamingDistributionResponse -> ()
rnf GetStreamingDistributionResponse' {Int
Maybe Text
Maybe StreamingDistribution
httpStatus :: Int
streamingDistribution :: Maybe StreamingDistribution
eTag :: Maybe Text
$sel:httpStatus:GetStreamingDistributionResponse' :: GetStreamingDistributionResponse -> Int
$sel:streamingDistribution:GetStreamingDistributionResponse' :: GetStreamingDistributionResponse -> Maybe StreamingDistribution
$sel:eTag:GetStreamingDistributionResponse' :: GetStreamingDistributionResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
eTag
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe StreamingDistribution
streamingDistribution
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus