{-# 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.CloudFrontOriginAccessIdentityConfig
-- 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.CloudFrontOriginAccessIdentityConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Origin access identity configuration. Send a @GET@ request to the
-- @\/CloudFront API version\/CloudFront\/identity ID\/config@ resource.
--
-- /See:/ 'newCloudFrontOriginAccessIdentityConfig' smart constructor.
data CloudFrontOriginAccessIdentityConfig = CloudFrontOriginAccessIdentityConfig'
  { -- | A unique value (for example, a date-time stamp) that ensures that the
    -- request can\'t be replayed.
    --
    -- If the value of @CallerReference@ is new (regardless of the content of
    -- the @CloudFrontOriginAccessIdentityConfig@ object), a new origin access
    -- identity is created.
    --
    -- If the @CallerReference@ is a value already sent in a previous identity
    -- request, and the content of the @CloudFrontOriginAccessIdentityConfig@
    -- is identical to the original request (ignoring white space), the
    -- response includes the same information returned to the original request.
    --
    -- If the @CallerReference@ is a value you already sent in a previous
    -- request to create an identity, but the content of the
    -- @CloudFrontOriginAccessIdentityConfig@ is different from the original
    -- request, CloudFront returns a
    -- @CloudFrontOriginAccessIdentityAlreadyExists@ error.
    CloudFrontOriginAccessIdentityConfig -> Text
callerReference :: Prelude.Text,
    -- | A comment to describe the origin access identity. The comment cannot be
    -- longer than 128 characters.
    CloudFrontOriginAccessIdentityConfig -> Text
comment :: Prelude.Text
  }
  deriving (CloudFrontOriginAccessIdentityConfig
-> CloudFrontOriginAccessIdentityConfig -> Bool
(CloudFrontOriginAccessIdentityConfig
 -> CloudFrontOriginAccessIdentityConfig -> Bool)
-> (CloudFrontOriginAccessIdentityConfig
    -> CloudFrontOriginAccessIdentityConfig -> Bool)
-> Eq CloudFrontOriginAccessIdentityConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CloudFrontOriginAccessIdentityConfig
-> CloudFrontOriginAccessIdentityConfig -> Bool
$c/= :: CloudFrontOriginAccessIdentityConfig
-> CloudFrontOriginAccessIdentityConfig -> Bool
== :: CloudFrontOriginAccessIdentityConfig
-> CloudFrontOriginAccessIdentityConfig -> Bool
$c== :: CloudFrontOriginAccessIdentityConfig
-> CloudFrontOriginAccessIdentityConfig -> Bool
Prelude.Eq, ReadPrec [CloudFrontOriginAccessIdentityConfig]
ReadPrec CloudFrontOriginAccessIdentityConfig
Int -> ReadS CloudFrontOriginAccessIdentityConfig
ReadS [CloudFrontOriginAccessIdentityConfig]
(Int -> ReadS CloudFrontOriginAccessIdentityConfig)
-> ReadS [CloudFrontOriginAccessIdentityConfig]
-> ReadPrec CloudFrontOriginAccessIdentityConfig
-> ReadPrec [CloudFrontOriginAccessIdentityConfig]
-> Read CloudFrontOriginAccessIdentityConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CloudFrontOriginAccessIdentityConfig]
$creadListPrec :: ReadPrec [CloudFrontOriginAccessIdentityConfig]
readPrec :: ReadPrec CloudFrontOriginAccessIdentityConfig
$creadPrec :: ReadPrec CloudFrontOriginAccessIdentityConfig
readList :: ReadS [CloudFrontOriginAccessIdentityConfig]
$creadList :: ReadS [CloudFrontOriginAccessIdentityConfig]
readsPrec :: Int -> ReadS CloudFrontOriginAccessIdentityConfig
$creadsPrec :: Int -> ReadS CloudFrontOriginAccessIdentityConfig
Prelude.Read, Int -> CloudFrontOriginAccessIdentityConfig -> ShowS
[CloudFrontOriginAccessIdentityConfig] -> ShowS
CloudFrontOriginAccessIdentityConfig -> String
(Int -> CloudFrontOriginAccessIdentityConfig -> ShowS)
-> (CloudFrontOriginAccessIdentityConfig -> String)
-> ([CloudFrontOriginAccessIdentityConfig] -> ShowS)
-> Show CloudFrontOriginAccessIdentityConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CloudFrontOriginAccessIdentityConfig] -> ShowS
$cshowList :: [CloudFrontOriginAccessIdentityConfig] -> ShowS
show :: CloudFrontOriginAccessIdentityConfig -> String
$cshow :: CloudFrontOriginAccessIdentityConfig -> String
showsPrec :: Int -> CloudFrontOriginAccessIdentityConfig -> ShowS
$cshowsPrec :: Int -> CloudFrontOriginAccessIdentityConfig -> ShowS
Prelude.Show, (forall x.
 CloudFrontOriginAccessIdentityConfig
 -> Rep CloudFrontOriginAccessIdentityConfig x)
