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

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

-- | A complex data type of profiles for the field-level encryption.
--
-- /See:/ 'newFieldLevelEncryptionProfileConfig' smart constructor.
data FieldLevelEncryptionProfileConfig = FieldLevelEncryptionProfileConfig'
  { -- | An optional comment for the field-level encryption profile. The comment
    -- cannot be longer than 128 characters.
    FieldLevelEncryptionProfileConfig -> Maybe Text
comment :: Prelude.Maybe Prelude.Text,
    -- | Profile name for the field-level encryption profile.
    FieldLevelEncryptionProfileConfig -> Text
name :: Prelude.Text,
    -- | A unique number that ensures that the request can\'t be replayed.
    FieldLevelEncryptionProfileConfig -> Text
callerReference :: Prelude.Text,
    -- | A complex data type of encryption entities for the field-level
    -- encryption profile that include the public key ID, provider, and field
    -- patterns for specifying which fields to encrypt with this key.
    FieldLevelEncryptionProfileConfig -> EncryptionEntities
encryptionEntities :: EncryptionEntities
  }
  deriving (FieldLevelEncryptionProfileConfig
-> FieldLevelEncryptionProfileConfig -> Bool
(FieldLevelEncryptionProfileConfig
 -> FieldLevelEncryptionProfileConfig -> Bool)
-> (FieldLevelEncryptionProfileConfig
    -> FieldLevelEncryptionProfileConfig -> Bool)
-> Eq FieldLevelEncryptionProfileConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FieldLevelEncryptionProfileConfig
-> FieldLevelEncryptionProfileConfig -> Bool
$c/= :: FieldLevelEncryptionProfileConfig
-> FieldLevelEncryptionProfileConfig -> Bool
== :: FieldLevelEncryptionProfileConfig
-> FieldLevelEncryptionProfileConfig -> Bool
$c== :: FieldLevelEncryptionProfileConfig
-> FieldLevelEncryptionProfileConfig -> Bool
Prelude.Eq, ReadPrec [FieldLevelEncryptionProfileConfig]
ReadPrec FieldLevelEncryptionProfileConfig
Int -> ReadS FieldLevelEncryptionProfileConfig
ReadS [FieldLevelEncryptionProfileConfig]
(Int -> ReadS FieldLevelEncryptionProfileConfig)
-> ReadS [FieldLevelEncryptionProfileConfig]
-> ReadPrec FieldLevelEncryptionProfileConfig
-> ReadPrec [FieldLevelEncryptionProfileConfig]
-> Read FieldLevelEncryptionProfileConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FieldLevelEncryptionProfileConfig]
$creadListPrec :: ReadPrec [FieldLevelEncryptionProfileConfig]
readPrec :: ReadPrec FieldLevelEncryptionProfileConfig
$creadPrec :: ReadPrec FieldLevelEncryptionProfileConfig
readList :: ReadS [FieldLevelEncryptionProfileConfig]
$creadList :: ReadS [FieldLevelEncryptionProfileConfig]
readsPrec :: Int -> ReadS FieldLevelEncryptionProfileConfig
$creadsPrec :: Int -> ReadS FieldLevelEncryptionProfileConfig
Prelude.Read, Int -> FieldLevelEncryptionProfileConfig -> ShowS
[FieldLevelEncryptionProfileConfig] -> ShowS
FieldLevelEncryptionProfileConfig -> String
(Int -> FieldLevelEncryptionProfileConfig -> ShowS)
-> (FieldLevelEncryptionProfileConfig -> String)
-> ([FieldLevelEncryptionProfileConfig] -> ShowS)
-> Show FieldLevelEncryptionProfileConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FieldLevelEncryptionProfileConfig] -> ShowS
$cshowList :: [FieldLevelEncryptionProfileConfig] -> ShowS
show :: FieldLevelEncryptionProfileConfig -> String
$cshow :: FieldLevelEncryptionProfileConfig -> String
showsPrec :: Int -> FieldLevelEncryptionProfileConfig -> ShowS
$cshowsPrec :: Int -> FieldLevelEncryptionProfileConfig -> ShowS
Prelude.Show, (forall x.
 FieldLevelEncryptionProfileConfig
 -> Rep FieldLevelEncryptionProfileConfig x)
-> (forall x.
    Rep FieldLevelEncryptionProfileConfig x
    -> FieldLevelEncryptionProfileConfig)
-> Generic FieldLevelEncryptionProfileConfig
forall x.
Rep FieldLevelEncryptionProfileConfig x
-> FieldLevelEncryptionProfileConfig
forall x.
FieldLevelEncryptionProfileConfig
-> Rep FieldLevelEncryptionProfileConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep FieldLevelEncryptionProfileConfig x
-> FieldLevelEncryptionProfileConfig
$cfrom :: forall x.
FieldLevelEncryptionProfileConfig
-> Rep FieldLevelEncryptionProfileConfig x
Prelude.Generic)

