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

import Amazonka.CloudFront.Types.ContentTypeProfileConfig
import Amazonka.CloudFront.Types.QueryArgProfileConfig
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A complex data type that includes the profile configurations specified
-- for field-level encryption.
--
-- /See:/ 'newFieldLevelEncryptionConfig' smart constructor.
data FieldLevelEncryptionConfig = FieldLevelEncryptionConfig'
  { -- | A complex data type that specifies when to forward content if a profile
    -- isn\'t found and the profile that can be provided as a query argument in
    -- a request.
    FieldLevelEncryptionConfig -> Maybe QueryArgProfileConfig
queryArgProfileConfig :: Prelude.Maybe QueryArgProfileConfig,
    -- | A complex data type that specifies when to forward content if a content
    -- type isn\'t recognized and profiles to use as by default in a request if
    -- a query argument doesn\'t specify a profile to use.
    FieldLevelEncryptionConfig -> Maybe ContentTypeProfileConfig
contentTypeProfileConfig :: Prelude.Maybe ContentTypeProfileConfig,
    -- | An optional comment about the configuration. The comment cannot be
    -- longer than 128 characters.
    FieldLevelEncryptionConfig -> Maybe Text
comment :: Prelude.Maybe Prelude.Text,
    -- | A unique number that ensures the request can\'t be replayed.
    FieldLevelEncryptionConfig -> Text
callerReference :: Prelude.Text
  }
  deriving (FieldLevelEncryptionConfig -> FieldLevelEncryptionConfig -> Bool
(FieldLevelEncryptionConfig -> FieldLevelEncryptionConfig -> Bool)
-> (FieldLevelEncryptionConfig
    -> FieldLevelEncryptionConfig -> Bool)
-> Eq FieldLevelEncryptionConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FieldLevelEncryptionConfig -> FieldLevelEncryptionConfig -> Bool
$c/= :: FieldLevelEncryptionConfig -> FieldLevelEncryptionConfig -> Bool
== :: FieldLevelEncryptionConfig -> FieldLevelEncryptionConfig -> Bool
$c== :: FieldLevelEncryptionConfig -> FieldLevelEncryptionConfig -> Bool
Prelude.Eq, ReadPrec [FieldLevelEncryptionConfig]
ReadPrec FieldLevelEncryptionConfig
Int -> ReadS FieldLevelEncryptionConfig
ReadS [FieldLevelEncryptionConfig]
(Int -> ReadS FieldLevelEncryptionConfig)
-> ReadS [FieldLevelEncryptionConfig]
-> ReadPrec FieldLevelEncryptionConfig
-> ReadPrec [FieldLevelEncryptionConfig]
-> Read FieldLevelEncryptionConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FieldLevelEncryptionConfig]
$creadListPrec :: ReadPrec [FieldLevelEncryptionConfig]
readPrec :: ReadPrec FieldLevelEncryptionConfig
$creadPrec :: ReadPrec FieldLevelEncryptionConfig
readList :: ReadS [FieldLevelEncryptionConfig]
$creadList :: ReadS [FieldLevelEncryptionConfig]
readsPrec :: Int -> ReadS FieldLevelEncryptionConfig
$creadsPrec :: Int -> ReadS FieldLevelEncryptionConfig
Prelude.Read, Int -> FieldLevelEncryptionConfig -> ShowS
[FieldLevelEncryptionConfig] -> ShowS
FieldLevelEncryptionConfig -> String
(Int -> FieldLevelEncryptionConfig -> ShowS)
-> (FieldLevelEncryptionConfig -> String)
-> ([FieldLevelEncryptionConfig] -> ShowS)
-> Show FieldLevelEncryptionConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FieldLevelEncryptionConfig] -> ShowS
$cshowList :: [FieldLevelEncryptionConfig] -> ShowS
show :: FieldLevelEncryptionConfig -> String
$cshow :: FieldLevelEncryptionConfig -> String
showsPrec :: Int -> FieldLevelEncryptionConfig -> ShowS
$cshowsPrec :: Int -> FieldLevelEncryptionConfig -> ShowS
Prelude.Show, (forall x.
 FieldLevelEncryptionConfig -> Rep FieldLevelEncryptionConfig x)