-> (forall x.
    Rep CloudFrontOriginAccessIdentityConfig x
    -> CloudFrontOriginAccessIdentityConfig)
-> Generic CloudFrontOriginAccessIdentityConfig
forall x.
Rep CloudFrontOriginAccessIdentityConfig x
-> CloudFrontOriginAccessIdentityConfig
forall x.
CloudFrontOriginAccessIdentityConfig
-> Rep CloudFrontOriginAccessIdentityConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CloudFrontOriginAccessIdentityConfig x
-> CloudFrontOriginAccessIdentityConfig
$cfrom :: forall x.
CloudFrontOriginAccessIdentityConfig
-> Rep CloudFrontOriginAccessIdentityConfig x
Prelude.Generic)

-- |
-- Create a value of 'CloudFrontOriginAccessIdentityConfig' 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:
--
-- 'callerReference', 'cloudFrontOriginAccessIdentityConfig_callerReference' - A unique value (for example, a date-time stamp) that ensures that the
-- request can\'t be replayed.
--
-- If the value of @CallerReference@ is new (regardless of the content of
-- the @CloudFrontOriginAccessIdentityConfig@ object), a new origin access
-- identity is created.
--
-- If the @CallerReference@ is a value already sent in a previous identity
-- request, and the content of the @CloudFrontOriginAccessIdentityConfig@
-- is identical to the original request (ignoring white space), the
-- response includes the same information returned to the original request.
--
-- If the @CallerReference@ is a value you already sent in a previous
-- request to create an identity, but the content of the
-- @CloudFrontOriginAccessIdentityConfig@ is different from the original
-- request, CloudFront returns a
-- @CloudFrontOriginAccessIdentityAlreadyExists@ error.
--
-- 'comment', 'cloudFrontOriginAccessIdentityConfig_comment' - A comment to describe the origin access identity. The comment cannot be
-- longer than 128 characters.
newCloudFrontOriginAccessIdentityConfig ::
  -- | 'callerReference'
  Prelude.Text ->
  -- | 'comment'
  Prelude.Text ->
  CloudFrontOriginAccessIdentityConfig
newCloudFrontOriginAccessIdentityConfig :: Text -> Text -> CloudFrontOriginAccessIdentityConfig
newCloudFrontOriginAccessIdentityConfig
  Text
pCallerReference_
  Text
pComment_ =
    CloudFrontOriginAccessIdentityConfig' :: Text -> Text -> CloudFrontOriginAccessIdentityConfig
CloudFrontOriginAccessIdentityConfig'
      { $sel:callerReference:CloudFrontOriginAccessIdentityConfig' :: Text
callerReference =
          Text
pCallerReference_,
        $sel:comment:CloudFrontOriginAccessIdentityConfig' :: Text
comment = Text
pComment_
      }

-- | A unique value (for example, a date-time stamp) that ensures that the
-- request can\'t be replayed.
--
-- If the value of @CallerReference@ is new (regardless of the content of
-- the @CloudFrontOriginAccessIdentityConfig@ object), a new origin access
-- identity is created.
--
-- If the @CallerReference@ is a value already sent in a previous identity
-- request, and the content of the @CloudFrontOriginAccessIdentityConfig@
-- is identical to the original request (ignoring white space), the
-- response includes the same information returned to the original request.
--
-- If the @CallerReference@ is a value you already sent in a previous
-- request to create an identity, but the content of the
-- @CloudFrontOriginAccessIdentityConfig@ is different from the original
-- request, CloudFront returns a
-- @CloudFrontOriginAccessIdentityAlreadyExists@ error.
cloudFrontOriginAccessIdentityConfig_callerReference :: Lens.Lens' CloudFrontOriginAccessIdentityConfig Prelude.Text
cloudFrontOriginAccessIdentityConfig_callerReference :: (Text -> f Text)
-> CloudFrontOriginAccessIdentityConfig
-> f CloudFrontOriginAccessIdentityConfig
cloudFrontOriginAccessIdentityConfig_callerReference = (CloudFrontOriginAccessIdentityConfig -> Text)
-> (CloudFrontOriginAccessIdentityConfig
    -> Text -> CloudFrontOriginAccessIdentityConfig)
-> Lens
     CloudFrontOriginAccessIdentityConfig
     CloudFrontOriginAccessIdentityConfig
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudFrontOriginAccessIdentityConfig' {Text
callerReference :: Text
$sel:callerReference:CloudFrontOriginAccessIdentityConfig' :: CloudFrontOriginAccessIdentityConfig -> Text
callerReference} -> Text
callerReference) (\s :: CloudFrontOriginAccessIdentityConfig
s@CloudFrontOriginAccessIdentityConfig' {} Text
a -> CloudFrontOriginAccessIdentityConfig
s {$sel:callerReference:CloudFrontOriginAccessIdentityConfig' :: Text
callerReference = Text
a} :: CloudFrontOriginAccessIdentityConfig)

-- | A comment to describe the origin access identity. The comment cannot be
-- longer than 128 characters.
cloudFrontOriginAccessIdentityConfig_comment :: Lens.Lens' CloudFrontOriginAccessIdentityConfig Prelude.Text
cloudFrontOriginAccessIdentityConfig_comment :: (Text -> f Text)
-> CloudFrontOriginAccessIdentityConfig
-> f CloudFrontOriginAccessIdentityConfig
cloudFrontOriginAccessIdentityConfig_comment = (CloudFrontOriginAccessIdentityConfig -> Text)
-> (CloudFrontOriginAccessIdentityConfig
    -> Text -> CloudFrontOriginAccessIdentityConfig)
-> Lens
     CloudFrontOriginAccessIdentityConfig
     CloudFrontOriginAccessIdentityConfig
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudFrontOriginAccessIdentityConfig' {Text
comment :: Text
$sel:comment:CloudFrontOriginAccessIdentityConfig' :: CloudFrontOriginAccessIdentityConfig -> Text
comment} -> Text
comment) (\s :: CloudFrontOriginAccessIdentityConfig
s@CloudFrontOriginAccessIdentityConfig' {} Text
a -> CloudFrontOriginAccessIdentityConfig
s {$sel:comment:CloudFrontOriginAccessIdentityConfig' :: Text
comment = Text
a} :: CloudFrontOriginAccessIdentityConfig)

instance
  Core.FromXML
    CloudFrontOriginAccessIdentityConfig
  where
  parseXML :: [Node] -> Either String CloudFrontOriginAccessIdentityConfig
parseXML [Node]
x =
    Text -> Text -> CloudFrontOriginAccessIdentityConfig
CloudFrontOriginAccessIdentityConfig'
      (Text -> Text -> CloudFrontOriginAccessIdentityConfig)
-> Either String Text
-> Either String (Text -> CloudFrontOriginAccessIdentityConfig)
forall (f :: * -> *) a b. Functor 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
"CallerReference")
      Either String (Text -> CloudFrontOriginAccessIdentityConfig)
-> Either String Text
-> Either String CloudFrontOriginAccessIdentityConfig
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
"Comment")

instance
  Prelude.Hashable
    CloudFrontOriginAccessIdentityConfig

instance
  Prelude.NFData
    CloudFrontOriginAccessIdentityConfig

instance
  Core.ToXML
    CloudFrontOriginAccessIdentityConfig
  where
  toXML :: CloudFrontOriginAccessIdentityConfig -> XML
toXML CloudFrontOriginAccessIdentityConfig' {Text
comment :: Text
callerReference :: Text
$sel:comment:CloudFrontOriginAccessIdentityConfig' :: CloudFrontOriginAccessIdentityConfig -> Text
$sel:callerReference:CloudFrontOriginAccessIdentityConfig' :: CloudFrontOriginAccessIdentityConfig -> Text
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"CallerReference" Name -> Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Text
callerReference,
        Name
"Comment" Name -> Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Text
comment
      ]