{-# 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.GetOriginAccessControlConfig
-- 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 a CloudFront origin access control configuration.
module Amazonka.CloudFront.GetOriginAccessControlConfig
  ( -- * Creating a Request
    GetOriginAccessControlConfig (..),
    newGetOriginAccessControlConfig,

    -- * Request Lenses
    getOriginAccessControlConfig_id,

    -- * Destructuring the Response
    GetOriginAccessControlConfigResponse (..),
    newGetOriginAccessControlConfigResponse,

    -- * Response Lenses
    getOriginAccessControlConfigResponse_eTag,
    getOriginAccessControlConfigResponse_originAccessControlConfig,
    getOriginAccessControlConfigResponse_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

-- | /See:/ 'newGetOriginAccessControlConfig' smart constructor.
data GetOriginAccessControlConfig = GetOriginAccessControlConfig'
  { -- | The unique identifier of the origin access control.
    GetOriginAccessControlConfig -> Text
id :: Prelude.Text
  }
  deriving (GetOriginAccessControlConfig
-> GetOriginAccessControlConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetOriginAccessControlConfig
-> GetOriginAccessControlConfig -> Bool
$c/= :: GetOriginAccessControlConfig
-> GetOriginAccessControlConfig -> Bool
== :: GetOriginAccessControlConfig
-> GetOriginAccessControlConfig -> Bool
$c== :: GetOriginAccessControlConfig
-> GetOriginAccessControlConfig -> Bool
Prelude.Eq, ReadPrec [GetOriginAccessControlConfig]
ReadPrec GetOriginAccessControlConfig
Int -> ReadS GetOriginAccessControlConfig
ReadS [GetOriginAccessControlConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetOriginAccessControlConfig]
$creadListPrec :: ReadPrec [GetOriginAccessControlConfig]
readPrec :: ReadPrec GetOriginAccessControlConfig
$creadPrec :: ReadPrec GetOriginAccessControlConfig
readList :: ReadS [GetOriginAccessControlConfig]
$creadList :: ReadS [GetOriginAccessControlConfig]
readsPrec :: Int -> ReadS GetOriginAccessControlConfig
$creadsPrec :: Int -> ReadS GetOriginAccessControlConfig
Prelude.Read, Int -> GetOriginAccessControlConfig -> ShowS
[GetOriginAccessControlConfig] -> ShowS
GetOriginAccessControlConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetOriginAccessControlConfig] -> ShowS
$cshowList :: [GetOriginAccessControlConfig] -> ShowS
show :: GetOriginAccessControlConfig -> String
$cshow :: GetOriginAccessControlConfig -> String
showsPrec :: Int -> GetOriginAccessControlConfig -> ShowS
$cshowsPrec :: Int -> GetOriginAccessControlConfig -> ShowS
Prelude.Show, forall x.
Rep GetOriginAccessControlConfig x -> GetOriginAccessControlConfig
forall x.
GetOriginAccessControlConfig -> Rep GetOriginAccessControlConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetOriginAccessControlConfig x -> GetOriginAccessControlConfig
$cfrom :: forall x.
GetOriginAccessControlConfig -> Rep GetOriginAccessControlConfig x
Prelude.Generic)

-- |
-- Create a value of 'GetOriginAccessControlConfig' 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', 'getOriginAccessControlConfig_id' - The unique identifier of the origin access control.
newGetOriginAccessControlConfig ::
  -- | 'id'
  Prelude.Text ->
  GetOriginAccessControlConfig
newGetOriginAccessControlConfig :: Text -> GetOriginAccessControlConfig
newGetOriginAccessControlConfig Text
pId_ =
  GetOriginAccessControlConfig' {$sel:id:GetOriginAccessControlConfig' :: Text
id = Text
pId_}

-- | The unique identifier of the origin access control.
getOriginAccessControlConfig_id :: Lens.Lens' GetOriginAccessControlConfig Prelude.Text
getOriginAccessControlConfig_id :: Lens' GetOriginAccessControlConfig Text
getOriginAccessControlConfig_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetOriginAccessControlConfig' {Text
id :: Text
$sel:id:GetOriginAccessControlConfig' :: GetOriginAccessControlConfig -> Text
id} -> Text
id) (\s :: GetOriginAccessControlConfig
s@GetOriginAccessControlConfig' {} Text
a -> GetOriginAccessControlConfig
s {$sel:id:GetOriginAccessControlConfig' :: Text
id = Text
a} :: GetOriginAccessControlConfig)

