{-# 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.GetCloudFrontOriginAccessIdentity
-- 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 information about an origin access identity.
module Amazonka.CloudFront.GetCloudFrontOriginAccessIdentity
  ( -- * Creating a Request
    GetCloudFrontOriginAccessIdentity (..),
    newGetCloudFrontOriginAccessIdentity,

    -- * Request Lenses
    getCloudFrontOriginAccessIdentity_id,

    -- * Destructuring the Response
    GetCloudFrontOriginAccessIdentityResponse (..),
    newGetCloudFrontOriginAccessIdentityResponse,

    -- * Response Lenses
    getCloudFrontOriginAccessIdentityResponse_cloudFrontOriginAccessIdentity,
    getCloudFrontOriginAccessIdentityResponse_eTag,
    getCloudFrontOriginAccessIdentityResponse_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 an origin access identity\'s information.
--
-- /See:/ 'newGetCloudFrontOriginAccessIdentity' smart constructor.
data GetCloudFrontOriginAccessIdentity = GetCloudFrontOriginAccessIdentity'
  { -- | The identity\'s ID.
    GetCloudFrontOriginAccessIdentity -> Text
id :: Prelude.Text
  }
  deriving (GetCloudFrontOriginAccessIdentity
-> GetCloudFrontOriginAccessIdentity -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetCloudFrontOriginAccessIdentity
-> GetCloudFrontOriginAccessIdentity -> Bool
$c/= :: GetCloudFrontOriginAccessIdentity
-> GetCloudFrontOriginAccessIdentity -> Bool
== :: GetCloudFrontOriginAccessIdentity
-> GetCloudFrontOriginAccessIdentity -> Bool
$c== :: GetCloudFrontOriginAccessIdentity
-> GetCloudFrontOriginAccessIdentity -> Bool
Prelude.Eq, ReadPrec [GetCloudFrontOriginAccessIdentity]
ReadPrec GetCloudFrontOriginAccessIdentity
Int -> ReadS GetCloudFrontOriginAccessIdentity
ReadS [GetCloudFrontOriginAccessIdentity]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetCloudFrontOriginAccessIdentity]
$creadListPrec :: ReadPrec [GetCloudFrontOriginAccessIdentity]
readPrec :: ReadPrec GetCloudFrontOriginAccessIdentity
$creadPrec :: ReadPrec GetCloudFrontOriginAccessIdentity
readList :: ReadS [GetCloudFrontOriginAccessIdentity]
$creadList :: ReadS [GetCloudFrontOriginAccessIdentity]
readsPrec :: Int -> ReadS GetCloudFrontOriginAccessIdentity
$creadsPrec :: Int -> ReadS GetCloudFrontOriginAccessIdentity
Prelude.Read, Int -> GetCloudFrontOriginAccessIdentity -> ShowS
[GetCloudFrontOriginAccessIdentity] -> ShowS
GetCloudFrontOriginAccessIdentity -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetCloudFrontOriginAccessIdentity] -> ShowS
$cshowList :: [GetCloudFrontOriginAccessIdentity] -> ShowS
show :: GetCloudFrontOriginAccessIdentity -> String
$cshow :: GetCloudFrontOriginAccessIdentity -> String
showsPrec :: Int -> GetCloudFrontOriginAccessIdentity -> ShowS
$cshowsPrec :: Int -> GetCloudFrontOriginAccessIdentity -> ShowS
Prelude.Show, forall x.
Rep GetCloudFrontOriginAccessIdentity x
-> GetCloudFrontOriginAccessIdentity
forall x.
GetCloudFrontOriginAccessIdentity
-> Rep GetCloudFrontOriginAccessIdentity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetCloudFrontOriginAccessIdentity x
-> GetCloudFrontOriginAccessIdentity
$cfrom :: forall x.
GetCloudFrontOriginAccessIdentity
-> Rep GetCloudFrontOriginAccessIdentity x
Prelude.Generic)

-- |
-- Create a value of 'GetCloudFrontOriginAccessIdentity' 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', 'getCloudFrontOriginAccessIdentity_id' - The identity\'s ID.
newGetCloudFrontOriginAccessIdentity ::
  -- | 'id'
  Prelude.Text ->
  GetCloudFrontOriginAccessIdentity
newGetCloudFrontOriginAccessIdentity :: Text -> GetCloudFrontOriginAccessIdentity
newGetCloudFrontOriginAccessIdentity Text
pId_ =
  GetCloudFrontOriginAccessIdentity' {$sel:id:GetCloudFrontOriginAccessIdentity' :: Text
id = Text
pId_}

-- | The identity\'s ID.
getCloudFrontOriginAccessIdentity_id :: Lens.Lens' GetCloudFrontOriginAccessIdentity Prelude.Text
getCloudFrontOriginAccessIdentity_id :: Lens' GetCloudFrontOriginAccessIdentity Text
getCloudFrontOriginAccessIdentity_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCloudFrontOriginAccessIdentity' {Text
id :: Text
$sel:id:GetCloudFrontOriginAccessIdentity' :: GetCloudFrontOriginAccessIdentity -> Text
id} -> Text
id) (\s :: GetCloudFrontOriginAccessIdentity
s@GetCloudFrontOriginAccessIdentity' {} Text
a -> GetCloudFrontOriginAccessIdentity
s {$sel:id:GetCloudFrontOriginAccessIdentity' :: Text
id = Text
a} :: GetCloudFrontOriginAccessIdentity)

