{-# 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.PublicKeyConfig
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CloudFront.Types.PublicKeyConfig where

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

-- | Configuration information about a public key that you can use with
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/PrivateContent.html signed URLs and signed cookies>,
-- or with
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/field-level-encryption.html field-level encryption>.
--
-- /See:/ 'newPublicKeyConfig' smart constructor.
data PublicKeyConfig = PublicKeyConfig'
  { -- | A comment to describe the public key. The comment cannot be longer than
    -- 128 characters.
    PublicKeyConfig -> Maybe Text
comment :: Prelude.Maybe Prelude.Text,
    -- | A string included in the request to help make sure that the request
    -- can\'t be replayed.
    PublicKeyConfig -> Text
callerReference :: Prelude.Text,
    -- | A name to help identify the public key.
    PublicKeyConfig -> Text
name :: Prelude.Text,
    -- | The public key that you can use with
    -- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/PrivateContent.html signed URLs and signed cookies>,
    -- or with
    -- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/field-level-encryption.html field-level encryption>.
    PublicKeyConfig -> Text
encodedKey :: Prelude.Text
  }
  deriving (PublicKeyConfig -> PublicKeyConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PublicKeyConfig -> PublicKeyConfig -> Bool
$c/= :: PublicKeyConfig -> PublicKeyConfig -> Bool
== :: PublicKeyConfig -> PublicKeyConfig -> Bool
$c== :: PublicKeyConfig -> PublicKeyConfig -> Bool
Prelude.Eq, ReadPrec [PublicKeyConfig]
ReadPrec PublicKeyConfig
Int -> ReadS PublicKeyConfig
ReadS [PublicKeyConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PublicKeyConfig]
$creadListPrec :: ReadPrec [PublicKeyConfig]
readPrec :: ReadPrec PublicKeyConfig
$creadPrec :: ReadPrec PublicKeyConfig
readList :: ReadS [PublicKeyConfig]
$creadList :: ReadS [PublicKeyConfig]
readsPrec :: Int -> ReadS PublicKeyConfig
$creadsPrec :: Int -> ReadS PublicKeyConfig
Prelude.Read, Int -> PublicKeyConfig -> ShowS
[PublicKeyConfig] -> ShowS
PublicKeyConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PublicKeyConfig] -> ShowS
$cshowList :: [PublicKeyConfig] -> ShowS
show :: PublicKeyConfig -> String
$cshow :: PublicKeyConfig -> String
showsPrec :: Int -> PublicKeyConfig -> ShowS
$cshowsPrec :: Int -> PublicKeyConfig -> ShowS
Prelude.Show, forall x. Rep PublicKeyConfig x -> PublicKeyConfig
forall x. PublicKeyConfig -> Rep PublicKeyConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PublicKeyConfig x -> PublicKeyConfig
$cfrom :: forall x. PublicKeyConfig -> Rep PublicKeyConfig x
Prelude.Generic)

-- |
-- Create a value of 'PublicKeyConfig' 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:
--
-- 'comment', 'publicKeyConfig_comment' - A comment to describe the public key. The comment cannot be longer than
-- 128 characters.
--
-- 'callerReference', 'publicKeyConfig_callerReference' - A string included in the request to help make sure that the request
-- can\'t be replayed.
--
-- 'name', 'publicKeyConfig_name' - A name to help identify the public key.
--
-- 'encodedKey', 'publicKeyConfig_encodedKey' - The public key that you can use with
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/PrivateContent.html signed URLs and signed cookies>,
-- or with
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/field-level-encryption.html field-level encryption>.
newPublicKeyConfig ::
  -- | 'callerReference'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  -- | 'encodedKey'
  Prelude.Text ->
  PublicKeyConfig
newPublicKeyConfig :: Text -> Text -> Text -> PublicKeyConfig
newPublicKeyConfig
  Text
pCallerReference_
  Text
pName_
  Text
pEncodedKey_ =
    PublicKeyConfig'
      { $sel:comment:PublicKeyConfig' :: Maybe Text
comment = forall a. Maybe a
Prelude.Nothing,
        $sel:callerReference:PublicKeyConfig' :: Text
callerReference = Text
pCallerReference_,
        $sel:name:PublicKeyConfig' :: Text
name = Text
pName_,
        $sel:encodedKey:PublicKeyConfig' :: Text
encodedKey = Text
pEncodedKey_
      }

-- | A comment to describe the public key. The comment cannot be longer than
-- 128 characters.
publicKeyConfig_comment :: Lens.Lens' PublicKeyConfig (Prelude.Maybe Prelude.Text)
publicKeyConfig_comment :: Lens' PublicKeyConfig (Maybe Text)
publicKeyConfig_comment = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PublicKeyConfig' {Maybe Text
comment :: Maybe Text
$sel:comment:PublicKeyConfig' :: PublicKeyConfig -> Maybe Text
comment} -> Maybe Text
comment) (\s :: PublicKeyConfig
s@PublicKeyConfig' {} Maybe Text
a -> PublicKeyConfig
s {$sel:comment:PublicKeyConfig' :: Maybe Text
comment = Maybe Text
a} :: PublicKeyConfig)

