{-# 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.GetStreamingDistributionConfig
-- 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)
--
-- Get the configuration information about a streaming distribution.
module Amazonka.CloudFront.GetStreamingDistributionConfig
  ( -- * Creating a Request
    GetStreamingDistributionConfig (..),
    newGetStreamingDistributionConfig,

    -- * Request Lenses
    getStreamingDistributionConfig_id,

    -- * Destructuring the Response
    GetStreamingDistributionConfigResponse (..),
    newGetStreamingDistributionConfigResponse,

    -- * Response Lenses
    getStreamingDistributionConfigResponse_streamingDistributionConfig,
    getStreamingDistributionConfigResponse_eTag,
    getStreamingDistributionConfigResponse_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

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

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

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

instance
  Core.AWSRequest
    GetStreamingDistributionConfig
  where
  type
    AWSResponse GetStreamingDistributionConfig =
      GetStreamingDistributionConfigResponse
  request :: GetStreamingDistributionConfig
-> Request GetStreamingDistributionConfig
request = Service
-> GetStreamingDistributionConfig
-> Request GetStreamingDistributionConfig
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetStreamingDistributionConfig
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse GetStreamingDistributionConfig)))
response =
    (Int
 -> ResponseHeaders
 -> [Node]
 -> Either String (AWSResponse GetStreamingDistributionConfig))
-> Logger
-> Service
-> Proxy GetStreamingDistributionConfig
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse GetStreamingDistributionConfig)))
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 StreamingDistributionConfig
-> Maybe Text -> Int -> GetStreamingDistributionConfigResponse
GetStreamingDistributionConfigResponse'
            (Maybe StreamingDistributionConfig
 -> Maybe Text -> Int -> GetStreamingDistributionConfigResponse)
-> Either String (Maybe StreamingDistributionConfig)
-> Either
     String
     (Maybe Text -> Int -> GetStreamingDistributionConfigResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node] -> Either String (Maybe StreamingDistributionConfig)
forall a. FromXML a => [Node] -> Either String a
Core.parseXML [Node]
x)
            Either
  String
  (Maybe Text -> Int -> GetStreamingDistributionConfigResponse)
-> Either String (Maybe Text)
-> Either String (Int -> GetStreamingDistributionConfigResponse)
forall (f :: * -> *) a b. Applicative f => 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 (Int -> GetStreamingDistributionConfigResponse)
-> Either String Int
-> Either String GetStreamingDistributionConfigResponse
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
    GetStreamingDistributionConfig

instance
  Prelude.NFData
    GetStreamingDistributionConfig

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

instance Core.ToPath GetStreamingDistributionConfig where
  toPath :: GetStreamingDistributionConfig -> ByteString
toPath GetStreamingDistributionConfig' {Text
id :: Text
$sel:id:GetStreamingDistributionConfig' :: GetStreamingDistributionConfig -> 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,
        ByteString
"/config"
      ]

instance Core.ToQuery GetStreamingDistributionConfig where
  toQuery :: GetStreamingDistributionConfig -> QueryString
toQuery = QueryString -> GetStreamingDistributionConfig -> 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:/ 'newGetStreamingDistributionConfigResponse' smart constructor.
data GetStreamingDistributionConfigResponse = GetStreamingDistributionConfigResponse'
  { -- | The streaming distribution\'s configuration information.
    GetStreamingDistributionConfigResponse
-> Maybe StreamingDistributionConfig
streamingDistributionConfig :: Prelude.Maybe StreamingDistributionConfig,
    -- | The current version of the configuration. For example: @E2QWRUHAPOMQZL@.
    GetStreamingDistributionConfigResponse -> Maybe Text
eTag :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetStreamingDistributionConfigResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetStreamingDistributionConfigResponse
-> GetStreamingDistributionConfigResponse -> Bool
(GetStreamingDistributionConfigResponse
 -> GetStreamingDistributionConfigResponse -> Bool)
-> (GetStreamingDistributionConfigResponse
    -> GetStreamingDistributionConfigResponse -> Bool)
-> Eq GetStreamingDistributionConfigResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetStreamingDistributionConfigResponse
-> GetStreamingDistributionConfigResponse -> Bool
$c/= :: GetStreamingDistributionConfigResponse
-> GetStreamingDistributionConfigResponse -> Bool
== :: GetStreamingDistributionConfigResponse
-> GetStreamingDistributionConfigResponse -> Bool
$c== :: GetStreamingDistributionConfigResponse
-> GetStreamingDistributionConfigResponse -> Bool
Prelude.Eq, ReadPrec [GetStreamingDistributionConfigResponse]
ReadPrec GetStreamingDistributionConfigResponse
Int -> ReadS GetStreamingDistributionConfigResponse
ReadS [GetStreamingDistributionConfigResponse]
(Int -> ReadS GetStreamingDistributionConfigResponse)
-> ReadS [GetStreamingDistributionConfigResponse]
-> ReadPrec GetStreamingDistributionConfigResponse
-> ReadPrec [GetStreamingDistributionConfigResponse]
-> Read GetStreamingDistributionConfigResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetStreamingDistributionConfigResponse]
$creadListPrec :: ReadPrec [GetStreamingDistributionConfigResponse]
readPrec :: ReadPrec GetStreamingDistributionConfigResponse
$creadPrec :: ReadPrec GetStreamingDistributionConfigResponse
readList :: ReadS [GetStreamingDistributionConfigResponse]
$creadList :: ReadS [GetStreamingDistributionConfigResponse]
readsPrec :: Int -> ReadS GetStreamingDistributionConfigResponse
$creadsPrec :: Int -> ReadS GetStreamingDistributionConfigResponse
Prelude.Read, Int -> GetStreamingDistributionConfigResponse -> ShowS
[GetStreamingDistributionConfigResponse] -> ShowS
GetStreamingDistributionConfigResponse -> String
(Int -> GetStreamingDistributionConfigResponse -> ShowS)
-> (GetStreamingDistributionConfigResponse -> String)
-> ([GetStreamingDistributionConfigResponse] -> ShowS)
-> Show GetStreamingDistributionConfigResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetStreamingDistributionConfigResponse] -> ShowS
$cshowList :: [GetStreamingDistributionConfigResponse] -> ShowS
show :: GetStreamingDistributionConfigResponse -> String
$cshow :: GetStreamingDistributionConfigResponse -> String
showsPrec :: Int -> GetStreamingDistributionConfigResponse -> ShowS
$cshowsPrec :: Int -> GetStreamingDistributionConfigResponse -> ShowS
Prelude.Show, (forall x.
 GetStreamingDistributionConfigResponse
 -> Rep GetStreamingDistributionConfigResponse x)