instance Core.AWSRequest GetOriginAccessControlConfig where
  type
    AWSResponse GetOriginAccessControlConfig =
      GetOriginAccessControlConfigResponse
  request :: (Service -> Service)
-> GetOriginAccessControlConfig
-> Request GetOriginAccessControlConfig
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 GetOriginAccessControlConfig
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetOriginAccessControlConfig)))
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 OriginAccessControlConfig
-> Int
-> GetOriginAccessControlConfigResponse
GetOriginAccessControlConfigResponse'
            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
    GetOriginAccessControlConfig
  where
  hashWithSalt :: Int -> GetOriginAccessControlConfig -> Int
hashWithSalt Int
_salt GetOriginAccessControlConfig' {Text
id :: Text
$sel:id:GetOriginAccessControlConfig' :: GetOriginAccessControlConfig -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id

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

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

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

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

-- | /See:/ 'newGetOriginAccessControlConfigResponse' smart constructor.
data GetOriginAccessControlConfigResponse = GetOriginAccessControlConfigResponse'
  { -- | The version identifier for the current version of the origin access
    -- control.
    GetOriginAccessControlConfigResponse -> Maybe Text
eTag :: Prelude.Maybe Prelude.Text,
    -- | Contains an origin access control configuration.
    GetOriginAccessControlConfigResponse
-> Maybe OriginAccessControlConfig
originAccessControlConfig :: Prelude.Maybe OriginAccessControlConfig,
    -- | The response's http status code.
    GetOriginAccessControlConfigResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetOriginAccessControlConfigResponse
-> GetOriginAccessControlConfigResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetOriginAccessControlConfigResponse
-> GetOriginAccessControlConfigResponse -> Bool
$c/= :: GetOriginAccessControlConfigResponse
-> GetOriginAccessControlConfigResponse -> Bool
== :: GetOriginAccessControlConfigResponse
-> GetOriginAccessControlConfigResponse -> Bool
$c== :: GetOriginAccessControlConfigResponse
-> GetOriginAccessControlConfigResponse -> Bool
Prelude.Eq, ReadPrec [GetOriginAccessControlConfigResponse]
ReadPrec GetOriginAccessControlConfigResponse
Int -> ReadS GetOriginAccessControlConfigResponse
ReadS [GetOriginAccessControlConfigResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetOriginAccessControlConfigResponse]
$creadListPrec :: ReadPrec [GetOriginAccessControlConfigResponse]
readPrec :: ReadPrec GetOriginAccessControlConfigResponse
$creadPrec :: ReadPrec GetOriginAccessControlConfigResponse
readList :: ReadS [GetOriginAccessControlConfigResponse]
$creadList :: ReadS [GetOriginAccessControlConfigResponse]
readsPrec :: Int -> ReadS GetOriginAccessControlConfigResponse
$creadsPrec :: Int -> ReadS GetOriginAccessControlConfigResponse
Prelude.Read, Int -> GetOriginAccessControlConfigResponse -> ShowS
[GetOriginAccessControlConfigResponse] -> ShowS
GetOriginAccessControlConfigResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetOriginAccessControlConfigResponse] -> ShowS
$cshowList :: [GetOriginAccessControlConfigResponse] -> ShowS
show :: GetOriginAccessControlConfigResponse -> String
$cshow :: GetOriginAccessControlConfigResponse -> String
showsPrec :: Int -> GetOriginAccessControlConfigResponse -> ShowS
$cshowsPrec :: Int -> GetOriginAccessControlConfigResponse -> ShowS
Prelude.Show, forall x.
Rep GetOriginAccessControlConfigResponse x
-> GetOriginAccessControlConfigResponse
forall x.
GetOriginAccessControlConfigResponse
-> Rep GetOriginAccessControlConfigResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetOriginAccessControlConfigResponse x
-> GetOriginAccessControlConfigResponse
$cfrom :: forall x.
GetOriginAccessControlConfigResponse
-> Rep GetOriginAccessControlConfigResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetOriginAccessControlConfigResponse' 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', 'getOriginAccessControlConfigResponse_eTag' - The version identifier for the current version of the origin access
-- control.
--
-- 'originAccessControlConfig', 'getOriginAccessControlConfigResponse_originAccessControlConfig' - Contains an origin access control configuration.
--
-- 'httpStatus', 'getOriginAccessControlConfigResponse_httpStatus' - The response's http status code.
newGetOriginAccessControlConfigResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetOriginAccessControlConfigResponse
newGetOriginAccessControlConfigResponse :: Int -> GetOriginAccessControlConfigResponse
newGetOriginAccessControlConfigResponse Int
pHttpStatus_ =
  GetOriginAccessControlConfigResponse'
    { $sel:eTag:GetOriginAccessControlConfigResponse' :: Maybe Text
eTag =
        forall a. Maybe a
Prelude.Nothing,
      $sel:originAccessControlConfig:GetOriginAccessControlConfigResponse' :: Maybe OriginAccessControlConfig
originAccessControlConfig =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetOriginAccessControlConfigResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The version identifier for the current version of the origin access
-- control.
getOriginAccessControlConfigResponse_eTag :: Lens.Lens' GetOriginAccessControlConfigResponse (Prelude.Maybe Prelude.Text)
getOriginAccessControlConfigResponse_eTag :: Lens' GetOriginAccessControlConfigResponse (Maybe Text)
getOriginAccessControlConfigResponse_eTag = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetOriginAccessControlConfigResponse' {Maybe Text
eTag :: Maybe Text
$sel:eTag:GetOriginAccessControlConfigResponse' :: GetOriginAccessControlConfigResponse -> Maybe Text
eTag} -> Maybe Text
eTag) (\s :: GetOriginAccessControlConfigResponse
s@GetOriginAccessControlConfigResponse' {} Maybe Text
a -> GetOriginAccessControlConfigResponse
s {$sel:eTag:GetOriginAccessControlConfigResponse' :: Maybe Text
eTag = Maybe Text
a} :: GetOriginAccessControlConfigResponse)