-- |
-- Create a value of 'FieldLevelEncryptionProfileConfig' 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', 'fieldLevelEncryptionProfileConfig_comment' - An optional comment for the field-level encryption profile. The comment
-- cannot be longer than 128 characters.
--
-- 'name', 'fieldLevelEncryptionProfileConfig_name' - Profile name for the field-level encryption profile.
--
-- 'callerReference', 'fieldLevelEncryptionProfileConfig_callerReference' - A unique number that ensures that the request can\'t be replayed.
--
-- 'encryptionEntities', 'fieldLevelEncryptionProfileConfig_encryptionEntities' - A complex data type of encryption entities for the field-level
-- encryption profile that include the public key ID, provider, and field
-- patterns for specifying which fields to encrypt with this key.
newFieldLevelEncryptionProfileConfig ::
  -- | 'name'
  Prelude.Text ->
  -- | 'callerReference'
  Prelude.Text ->
  -- | 'encryptionEntities'
  EncryptionEntities ->
  FieldLevelEncryptionProfileConfig
newFieldLevelEncryptionProfileConfig :: Text
-> Text -> EncryptionEntities -> FieldLevelEncryptionProfileConfig
newFieldLevelEncryptionProfileConfig
  Text
pName_
  Text
pCallerReference_
  EncryptionEntities
pEncryptionEntities_ =
    FieldLevelEncryptionProfileConfig' :: Maybe Text
-> Text
-> Text
-> EncryptionEntities
-> FieldLevelEncryptionProfileConfig
FieldLevelEncryptionProfileConfig'
      { $sel:comment:FieldLevelEncryptionProfileConfig' :: Maybe Text
comment =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:name:FieldLevelEncryptionProfileConfig' :: Text
name = Text
pName_,
        $sel:callerReference:FieldLevelEncryptionProfileConfig' :: Text
callerReference = Text
pCallerReference_,
        $sel:encryptionEntities:FieldLevelEncryptionProfileConfig' :: EncryptionEntities
encryptionEntities =
          EncryptionEntities
pEncryptionEntities_
      }

-- | An optional comment for the field-level encryption profile. The comment
-- cannot be longer than 128 characters.
fieldLevelEncryptionProfileConfig_comment :: Lens.Lens' FieldLevelEncryptionProfileConfig (Prelude.Maybe Prelude.Text)
fieldLevelEncryptionProfileConfig_comment :: (Maybe Text -> f (Maybe Text))
-> FieldLevelEncryptionProfileConfig
-> f FieldLevelEncryptionProfileConfig
fieldLevelEncryptionProfileConfig_comment = (FieldLevelEncryptionProfileConfig -> Maybe Text)
-> (FieldLevelEncryptionProfileConfig
    -> Maybe Text -> FieldLevelEncryptionProfileConfig)
-> Lens
     FieldLevelEncryptionProfileConfig
     FieldLevelEncryptionProfileConfig
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FieldLevelEncryptionProfileConfig' {Maybe Text
comment :: Maybe Text
$sel:comment:FieldLevelEncryptionProfileConfig' :: FieldLevelEncryptionProfileConfig -> Maybe Text
comment} -> Maybe Text
comment) (\s :: FieldLevelEncryptionProfileConfig
s@FieldLevelEncryptionProfileConfig' {} Maybe Text
a -> FieldLevelEncryptionProfileConfig
s {$sel:comment:FieldLevelEncryptionProfileConfig' :: Maybe Text
comment = Maybe Text
a} :: FieldLevelEncryptionProfileConfig)

-- | Profile name for the field-level encryption profile.
fieldLevelEncryptionProfileConfig_name :: Lens.Lens' FieldLevelEncryptionProfileConfig Prelude.Text
fieldLevelEncryptionProfileConfig_name :: (Text -> f Text)
-> FieldLevelEncryptionProfileConfig
-> f FieldLevelEncryptionProfileConfig
fieldLevelEncryptionProfileConfig_name = (FieldLevelEncryptionProfileConfig -> Text)
-> (FieldLevelEncryptionProfileConfig
    -> Text -> FieldLevelEncryptionProfileConfig)
-> Lens
     FieldLevelEncryptionProfileConfig
     FieldLevelEncryptionProfileConfig
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FieldLevelEncryptionProfileConfig' {Text
name :: Text
$sel:name:FieldLevelEncryptionProfileConfig' :: FieldLevelEncryptionProfileConfig -> Text
name} -> Text
name) (\s :: FieldLevelEncryptionProfileConfig
s@FieldLevelEncryptionProfileConfig' {} Text
a -> FieldLevelEncryptionProfileConfig
s {$sel:name:FieldLevelEncryptionProfileConfig' :: Text
name = Text
a} :: FieldLevelEncryptionProfileConfig)

