{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.CloudFrontOriginAccessIdentity
-- 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)
module Amazonka.CloudFront.Types.CloudFrontOriginAccessIdentity where

import Amazonka.CloudFront.Types.CloudFrontOriginAccessIdentityConfig
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | CloudFront origin access identity.
--
-- /See:/ 'newCloudFrontOriginAccessIdentity' smart constructor.
data CloudFrontOriginAccessIdentity = CloudFrontOriginAccessIdentity'
  { -- | The current configuration information for the identity.
    CloudFrontOriginAccessIdentity
-> Maybe CloudFrontOriginAccessIdentityConfig
cloudFrontOriginAccessIdentityConfig :: Prelude.Maybe CloudFrontOriginAccessIdentityConfig,
    -- | The ID for the origin access identity, for example, @E74FTE3AJFJ256A@.
    CloudFrontOriginAccessIdentity -> Text
id :: Prelude.Text,
    -- | The Amazon S3 canonical user ID for the origin access identity, used
    -- when giving the origin access identity read permission to an object in
    -- Amazon S3.
    CloudFrontOriginAccessIdentity -> Text
s3CanonicalUserId :: Prelude.Text
  }
  deriving (CloudFrontOriginAccessIdentity
-> CloudFrontOriginAccessIdentity -> Bool
(CloudFrontOriginAccessIdentity
 -> CloudFrontOriginAccessIdentity -> Bool)
-> (CloudFrontOriginAccessIdentity
    -> CloudFrontOriginAccessIdentity -> Bool)
-> Eq CloudFrontOriginAccessIdentity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CloudFrontOriginAccessIdentity
-> CloudFrontOriginAccessIdentity -> Bool
$c/= :: CloudFrontOriginAccessIdentity
-> CloudFrontOriginAccessIdentity -> Bool
== :: CloudFrontOriginAccessIdentity
-> CloudFrontOriginAccessIdentity -> Bool
$c== :: CloudFrontOriginAccessIdentity
-> CloudFrontOriginAccessIdentity -> Bool
Prelude.Eq, ReadPrec [CloudFrontOriginAccessIdentity]
ReadPrec CloudFrontOriginAccessIdentity
Int -> ReadS CloudFrontOriginAccessIdentity
ReadS [CloudFrontOriginAccessIdentity]
(Int -> ReadS CloudFrontOriginAccessIdentity)
-> ReadS [CloudFrontOriginAccessIdentity]
-> ReadPrec CloudFrontOriginAccessIdentity
-> ReadPrec [CloudFrontOriginAccessIdentity]
-> Read CloudFrontOriginAccessIdentity
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CloudFrontOriginAccessIdentity]
$creadListPrec :: ReadPrec [CloudFrontOriginAccessIdentity]
readPrec :: ReadPrec CloudFrontOriginAccessIdentity
$creadPrec :: ReadPrec CloudFrontOriginAccessIdentity
readList :: ReadS [CloudFrontOriginAccessIdentity]
$creadList :: ReadS [CloudFrontOriginAccessIdentity]
readsPrec :: Int -> ReadS CloudFrontOriginAccessIdentity
$creadsPrec :: Int -> ReadS CloudFrontOriginAccessIdentity
Prelude.Read, Int -> CloudFrontOriginAccessIdentity -> ShowS
[CloudFrontOriginAccessIdentity] -> ShowS
CloudFrontOriginAccessIdentity -> String
(Int -> CloudFrontOriginAccessIdentity -> ShowS)
-> (CloudFrontOriginAccessIdentity -> String)
-> ([CloudFrontOriginAccessIdentity] -> ShowS)
-> Show CloudFrontOriginAccessIdentity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CloudFrontOriginAccessIdentity] -> ShowS
$cshowList :: [CloudFrontOriginAccessIdentity] -> ShowS
show :: CloudFrontOriginAccessIdentity -> String
$cshow :: CloudFrontOriginAccessIdentity -> String
showsPrec :: Int -> CloudFrontOriginAccessIdentity -> ShowS
$cshowsPrec :: Int -> CloudFrontOriginAccessIdentity -> ShowS
Prelude.Show, (forall x.
 CloudFrontOriginAccessIdentity
 -> Rep CloudFrontOriginAccessIdentity x)
-> (forall x.
    Rep CloudFrontOriginAccessIdentity x
    -> CloudFrontOriginAccessIdentity)
