{-# 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.GetOriginAccessControl
-- 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, including its unique
-- identifier.
module Amazonka.CloudFront.GetOriginAccessControl
  ( -- * Creating a Request
    GetOriginAccessControl (..),
    newGetOriginAccessControl,

    -- * Request Lenses
    getOriginAccessControl_id,

    -- * Destructuring the Response
    GetOriginAccessControlResponse (..),
    newGetOriginAccessControlResponse,

    -- * Response Lenses
    getOriginAccessControlResponse_eTag,
    getOriginAccessControlResponse_originAccessControl,
    getOriginAccessControlResponse_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:/ 'newGetOriginAccessControl' smart constructor.
data GetOriginAccessControl = GetOriginAccessControl'
  { -- | The unique identifier of the origin access control.
    GetOriginAccessControl -> Text
id :: Prelude.Text
  }
  deriving (GetOriginAccessControl -> GetOriginAccessControl -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetOriginAccessControl -> GetOriginAccessControl -> Bool
$c/= :: GetOriginAccessControl -> GetOriginAccessControl -> Bool
== :: GetOriginAccessControl -> GetOriginAccessControl -> Bool
$c== :: GetOriginAccessControl -> GetOriginAccessControl -> Bool
Prelude.Eq, ReadPrec [GetOriginAccessControl]
ReadPrec GetOriginAccessControl
Int -> ReadS GetOriginAccessControl
ReadS [GetOriginAccessControl]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetOriginAccessControl]
$creadListPrec :: ReadPrec [GetOriginAccessControl]
readPrec :: ReadPrec GetOriginAccessControl
$creadPrec :: ReadPrec GetOriginAccessControl
readList :: ReadS [GetOriginAccessControl]
$creadList :: ReadS [GetOriginAccessControl]
readsPrec :: Int -> ReadS GetOriginAccessControl
$creadsPrec :: Int -> ReadS GetOriginAccessControl
Prelude.Read, Int -> GetOriginAccessControl -> ShowS
[GetOriginAccessControl] -> ShowS
GetOriginAccessControl -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetOriginAccessControl] -> ShowS
$cshowList :: [GetOriginAccessControl] -> ShowS
show :: GetOriginAccessControl -> String
$cshow :: GetOriginAccessControl -> String
showsPrec :: Int -> GetOriginAccessControl -> ShowS
$cshowsPrec :: Int -> GetOriginAccessControl -> ShowS
Prelude.Show, forall x. Rep GetOriginAccessControl x -> GetOriginAccessControl
forall x. GetOriginAccessControl -> Rep GetOriginAccessControl x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetOriginAccessControl x -> GetOriginAccessControl
$cfrom :: forall x. GetOriginAccessControl -> Rep GetOriginAccessControl x
Prelude.Generic)

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

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

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

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

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

instance Data.ToPath GetOriginAccessControl where
  toPath :: GetOriginAccessControl -> ByteString
toPath GetOriginAccessControl' {Text
id :: Text
$sel:id:GetOriginAccessControl' :: GetOriginAccessControl -> 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]

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

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

-- |
-- Create a value of 'GetOriginAccessControlResponse' 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', 'getOriginAccessControlResponse_eTag' - The version identifier for the current version of the origin access
-- control.
--
-- 'originAccessControl', 'getOriginAccessControlResponse_originAccessControl' - Contains an origin access control, including its unique identifier.
--
-- 'httpStatus', 'getOriginAccessControlResponse_httpStatus' - The response's http status code.
newGetOriginAccessControlResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetOriginAccessControlResponse
newGetOriginAccessControlResponse :: Int -> GetOriginAccessControlResponse
newGetOriginAccessControlResponse Int
pHttpStatus_ =
  GetOriginAccessControlResponse'
    { $sel:eTag:GetOriginAccessControlResponse' :: Maybe Text
eTag =
        forall a. Maybe a
Prelude.Nothing,
      $sel:originAccessControl:GetOriginAccessControlResponse' :: Maybe OriginAccessControl
originAccessControl = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetOriginAccessControlResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

-- | Contains an origin access control, including its unique identifier.
getOriginAccessControlResponse_originAccessControl :: Lens.Lens' GetOriginAccessControlResponse (Prelude.Maybe OriginAccessControl)
getOriginAccessControlResponse_originAccessControl :: Lens' GetOriginAccessControlResponse (Maybe OriginAccessControl)
getOriginAccessControlResponse_originAccessControl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetOriginAccessControlResponse' {Maybe OriginAccessControl
originAccessControl :: Maybe OriginAccessControl
$sel:originAccessControl:GetOriginAccessControlResponse' :: GetOriginAccessControlResponse -> Maybe OriginAccessControl
originAccessControl} -> Maybe OriginAccessControl
originAccessControl) (\s :: GetOriginAccessControlResponse
s@GetOriginAccessControlResponse' {} Maybe OriginAccessControl
a -> GetOriginAccessControlResponse
s {$sel:originAccessControl:GetOriginAccessControlResponse' :: Maybe OriginAccessControl
originAccessControl = Maybe OriginAccessControl
a} :: GetOriginAccessControlResponse)

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

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