-- | A unique number that ensures that the request can\'t be replayed.
fieldLevelEncryptionProfileConfig_callerReference :: Lens.Lens' FieldLevelEncryptionProfileConfig Prelude.Text
fieldLevelEncryptionProfileConfig_callerReference :: (Text -> f Text)
-> FieldLevelEncryptionProfileConfig
-> f FieldLevelEncryptionProfileConfig
fieldLevelEncryptionProfileConfig_callerReference = (FieldLevelEncryptionProfileConfig -> Text)
-> (FieldLevelEncryptionProfileConfig
    -> Text -> FieldLevelEncryptionProfileConfig)
-> Lens
     FieldLevelEncryptionProfileConfig
     FieldLevelEncryptionProfileConfig
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FieldLevelEncryptionProfileConfig' {Text
callerReference :: Text
$sel:callerReference:FieldLevelEncryptionProfileConfig' :: FieldLevelEncryptionProfileConfig -> Text
callerReference} -> Text
callerReference) (\s :: FieldLevelEncryptionProfileConfig
s@FieldLevelEncryptionProfileConfig' {} Text
a -> FieldLevelEncryptionProfileConfig
s {$sel:callerReference:FieldLevelEncryptionProfileConfig' :: Text
callerReference = Text
a} :: FieldLevelEncryptionProfileConfig)

-- | A complex data type of encryption entities for the field-level
-- encryption profile that include the public key ID, provider, and field
-- patterns for specifying which fields to encrypt with this key.
fieldLevelEncryptionProfileConfig_encryptionEntities :: Lens.Lens' FieldLevelEncryptionProfileConfig EncryptionEntities
fieldLevelEncryptionProfileConfig_encryptionEntities :: (EncryptionEntities -> f EncryptionEntities)
-> FieldLevelEncryptionProfileConfig
-> f FieldLevelEncryptionProfileConfig
fieldLevelEncryptionProfileConfig_encryptionEntities = (FieldLevelEncryptionProfileConfig -> EncryptionEntities)
-> (FieldLevelEncryptionProfileConfig
    -> EncryptionEntities -> FieldLevelEncryptionProfileConfig)
-> Lens
     FieldLevelEncryptionProfileConfig
     FieldLevelEncryptionProfileConfig
     EncryptionEntities
     EncryptionEntities
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FieldLevelEncryptionProfileConfig' {EncryptionEntities
encryptionEntities :: EncryptionEntities
$sel:encryptionEntities:FieldLevelEncryptionProfileConfig' :: FieldLevelEncryptionProfileConfig -> EncryptionEntities
encryptionEntities} -> EncryptionEntities
encryptionEntities) (\s :: FieldLevelEncryptionProfileConfig
s@FieldLevelEncryptionProfileConfig' {} EncryptionEntities
a -> FieldLevelEncryptionProfileConfig
s {$sel:encryptionEntities:FieldLevelEncryptionProfileConfig' :: EncryptionEntities
encryptionEntities = EncryptionEntities
a} :: FieldLevelEncryptionProfileConfig)

instance
  Core.FromXML
    FieldLevelEncryptionProfileConfig
  where
  parseXML :: [Node] -> Either String FieldLevelEncryptionProfileConfig
parseXML [Node]
x =
    Maybe Text
-> Text
-> Text
-> EncryptionEntities
-> FieldLevelEncryptionProfileConfig
FieldLevelEncryptionProfileConfig'
      (Maybe Text
 -> Text
 -> Text
 -> EncryptionEntities
 -> FieldLevelEncryptionProfileConfig)
-> Either String (Maybe Text)
-> Either
     String
     (Text
      -> Text -> EncryptionEntities -> FieldLevelEncryptionProfileConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Comment")
      Either
  String
  (Text
   -> Text -> EncryptionEntities -> FieldLevelEncryptionProfileConfig)
-> Either String Text
-> Either
     String
     (Text -> EncryptionEntities -> FieldLevelEncryptionProfileConfig)
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
"Name")
      Either
  String
  (Text -> EncryptionEntities -> FieldLevelEncryptionProfileConfig)
-> Either String Text
-> Either
     String (EncryptionEntities -> FieldLevelEncryptionProfileConfig)
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
"CallerReference")
      Either
  String (EncryptionEntities -> FieldLevelEncryptionProfileConfig)
-> Either String EncryptionEntities
-> Either String FieldLevelEncryptionProfileConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String EncryptionEntities
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"EncryptionEntities")

instance
  Prelude.Hashable
    FieldLevelEncryptionProfileConfig

instance
  Prelude.NFData
    FieldLevelEncryptionProfileConfig

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