-> Generic CloudFrontOriginAccessIdentity
forall x.
Rep CloudFrontOriginAccessIdentity x
-> CloudFrontOriginAccessIdentity
forall x.
CloudFrontOriginAccessIdentity
-> Rep CloudFrontOriginAccessIdentity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CloudFrontOriginAccessIdentity x
-> CloudFrontOriginAccessIdentity
$cfrom :: forall x.
CloudFrontOriginAccessIdentity
-> Rep CloudFrontOriginAccessIdentity x
Prelude.Generic)

-- |
-- Create a value of 'CloudFrontOriginAccessIdentity' 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:
--
-- 'cloudFrontOriginAccessIdentityConfig', 'cloudFrontOriginAccessIdentity_cloudFrontOriginAccessIdentityConfig' - The current configuration information for the identity.
--
-- 'id', 'cloudFrontOriginAccessIdentity_id' - The ID for the origin access identity, for example, @E74FTE3AJFJ256A@.
--
-- 's3CanonicalUserId', 'cloudFrontOriginAccessIdentity_s3CanonicalUserId' - The Amazon S3 canonical user ID for the origin access identity, used
-- when giving the origin access identity read permission to an object in
-- Amazon S3.
newCloudFrontOriginAccessIdentity ::
  -- | 'id'
  Prelude.Text ->
  -- | 's3CanonicalUserId'
  Prelude.Text ->
  CloudFrontOriginAccessIdentity
newCloudFrontOriginAccessIdentity :: Text -> Text -> CloudFrontOriginAccessIdentity
newCloudFrontOriginAccessIdentity
  Text
pId_
  Text
pS3CanonicalUserId_ =
    CloudFrontOriginAccessIdentity' :: Maybe CloudFrontOriginAccessIdentityConfig
-> Text -> Text -> CloudFrontOriginAccessIdentity
CloudFrontOriginAccessIdentity'
      { $sel:cloudFrontOriginAccessIdentityConfig:CloudFrontOriginAccessIdentity' :: Maybe CloudFrontOriginAccessIdentityConfig
cloudFrontOriginAccessIdentityConfig =
          Maybe CloudFrontOriginAccessIdentityConfig
forall a. Maybe a
Prelude.Nothing,
        $sel:id:CloudFrontOriginAccessIdentity' :: Text
id = Text
pId_,
        $sel:s3CanonicalUserId:CloudFrontOriginAccessIdentity' :: Text
s3CanonicalUserId = Text
pS3CanonicalUserId_
      }

-- | The current configuration information for the identity.
cloudFrontOriginAccessIdentity_cloudFrontOriginAccessIdentityConfig :: Lens.Lens' CloudFrontOriginAccessIdentity (Prelude.Maybe CloudFrontOriginAccessIdentityConfig)
cloudFrontOriginAccessIdentity_cloudFrontOriginAccessIdentityConfig :: (Maybe CloudFrontOriginAccessIdentityConfig
 -> f (Maybe CloudFrontOriginAccessIdentityConfig))
-> CloudFrontOriginAccessIdentity
-> f CloudFrontOriginAccessIdentity
cloudFrontOriginAccessIdentity_cloudFrontOriginAccessIdentityConfig = (CloudFrontOriginAccessIdentity
 -> Maybe CloudFrontOriginAccessIdentityConfig)
-> (CloudFrontOriginAccessIdentity
    -> Maybe CloudFrontOriginAccessIdentityConfig
    -> CloudFrontOriginAccessIdentity)
-> Lens
     CloudFrontOriginAccessIdentity
     CloudFrontOriginAccessIdentity
     (Maybe CloudFrontOriginAccessIdentityConfig)
     (Maybe CloudFrontOriginAccessIdentityConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudFrontOriginAccessIdentity' {Maybe CloudFrontOriginAccessIdentityConfig
cloudFrontOriginAccessIdentityConfig :: Maybe CloudFrontOriginAccessIdentityConfig
$sel:cloudFrontOriginAccessIdentityConfig:CloudFrontOriginAccessIdentity' :: CloudFrontOriginAccessIdentity
-> Maybe CloudFrontOriginAccessIdentityConfig
cloudFrontOriginAccessIdentityConfig} -> Maybe CloudFrontOriginAccessIdentityConfig
cloudFrontOriginAccessIdentityConfig) (\s :: CloudFrontOriginAccessIdentity
s@CloudFrontOriginAccessIdentity' {} Maybe CloudFrontOriginAccessIdentityConfig
a -> CloudFrontOriginAccessIdentity
s {$sel:cloudFrontOriginAccessIdentityConfig:CloudFrontOriginAccessIdentity' :: Maybe CloudFrontOriginAccessIdentityConfig
cloudFrontOriginAccessIdentityConfig = Maybe CloudFrontOriginAccessIdentityConfig
a} :: CloudFrontOriginAccessIdentity)