-- | Contains an origin access control configuration.
getOriginAccessControlConfigResponse_originAccessControlConfig :: Lens.Lens' GetOriginAccessControlConfigResponse (Prelude.Maybe OriginAccessControlConfig)
getOriginAccessControlConfigResponse_originAccessControlConfig :: Lens'
  GetOriginAccessControlConfigResponse
  (Maybe OriginAccessControlConfig)
getOriginAccessControlConfigResponse_originAccessControlConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetOriginAccessControlConfigResponse' {Maybe OriginAccessControlConfig
originAccessControlConfig :: Maybe OriginAccessControlConfig
$sel:originAccessControlConfig:GetOriginAccessControlConfigResponse' :: GetOriginAccessControlConfigResponse
-> Maybe OriginAccessControlConfig
originAccessControlConfig} -> Maybe OriginAccessControlConfig
originAccessControlConfig) (\s :: GetOriginAccessControlConfigResponse
s@GetOriginAccessControlConfigResponse' {} Maybe OriginAccessControlConfig
a -> GetOriginAccessControlConfigResponse
s {$sel:originAccessControlConfig:GetOriginAccessControlConfigResponse' :: Maybe OriginAccessControlConfig
originAccessControlConfig = Maybe OriginAccessControlConfig
a} :: GetOriginAccessControlConfigResponse)

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

instance
  Prelude.NFData
    GetOriginAccessControlConfigResponse
  where
  rnf :: GetOriginAccessControlConfigResponse -> ()
rnf GetOriginAccessControlConfigResponse' {Int
Maybe Text
Maybe OriginAccessControlConfig
httpStatus :: Int
originAccessControlConfig :: Maybe OriginAccessControlConfig
eTag :: Maybe Text
$sel:httpStatus:GetOriginAccessControlConfigResponse' :: GetOriginAccessControlConfigResponse -> Int
$sel:originAccessControlConfig:GetOriginAccessControlConfigResponse' :: GetOriginAccessControlConfigResponse
-> Maybe OriginAccessControlConfig
$sel:eTag:GetOriginAccessControlConfigResponse' :: GetOriginAccessControlConfigResponse -> 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 OriginAccessControlConfig
originAccessControlConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus