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

import Amazonka.CloudFront.Types.ContentTypeProfileConfig
import Amazonka.CloudFront.Types.QueryArgProfileConfig
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

-- | A complex data type that includes the profile configurations specified
-- for field-level encryption.
--
-- /See:/ 'newFieldLevelEncryptionConfig' smart constructor.
data FieldLevelEncryptionConfig = FieldLevelEncryptionConfig'
  { -- | An optional comment about the configuration. The comment cannot be
    -- longer than 128 characters.
    FieldLevelEncryptionConfig -> Maybe Text
comment :: Prelude.Maybe Prelude.Text,
    -- | 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,
    -- | 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 unique number that ensures the request can\'t be replayed.
    FieldLevelEncryptionConfig -> Text
callerReference :: Prelude.Text
  }
  deriving (FieldLevelEncryptionConfig -> FieldLevelEncryptionConfig -> Bool
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]
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
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.
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:
--
-- 'comment', 'fieldLevelEncryptionConfig_comment' - An optional comment about the configuration. The comment cannot be
-- longer than 128 characters.
--
-- '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.
--
-- '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.
--
-- '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'
    { $sel:comment:FieldLevelEncryptionConfig' :: Maybe Text
comment =
        forall a. Maybe a
Prelude.Nothing,
      $sel:contentTypeProfileConfig:FieldLevelEncryptionConfig' :: Maybe ContentTypeProfileConfig
contentTypeProfileConfig = forall a. Maybe a
Prelude.Nothing,
      $sel:queryArgProfileConfig:FieldLevelEncryptionConfig' :: Maybe QueryArgProfileConfig
queryArgProfileConfig = forall a. Maybe a
Prelude.Nothing,
      $sel:callerReference:FieldLevelEncryptionConfig' :: Text
callerReference = Text
pCallerReference_
    }

-- | 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 :: Lens' FieldLevelEncryptionConfig (Maybe Text)
fieldLevelEncryptionConfig_comment = 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 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 :: Lens' FieldLevelEncryptionConfig (Maybe ContentTypeProfileConfig)
fieldLevelEncryptionConfig_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)

-- | 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 :: Lens' FieldLevelEncryptionConfig (Maybe QueryArgProfileConfig)
fieldLevelEncryptionConfig_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 unique number that ensures the request can\'t be replayed.
fieldLevelEncryptionConfig_callerReference :: Lens.Lens' FieldLevelEncryptionConfig Prelude.Text
fieldLevelEncryptionConfig_callerReference :: Lens' FieldLevelEncryptionConfig Text
fieldLevelEncryptionConfig_callerReference = 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 Data.FromXML FieldLevelEncryptionConfig where
  parseXML :: [Node] -> Either String FieldLevelEncryptionConfig
parseXML [Node]
x =
    Maybe Text
-> Maybe ContentTypeProfileConfig
-> Maybe QueryArgProfileConfig
-> Text
-> FieldLevelEncryptionConfig
FieldLevelEncryptionConfig'
      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 (Maybe a)
Data..@? Text
"ContentTypeProfileConfig")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"QueryArgProfileConfig")
      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")

instance Prelude.Hashable FieldLevelEncryptionConfig where
  hashWithSalt :: Int -> FieldLevelEncryptionConfig -> Int
hashWithSalt Int
_salt FieldLevelEncryptionConfig' {Maybe Text
Maybe ContentTypeProfileConfig
Maybe QueryArgProfileConfig
Text
callerReference :: Text
queryArgProfileConfig :: Maybe QueryArgProfileConfig
contentTypeProfileConfig :: Maybe ContentTypeProfileConfig
comment :: Maybe Text
$sel:callerReference:FieldLevelEncryptionConfig' :: FieldLevelEncryptionConfig -> Text
$sel:queryArgProfileConfig:FieldLevelEncryptionConfig' :: FieldLevelEncryptionConfig -> Maybe QueryArgProfileConfig
$sel:contentTypeProfileConfig:FieldLevelEncryptionConfig' :: FieldLevelEncryptionConfig -> Maybe ContentTypeProfileConfig
$sel:comment:FieldLevelEncryptionConfig' :: FieldLevelEncryptionConfig -> 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` Maybe ContentTypeProfileConfig
contentTypeProfileConfig
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe QueryArgProfileConfig
queryArgProfileConfig
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
callerReference

instance Prelude.NFData FieldLevelEncryptionConfig where
  rnf :: FieldLevelEncryptionConfig -> ()
rnf FieldLevelEncryptionConfig' {Maybe Text
Maybe ContentTypeProfileConfig
Maybe QueryArgProfileConfig
Text
callerReference :: Text
queryArgProfileConfig :: Maybe QueryArgProfileConfig
contentTypeProfileConfig :: Maybe ContentTypeProfileConfig
comment :: Maybe Text
$sel:callerReference:FieldLevelEncryptionConfig' :: FieldLevelEncryptionConfig -> Text
$sel:queryArgProfileConfig:FieldLevelEncryptionConfig' :: FieldLevelEncryptionConfig -> Maybe QueryArgProfileConfig
$sel:contentTypeProfileConfig:FieldLevelEncryptionConfig' :: FieldLevelEncryptionConfig -> Maybe ContentTypeProfileConfig
$sel:comment:FieldLevelEncryptionConfig' :: FieldLevelEncryptionConfig -> 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 Maybe ContentTypeProfileConfig
contentTypeProfileConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe QueryArgProfileConfig
queryArgProfileConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
callerReference

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