-- | A string included in the request to help make sure that the request
-- can\'t be replayed.
publicKeyConfig_callerReference :: Lens.Lens' PublicKeyConfig Prelude.Text
publicKeyConfig_callerReference :: Lens' PublicKeyConfig Text
publicKeyConfig_callerReference = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PublicKeyConfig' {Text
callerReference :: Text
$sel:callerReference:PublicKeyConfig' :: PublicKeyConfig -> Text
callerReference} -> Text
callerReference) (\s :: PublicKeyConfig
s@PublicKeyConfig' {} Text
a -> PublicKeyConfig
s {$sel:callerReference:PublicKeyConfig' :: Text
callerReference = Text
a} :: PublicKeyConfig)

-- | A name to help identify the public key.
publicKeyConfig_name :: Lens.Lens' PublicKeyConfig Prelude.Text
publicKeyConfig_name :: Lens' PublicKeyConfig Text
publicKeyConfig_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PublicKeyConfig' {Text
name :: Text
$sel:name:PublicKeyConfig' :: PublicKeyConfig -> Text
name} -> Text
name) (\s :: PublicKeyConfig
s@PublicKeyConfig' {} Text
a -> PublicKeyConfig
s {$sel:name:PublicKeyConfig' :: Text
name = Text
a} :: PublicKeyConfig)

-- | The public key that you can use with
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/PrivateContent.html signed URLs and signed cookies>,
-- or with
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/field-level-encryption.html field-level encryption>.
publicKeyConfig_encodedKey :: Lens.Lens' PublicKeyConfig Prelude.Text
publicKeyConfig_encodedKey :: Lens' PublicKeyConfig Text
publicKeyConfig_encodedKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PublicKeyConfig' {Text
encodedKey :: Text
$sel:encodedKey:PublicKeyConfig' :: PublicKeyConfig -> Text
encodedKey} -> Text
encodedKey) (\s :: PublicKeyConfig
s@PublicKeyConfig' {} Text
a -> PublicKeyConfig
s {$sel:encodedKey:PublicKeyConfig' :: Text
encodedKey = Text
a} :: PublicKeyConfig)

instance Data.FromXML PublicKeyConfig where
  parseXML :: [Node] -> Either String PublicKeyConfig
parseXML [Node]
x =
    Maybe Text -> Text -> Text -> Text -> PublicKeyConfig
PublicKeyConfig'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Comment")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"CallerReference")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Name")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"EncodedKey")

instance Prelude.Hashable PublicKeyConfig where
  hashWithSalt :: Int -> PublicKeyConfig -> Int
hashWithSalt Int
_salt PublicKeyConfig' {Maybe Text
Text
encodedKey :: Text
name :: Text
callerReference :: Text
comment :: Maybe Text
$sel:encodedKey:PublicKeyConfig' :: PublicKeyConfig -> Text
$sel:name:PublicKeyConfig' :: PublicKeyConfig -> Text
$sel:callerReference:PublicKeyConfig' :: PublicKeyConfig -> Text
$sel:comment:PublicKeyConfig' :: PublicKeyConfig -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
comment
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
callerReference
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
encodedKey

instance Prelude.NFData PublicKeyConfig where
  rnf :: PublicKeyConfig -> ()
rnf PublicKeyConfig' {Maybe Text
Text
encodedKey :: Text
name :: Text
callerReference :: Text
comment :: Maybe Text
$sel:encodedKey:PublicKeyConfig' :: PublicKeyConfig -> Text
$sel:name:PublicKeyConfig' :: PublicKeyConfig -> Text
$sel:callerReference:PublicKeyConfig' :: PublicKeyConfig -> Text
$sel:comment:PublicKeyConfig' :: PublicKeyConfig -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
comment
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
callerReference
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
encodedKey

instance Data.ToXML PublicKeyConfig where
  toXML :: PublicKeyConfig -> XML
toXML PublicKeyConfig' {Maybe Text
Text
encodedKey :: Text
name :: Text
callerReference :: Text
comment :: Maybe Text
$sel:encodedKey:PublicKeyConfig' :: PublicKeyConfig -> Text
$sel:name:PublicKeyConfig' :: PublicKeyConfig -> Text
$sel:callerReference:PublicKeyConfig' :: PublicKeyConfig -> Text
$sel:comment:PublicKeyConfig' :: PublicKeyConfig -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"Comment" forall a. ToXML a => Name -> a -> XML
Data.@= Maybe Text
comment,
        Name
"CallerReference" forall a. ToXML a => Name -> a -> XML
Data.@= Text
callerReference,
        Name
"Name" forall a. ToXML a => Name -> a -> XML
Data.@= Text
name,
        Name
"EncodedKey" forall a. ToXML a => Name -> a -> XML
Data.@= Text
encodedKey
      ]