instance
  Core.AWSRequest
    GetCloudFrontOriginAccessIdentity
  where
  type
    AWSResponse GetCloudFrontOriginAccessIdentity =
      GetCloudFrontOriginAccessIdentityResponse
  request :: (Service -> Service)
-> GetCloudFrontOriginAccessIdentity
-> Request GetCloudFrontOriginAccessIdentity
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 GetCloudFrontOriginAccessIdentity
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse GetCloudFrontOriginAccessIdentity)))
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 CloudFrontOriginAccessIdentity
-> Maybe Text -> Int -> GetCloudFrontOriginAccessIdentityResponse
GetCloudFrontOriginAccessIdentityResponse'
            forall (f :: * -> *) a b. Functor 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.<*> (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 (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

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

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

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

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

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

-- |
-- Create a value of 'GetCloudFrontOriginAccessIdentityResponse' 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:
--
-- 'cloudFrontOriginAccessIdentity', 'getCloudFrontOriginAccessIdentityResponse_cloudFrontOriginAccessIdentity' - The origin access identity\'s information.
--
-- 'eTag', 'getCloudFrontOriginAccessIdentityResponse_eTag' - The current version of the origin access identity\'s information. For
-- example: @E2QWRUHAPOMQZL@.
--
-- 'httpStatus', 'getCloudFrontOriginAccessIdentityResponse_httpStatus' - The response's http status code.
newGetCloudFrontOriginAccessIdentityResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetCloudFrontOriginAccessIdentityResponse
newGetCloudFrontOriginAccessIdentityResponse :: Int -> GetCloudFrontOriginAccessIdentityResponse
newGetCloudFrontOriginAccessIdentityResponse
  Int
pHttpStatus_ =
    GetCloudFrontOriginAccessIdentityResponse'
      { $sel:cloudFrontOriginAccessIdentity:GetCloudFrontOriginAccessIdentityResponse' :: Maybe CloudFrontOriginAccessIdentity
cloudFrontOriginAccessIdentity =
          forall a. Maybe a
Prelude.Nothing,
        $sel:eTag:GetCloudFrontOriginAccessIdentityResponse' :: Maybe Text
eTag = forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:GetCloudFrontOriginAccessIdentityResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | The origin access identity\'s information.
getCloudFrontOriginAccessIdentityResponse_cloudFrontOriginAccessIdentity :: Lens.Lens' GetCloudFrontOriginAccessIdentityResponse (Prelude.Maybe CloudFrontOriginAccessIdentity)
getCloudFrontOriginAccessIdentityResponse_cloudFrontOriginAccessIdentity :: Lens'
  GetCloudFrontOriginAccessIdentityResponse
  (Maybe CloudFrontOriginAccessIdentity)
getCloudFrontOriginAccessIdentityResponse_cloudFrontOriginAccessIdentity = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCloudFrontOriginAccessIdentityResponse' {Maybe CloudFrontOriginAccessIdentity
cloudFrontOriginAccessIdentity :: Maybe CloudFrontOriginAccessIdentity
$sel:cloudFrontOriginAccessIdentity:GetCloudFrontOriginAccessIdentityResponse' :: GetCloudFrontOriginAccessIdentityResponse
-> Maybe CloudFrontOriginAccessIdentity
cloudFrontOriginAccessIdentity} -> Maybe CloudFrontOriginAccessIdentity
cloudFrontOriginAccessIdentity) (\s :: GetCloudFrontOriginAccessIdentityResponse
s@GetCloudFrontOriginAccessIdentityResponse' {} Maybe CloudFrontOriginAccessIdentity
a -> GetCloudFrontOriginAccessIdentityResponse
s {$sel:cloudFrontOriginAccessIdentity:GetCloudFrontOriginAccessIdentityResponse' :: Maybe CloudFrontOriginAccessIdentity
cloudFrontOriginAccessIdentity = Maybe CloudFrontOriginAccessIdentity
a} :: GetCloudFrontOriginAccessIdentityResponse)

-- | The current version of the origin access identity\'s information. For
-- example: @E2QWRUHAPOMQZL@.
getCloudFrontOriginAccessIdentityResponse_eTag :: Lens.Lens' GetCloudFrontOriginAccessIdentityResponse (Prelude.Maybe Prelude.Text)
getCloudFrontOriginAccessIdentityResponse_eTag :: Lens' GetCloudFrontOriginAccessIdentityResponse (Maybe Text)
getCloudFrontOriginAccessIdentityResponse_eTag = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCloudFrontOriginAccessIdentityResponse' {Maybe Text
eTag :: Maybe Text
$sel:eTag:GetCloudFrontOriginAccessIdentityResponse' :: GetCloudFrontOriginAccessIdentityResponse -> Maybe Text
eTag} -> Maybe Text
eTag) (\s :: GetCloudFrontOriginAccessIdentityResponse
s@GetCloudFrontOriginAccessIdentityResponse' {} Maybe Text
a -> GetCloudFrontOriginAccessIdentityResponse
s {$sel:eTag:GetCloudFrontOriginAccessIdentityResponse' :: Maybe Text
eTag = Maybe Text
a} :: GetCloudFrontOriginAccessIdentityResponse)

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

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