-> (forall x.
    Rep GetStreamingDistributionConfigResponse x
    -> GetStreamingDistributionConfigResponse)
-> Generic GetStreamingDistributionConfigResponse
forall x.
Rep GetStreamingDistributionConfigResponse x
-> GetStreamingDistributionConfigResponse
forall x.
GetStreamingDistributionConfigResponse
-> Rep GetStreamingDistributionConfigResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetStreamingDistributionConfigResponse x
-> GetStreamingDistributionConfigResponse
$cfrom :: forall x.
GetStreamingDistributionConfigResponse
-> Rep GetStreamingDistributionConfigResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetStreamingDistributionConfigResponse' 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:
--
-- 'streamingDistributionConfig', 'getStreamingDistributionConfigResponse_streamingDistributionConfig' - The streaming distribution\'s configuration information.
--
-- 'eTag', 'getStreamingDistributionConfigResponse_eTag' - The current version of the configuration. For example: @E2QWRUHAPOMQZL@.
--
-- 'httpStatus', 'getStreamingDistributionConfigResponse_httpStatus' - The response's http status code.
newGetStreamingDistributionConfigResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetStreamingDistributionConfigResponse
newGetStreamingDistributionConfigResponse :: Int -> GetStreamingDistributionConfigResponse
newGetStreamingDistributionConfigResponse
  Int
pHttpStatus_ =
    GetStreamingDistributionConfigResponse' :: Maybe StreamingDistributionConfig
-> Maybe Text -> Int -> GetStreamingDistributionConfigResponse
GetStreamingDistributionConfigResponse'
      { $sel:streamingDistributionConfig:GetStreamingDistributionConfigResponse' :: Maybe StreamingDistributionConfig
streamingDistributionConfig =
          Maybe StreamingDistributionConfig
forall a. Maybe a
Prelude.Nothing,
        $sel:eTag:GetStreamingDistributionConfigResponse' :: Maybe Text
eTag = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:GetStreamingDistributionConfigResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | The streaming distribution\'s configuration information.
getStreamingDistributionConfigResponse_streamingDistributionConfig :: Lens.Lens' GetStreamingDistributionConfigResponse (Prelude.Maybe StreamingDistributionConfig)
getStreamingDistributionConfigResponse_streamingDistributionConfig :: (Maybe StreamingDistributionConfig
 -> f (Maybe StreamingDistributionConfig))
-> GetStreamingDistributionConfigResponse
-> f GetStreamingDistributionConfigResponse
getStreamingDistributionConfigResponse_streamingDistributionConfig = (GetStreamingDistributionConfigResponse
 -> Maybe StreamingDistributionConfig)
-> (GetStreamingDistributionConfigResponse
    -> Maybe StreamingDistributionConfig
    -> GetStreamingDistributionConfigResponse)
-> Lens
     GetStreamingDistributionConfigResponse
     GetStreamingDistributionConfigResponse
     (Maybe StreamingDistributionConfig)
     (Maybe StreamingDistributionConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetStreamingDistributionConfigResponse' {Maybe StreamingDistributionConfig
streamingDistributionConfig :: Maybe StreamingDistributionConfig
$sel:streamingDistributionConfig:GetStreamingDistributionConfigResponse' :: GetStreamingDistributionConfigResponse
-> Maybe StreamingDistributionConfig
streamingDistributionConfig} -> Maybe StreamingDistributionConfig
streamingDistributionConfig) (\s :: GetStreamingDistributionConfigResponse
s@GetStreamingDistributionConfigResponse' {} Maybe StreamingDistributionConfig
a -> GetStreamingDistributionConfigResponse
s {$sel:streamingDistributionConfig:GetStreamingDistributionConfigResponse' :: Maybe StreamingDistributionConfig
streamingDistributionConfig = Maybe StreamingDistributionConfig
a} :: GetStreamingDistributionConfigResponse)

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

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

instance
  Prelude.NFData
    GetStreamingDistributionConfigResponse