-> (forall x.
    Rep FieldLevelEncryptionConfig x -> FieldLevelEncryptionConfig)
-> Generic FieldLevelEncryptionConfig
forall x.
Rep FieldLevelEncryptionConfig x -> FieldLevelEncryptionConfig
forall x.
FieldLevelEncryptionConfig -> Rep FieldLevelEncryptionConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep FieldLevelEncryptionConfig x -> FieldLevelEncryptionConfig
$cfrom :: forall x.
FieldLevelEncryptionConfig -> Rep FieldLevelEncryptionConfig x
Prelude.Generic)

-- |
-- Create a value of 'FieldLevelEncryptionConfig' 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:
--
-- 'queryArgProfileConfig', 'fieldLevelEncryptionConfig_queryArgProfileConfig' - A complex data type that specifies when to forward content if a profile
-- isn\'t found and the profile that can be provided as a query argument in
-- a request.
--
-- 'contentTypeProfileConfig', 'fieldLevelEncryptionConfig_contentTypeProfileConfig' - A complex data type that specifies when to forward content if a content
-- type isn\'t recognized and profiles to use as by default in a request if
-- a query argument doesn\'t specify a profile to use.
--
-- 'comment', 'fieldLevelEncryptionConfig_comment' - An optional comment about the configuration. The comment cannot be
-- longer than 128 characters.
--
-- 'callerReference', 'fieldLevelEncryptionConfig_callerReference' - A unique number that ensures the request can\'t be replayed.
newFieldLevelEncryptionConfig ::
  -- | 'callerReference'
  Prelude.Text ->
  FieldLevelEncryptionConfig
newFieldLevelEncryptionConfig :: Text -> FieldLevelEncryptionConfig
newFieldLevelEncryptionConfig Text
pCallerReference_ =
  FieldLevelEncryptionConfig' :: Maybe QueryArgProfileConfig
-> Maybe ContentTypeProfileConfig
-> Maybe Text
-> Text
-> FieldLevelEncryptionConfig
FieldLevelEncryptionConfig'
    { $sel:queryArgProfileConfig:FieldLevelEncryptionConfig' :: Maybe QueryArgProfileConfig
queryArgProfileConfig =
        Maybe QueryArgProfileConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:contentTypeProfileConfig:FieldLevelEncryptionConfig' :: Maybe ContentTypeProfileConfig
contentTypeProfileConfig = Maybe ContentTypeProfileConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:comment:FieldLevelEncryptionConfig' :: Maybe Text
comment = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:callerReference:FieldLevelEncryptionConfig' :: Text
callerReference = Text
pCallerReference_
    }

-- | A complex data type that specifies when to forward content if a profile
-- isn\'t found and the profile that can be provided as a query argument in
-- a request.
fieldLevelEncryptionConfig_queryArgProfileConfig :: Lens.Lens' FieldLevelEncryptionConfig (Prelude.Maybe QueryArgProfileConfig)
fieldLevelEncryptionConfig_queryArgProfileConfig :: (Maybe QueryArgProfileConfig -> f (Maybe QueryArgProfileConfig))
-> FieldLevelEncryptionConfig -> f FieldLevelEncryptionConfig
fieldLevelEncryptionConfig_queryArgProfileConfig = (FieldLevelEncryptionConfig -> Maybe QueryArgProfileConfig)
-> (FieldLevelEncryptionConfig
    -> Maybe QueryArgProfileConfig -> FieldLevelEncryptionConfig)
-> Lens
     FieldLevelEncryptionConfig
     FieldLevelEncryptionConfig
     (Maybe QueryArgProfileConfig)
     (Maybe QueryArgProfileConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FieldLevelEncryptionConfig' {Maybe QueryArgProfileConfig
queryArgProfileConfig :: Maybe QueryArgProfileConfig
$sel:queryArgProfileConfig:FieldLevelEncryptionConfig' :: FieldLevelEncryptionConfig -> Maybe QueryArgProfileConfig
queryArgProfileConfig} -> Maybe QueryArgProfileConfig
queryArgProfileConfig) (\s :: FieldLevelEncryptionConfig
s@FieldLevelEncryptionConfig' {} Maybe QueryArgProfileConfig
a -> FieldLevelEncryptionConfig
s {$sel:queryArgProfileConfig:FieldLevelEncryptionConfig' :: Maybe QueryArgProfileConfig
queryArgProfileConfig = Maybe QueryArgProfileConfig
a} :: FieldLevelEncryptionConfig)

-- | A complex data type that specifies when to forward content if a content
-- type isn\'t recognized and profiles to use as by default in a request if
-- a query argument doesn\'t specify a profile to use.
fieldLevelEncryptionConfig_contentTypeProfileConfig :: Lens.Lens' FieldLevelEncryptionConfig (Prelude.Maybe ContentTypeProfileConfig)
fieldLevelEncryptionConfig_contentTypeProfileConfig :: (Maybe ContentTypeProfileConfig
 -> f (Maybe ContentTypeProfileConfig))
-> FieldLevelEncryptionConfig -> f FieldLevelEncryptionConfig
fieldLevelEncryptionConfig_contentTypeProfileConfig = (FieldLevelEncryptionConfig -> Maybe ContentTypeProfileConfig)
-> (FieldLevelEncryptionConfig
    -> Maybe ContentTypeProfileConfig -> FieldLevelEncryptionConfig)
-> Lens
     FieldLevelEncryptionConfig
     FieldLevelEncryptionConfig
     (Maybe ContentTypeProfileConfig)
     (Maybe ContentTypeProfileConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FieldLevelEncryptionConfig' {Maybe ContentTypeProfileConfig
contentTypeProfileConfig :: Maybe ContentTypeProfileConfig
$sel:contentTypeProfileConfig:FieldLevelEncryptionConfig' :: FieldLevelEncryptionConfig -> Maybe ContentTypeProfileConfig
contentTypeProfileConfig} -> Maybe ContentTypeProfileConfig
contentTypeProfileConfig) (\s :: FieldLevelEncryptionConfig
s@FieldLevelEncryptionConfig' {} Maybe ContentTypeProfileConfig
a -> FieldLevelEncryptionConfig
s {$sel:contentTypeProfileConfig:FieldLevelEncryptionConfig' :: Maybe ContentTypeProfileConfig
contentTypeProfileConfig = Maybe ContentTypeProfileConfig
a} :: FieldLevelEncryptionConfig)

-- | An optional comment about the configuration. The comment cannot be
-- longer than 128 characters.
fieldLevelEncryptionConfig_comment :: Lens.Lens' FieldLevelEncryptionConfig (Prelude.Maybe Prelude.Text)
fieldLevelEncryptionConfig_comment :: (Maybe Text -> f (Maybe Text))
-> FieldLevelEncryptionConfig -> f FieldLevelEncryptionConfig
fieldLevelEncryptionConfig_comment = (FieldLevelEncryptionConfig -> Maybe Text)
-> (FieldLevelEncryptionConfig
    -> Maybe Text -> FieldLevelEncryptionConfig)
-> Lens
     FieldLevelEncryptionConfig
     FieldLevelEncryptionConfig
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FieldLevelEncryptionConfig' {Maybe Text
comment :: Maybe Text
$sel:comment:FieldLevelEncryptionConfig' :: FieldLevelEncryptionConfig -> Maybe Text
comment} -> Maybe Text
comment) (\s :: FieldLevelEncryptionConfig
s@FieldLevelEncryptionConfig' {} Maybe Text
a -> FieldLevelEncryptionConfig
s {$sel:comment:FieldLevelEncryptionConfig' :: Maybe Text
comment = Maybe Text
a} :: FieldLevelEncryptionConfig)

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

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

instance Prelude.Hashable FieldLevelEncryptionConfig

instance Prelude.NFData FieldLevelEncryptionConfig

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