-- | The ID for the origin access identity, for example, @E74FTE3AJFJ256A@.
cloudFrontOriginAccessIdentity_id :: Lens.Lens' CloudFrontOriginAccessIdentity Prelude.Text
cloudFrontOriginAccessIdentity_id :: (Text -> f Text)
-> CloudFrontOriginAccessIdentity
-> f CloudFrontOriginAccessIdentity
cloudFrontOriginAccessIdentity_id = (CloudFrontOriginAccessIdentity -> Text)
-> (CloudFrontOriginAccessIdentity
    -> Text -> CloudFrontOriginAccessIdentity)
-> Lens
     CloudFrontOriginAccessIdentity
     CloudFrontOriginAccessIdentity
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudFrontOriginAccessIdentity' {Text
id :: Text
$sel:id:CloudFrontOriginAccessIdentity' :: CloudFrontOriginAccessIdentity -> Text
id} -> Text
id) (\s :: CloudFrontOriginAccessIdentity
s@CloudFrontOriginAccessIdentity' {} Text
a -> CloudFrontOriginAccessIdentity
s {$sel:id:CloudFrontOriginAccessIdentity' :: Text
id = Text
a} :: CloudFrontOriginAccessIdentity)

-- | The Amazon S3 canonical user ID for the origin access identity, used
-- when giving the origin access identity read permission to an object in
-- Amazon S3.
cloudFrontOriginAccessIdentity_s3CanonicalUserId :: Lens.Lens' CloudFrontOriginAccessIdentity Prelude.Text
cloudFrontOriginAccessIdentity_s3CanonicalUserId :: (Text -> f Text)
-> CloudFrontOriginAccessIdentity
-> f CloudFrontOriginAccessIdentity
cloudFrontOriginAccessIdentity_s3CanonicalUserId = (CloudFrontOriginAccessIdentity -> Text)
-> (CloudFrontOriginAccessIdentity
    -> Text -> CloudFrontOriginAccessIdentity)
-> Lens
     CloudFrontOriginAccessIdentity
     CloudFrontOriginAccessIdentity
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudFrontOriginAccessIdentity' {Text
s3CanonicalUserId :: Text
$sel:s3CanonicalUserId:CloudFrontOriginAccessIdentity' :: CloudFrontOriginAccessIdentity -> Text
s3CanonicalUserId} -> Text
s3CanonicalUserId) (\s :: CloudFrontOriginAccessIdentity
s@CloudFrontOriginAccessIdentity' {} Text
a -> CloudFrontOriginAccessIdentity
s {$sel:s3CanonicalUserId:CloudFrontOriginAccessIdentity' :: Text
s3CanonicalUserId = Text
a} :: CloudFrontOriginAccessIdentity)

instance Core.FromXML CloudFrontOriginAccessIdentity where
  parseXML :: [Node] -> Either String CloudFrontOriginAccessIdentity
parseXML [Node]
x =
    Maybe CloudFrontOriginAccessIdentityConfig
-> Text -> Text -> CloudFrontOriginAccessIdentity
CloudFrontOriginAccessIdentity'
      (Maybe CloudFrontOriginAccessIdentityConfig
 -> Text -> Text -> CloudFrontOriginAccessIdentity)
-> Either String (Maybe CloudFrontOriginAccessIdentityConfig)
-> Either String (Text -> Text -> CloudFrontOriginAccessIdentity)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node]
-> Text
-> Either String (Maybe CloudFrontOriginAccessIdentityConfig)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"CloudFrontOriginAccessIdentityConfig")
      Either String (Text -> Text -> CloudFrontOriginAccessIdentity)
-> Either String Text
-> Either String (Text -> CloudFrontOriginAccessIdentity)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Id")
      Either String (Text -> CloudFrontOriginAccessIdentity)
-> Either String Text
-> Either String CloudFrontOriginAccessIdentity
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"S3CanonicalUserId")

instance
  Prelude.Hashable
    CloudFrontOriginAccessIdentity

instance
  Prelude.NFData
    CloudFrontOriginAccessIdentity