{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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_eTag,
    getStreamingDistributionConfigResponse_streamingDistributionConfig,
    getStreamingDistributionConfigResponse_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

-- | 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
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]
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
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.
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' {$sel:id:GetStreamingDistributionConfig' :: Text
id = Text
pId_}

-- | The streaming distribution\'s ID.
getStreamingDistributionConfig_id :: Lens.Lens' GetStreamingDistributionConfig Prelude.Text
getStreamingDistributionConfig_id :: Lens' GetStreamingDistributionConfig Text
getStreamingDistributionConfig_id = 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 :: (Service -> Service)
-> GetStreamingDistributionConfig
-> Request GetStreamingDistributionConfig
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 GetStreamingDistributionConfig
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse GetStreamingDistributionConfig)))
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 StreamingDistributionConfig
-> Int
-> GetStreamingDistributionConfigResponse
GetStreamingDistributionConfigResponse'
            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
    GetStreamingDistributionConfig
  where
  hashWithSalt :: Int -> GetStreamingDistributionConfig -> Int
hashWithSalt
    Int
_salt
    GetStreamingDistributionConfig' {Text
id :: Text
$sel:id:GetStreamingDistributionConfig' :: GetStreamingDistributionConfig -> Text
..} =
      Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id

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

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

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

instance Data.ToQuery GetStreamingDistributionConfig where
  toQuery :: GetStreamingDistributionConfig -> 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:/ 'newGetStreamingDistributionConfigResponse' smart constructor.
data GetStreamingDistributionConfigResponse = GetStreamingDistributionConfigResponse'
  { -- | The current version of the configuration. For example: @E2QWRUHAPOMQZL@.
    GetStreamingDistributionConfigResponse -> Maybe Text
eTag :: Prelude.Maybe Prelude.Text,
    -- | The streaming distribution\'s configuration information.
    GetStreamingDistributionConfigResponse
-> Maybe StreamingDistributionConfig
streamingDistributionConfig :: Prelude.Maybe StreamingDistributionConfig,
    -- | The response's http status code.
    GetStreamingDistributionConfigResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetStreamingDistributionConfigResponse
-> GetStreamingDistributionConfigResponse -> Bool
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]
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
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.
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:
--
-- 'eTag', 'getStreamingDistributionConfigResponse_eTag' - The current version of the configuration. For example: @E2QWRUHAPOMQZL@.
--
-- 'streamingDistributionConfig', 'getStreamingDistributionConfigResponse_streamingDistributionConfig' - The streaming distribution\'s configuration information.
--
-- 'httpStatus', 'getStreamingDistributionConfigResponse_httpStatus' - The response's http status code.
newGetStreamingDistributionConfigResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetStreamingDistributionConfigResponse
newGetStreamingDistributionConfigResponse :: Int -> GetStreamingDistributionConfigResponse
newGetStreamingDistributionConfigResponse
  Int
pHttpStatus_ =
    GetStreamingDistributionConfigResponse'
      { $sel:eTag:GetStreamingDistributionConfigResponse' :: Maybe Text
eTag =
          forall a. Maybe a
Prelude.Nothing,
        $sel:streamingDistributionConfig:GetStreamingDistributionConfigResponse' :: Maybe StreamingDistributionConfig
streamingDistributionConfig =
          forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:GetStreamingDistributionConfigResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | The current version of the configuration. For example: @E2QWRUHAPOMQZL@.
getStreamingDistributionConfigResponse_eTag :: Lens.Lens' GetStreamingDistributionConfigResponse (Prelude.Maybe Prelude.Text)
getStreamingDistributionConfigResponse_eTag :: Lens' GetStreamingDistributionConfigResponse (Maybe Text)
getStreamingDistributionConfigResponse_eTag = 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 streaming distribution\'s configuration information.
getStreamingDistributionConfigResponse_streamingDistributionConfig :: Lens.Lens' GetStreamingDistributionConfigResponse (Prelude.Maybe StreamingDistributionConfig)
getStreamingDistributionConfigResponse_streamingDistributionConfig :: Lens'
  GetStreamingDistributionConfigResponse
  (Maybe StreamingDistributionConfig)
getStreamingDistributionConfigResponse_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 response's http status code.
getStreamingDistributionConfigResponse_httpStatus :: Lens.Lens' GetStreamingDistributionConfigResponse Prelude.Int
getStreamingDistributionConfigResponse_httpStatus :: Lens' GetStreamingDistributionConfigResponse Int
getStreamingDistributionConfigResponse_httpStatus = 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
  where
  rnf :: GetStreamingDistributionConfigResponse -> ()
rnf GetStreamingDistributionConfigResponse' {Int
Maybe Text
Maybe StreamingDistributionConfig
httpStatus :: Int
streamingDistributionConfig :: Maybe StreamingDistributionConfig
eTag :: Maybe Text
$sel:httpStatus:GetStreamingDistributionConfigResponse' :: GetStreamingDistributionConfigResponse -> Int
$sel:streamingDistributionConfig:GetStreamingDistributionConfigResponse' :: GetStreamingDistributionConfigResponse
-> Maybe StreamingDistributionConfig
$sel:eTag:GetStreamingDistributionConfigResponse' :: GetStreamingDistributionConfigResponse -> 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 StreamingDistributionConfig
streamingDistributionConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus