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

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

-- | The configuration for a field-level encryption content type-profile
-- mapping.
--
-- /See:/ 'newContentTypeProfileConfig' smart constructor.
data ContentTypeProfileConfig = ContentTypeProfileConfig'
  { -- | The configuration for a field-level encryption content type-profile.
    ContentTypeProfileConfig -> Maybe ContentTypeProfiles
contentTypeProfiles :: Prelude.Maybe ContentTypeProfiles,
    -- | The setting in a field-level encryption content type-profile mapping
    -- that specifies what to do when an unknown content type is provided for
    -- the profile. If true, content is forwarded without being encrypted when
    -- the content type is unknown. If false (the default), an error is
    -- returned when the content type is unknown.
    ContentTypeProfileConfig -> Bool
forwardWhenContentTypeIsUnknown :: Prelude.Bool
  }
  deriving (ContentTypeProfileConfig -> ContentTypeProfileConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ContentTypeProfileConfig -> ContentTypeProfileConfig -> Bool
$c/= :: ContentTypeProfileConfig -> ContentTypeProfileConfig -> Bool
== :: ContentTypeProfileConfig -> ContentTypeProfileConfig -> Bool
$c== :: ContentTypeProfileConfig -> ContentTypeProfileConfig -> Bool
Prelude.Eq, ReadPrec [ContentTypeProfileConfig]
ReadPrec ContentTypeProfileConfig
Int -> ReadS ContentTypeProfileConfig
ReadS [ContentTypeProfileConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ContentTypeProfileConfig]
$creadListPrec :: ReadPrec [ContentTypeProfileConfig]
readPrec :: ReadPrec ContentTypeProfileConfig
$creadPrec :: ReadPrec ContentTypeProfileConfig
readList :: ReadS [ContentTypeProfileConfig]
$creadList :: ReadS [ContentTypeProfileConfig]
readsPrec :: Int -> ReadS ContentTypeProfileConfig
$creadsPrec :: Int -> ReadS ContentTypeProfileConfig
Prelude.Read, Int -> ContentTypeProfileConfig -> ShowS
[ContentTypeProfileConfig] -> ShowS
ContentTypeProfileConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ContentTypeProfileConfig] -> ShowS
$cshowList :: [ContentTypeProfileConfig] -> ShowS
show :: ContentTypeProfileConfig -> String
$cshow :: ContentTypeProfileConfig -> String
showsPrec :: Int -> ContentTypeProfileConfig -> ShowS
$cshowsPrec :: Int -> ContentTypeProfileConfig -> ShowS
Prelude.Show, forall x.
Rep ContentTypeProfileConfig x -> ContentTypeProfileConfig
forall x.
ContentTypeProfileConfig -> Rep ContentTypeProfileConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ContentTypeProfileConfig x -> ContentTypeProfileConfig
$cfrom :: forall x.
ContentTypeProfileConfig -> Rep ContentTypeProfileConfig x
Prelude.Generic)

-- |
-- Create a value of 'ContentTypeProfileConfig' 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:
--
-- 'contentTypeProfiles', 'contentTypeProfileConfig_contentTypeProfiles' - The configuration for a field-level encryption content type-profile.
--
-- 'forwardWhenContentTypeIsUnknown', 'contentTypeProfileConfig_forwardWhenContentTypeIsUnknown' - The setting in a field-level encryption content type-profile mapping
-- that specifies what to do when an unknown content type is provided for
-- the profile. If true, content is forwarded without being encrypted when
-- the content type is unknown. If false (the default), an error is
-- returned when the content type is unknown.
newContentTypeProfileConfig ::
  -- | 'forwardWhenContentTypeIsUnknown'
  Prelude.Bool ->
  ContentTypeProfileConfig
newContentTypeProfileConfig :: Bool -> ContentTypeProfileConfig
newContentTypeProfileConfig
  Bool
pForwardWhenContentTypeIsUnknown_ =
    ContentTypeProfileConfig'
      { $sel:contentTypeProfiles:ContentTypeProfileConfig' :: Maybe ContentTypeProfiles
contentTypeProfiles =
          forall a. Maybe a
Prelude.Nothing,
        $sel:forwardWhenContentTypeIsUnknown:ContentTypeProfileConfig' :: Bool
forwardWhenContentTypeIsUnknown =
          Bool
pForwardWhenContentTypeIsUnknown_
      }

-- | The configuration for a field-level encryption content type-profile.
contentTypeProfileConfig_contentTypeProfiles :: Lens.Lens' ContentTypeProfileConfig (Prelude.Maybe ContentTypeProfiles)
contentTypeProfileConfig_contentTypeProfiles :: Lens' ContentTypeProfileConfig (Maybe ContentTypeProfiles)
contentTypeProfileConfig_contentTypeProfiles = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContentTypeProfileConfig' {Maybe ContentTypeProfiles
contentTypeProfiles :: Maybe ContentTypeProfiles
$sel:contentTypeProfiles:ContentTypeProfileConfig' :: ContentTypeProfileConfig -> Maybe ContentTypeProfiles
contentTypeProfiles} -> Maybe ContentTypeProfiles
contentTypeProfiles) (\s :: ContentTypeProfileConfig
s@ContentTypeProfileConfig' {} Maybe ContentTypeProfiles
a -> ContentTypeProfileConfig
s {$sel:contentTypeProfiles:ContentTypeProfileConfig' :: Maybe ContentTypeProfiles
contentTypeProfiles = Maybe ContentTypeProfiles
a} :: ContentTypeProfileConfig)

-- | The setting in a field-level encryption content type-profile mapping
-- that specifies what to do when an unknown content type is provided for
-- the profile. If true, content is forwarded without being encrypted when
-- the content type is unknown. If false (the default), an error is
-- returned when the content type is unknown.
contentTypeProfileConfig_forwardWhenContentTypeIsUnknown :: Lens.Lens' ContentTypeProfileConfig Prelude.Bool
contentTypeProfileConfig_forwardWhenContentTypeIsUnknown :: Lens' ContentTypeProfileConfig Bool
contentTypeProfileConfig_forwardWhenContentTypeIsUnknown = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContentTypeProfileConfig' {Bool
forwardWhenContentTypeIsUnknown :: Bool
$sel:forwardWhenContentTypeIsUnknown:ContentTypeProfileConfig' :: ContentTypeProfileConfig -> Bool
forwardWhenContentTypeIsUnknown} -> Bool
forwardWhenContentTypeIsUnknown) (\s :: ContentTypeProfileConfig
s@ContentTypeProfileConfig' {} Bool
a -> ContentTypeProfileConfig
s {$sel:forwardWhenContentTypeIsUnknown:ContentTypeProfileConfig' :: Bool
forwardWhenContentTypeIsUnknown = Bool
a} :: ContentTypeProfileConfig)

instance Data.FromXML ContentTypeProfileConfig where
  parseXML :: [Node] -> Either String ContentTypeProfileConfig
parseXML [Node]
x =
    Maybe ContentTypeProfiles -> Bool -> ContentTypeProfileConfig
ContentTypeProfileConfig'
      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
"ContentTypeProfiles")
      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
"ForwardWhenContentTypeIsUnknown")

instance Prelude.Hashable ContentTypeProfileConfig where
  hashWithSalt :: Int -> ContentTypeProfileConfig -> Int
hashWithSalt Int
_salt ContentTypeProfileConfig' {Bool
Maybe ContentTypeProfiles
forwardWhenContentTypeIsUnknown :: Bool
contentTypeProfiles :: Maybe ContentTypeProfiles
$sel:forwardWhenContentTypeIsUnknown:ContentTypeProfileConfig' :: ContentTypeProfileConfig -> Bool
$sel:contentTypeProfiles:ContentTypeProfileConfig' :: ContentTypeProfileConfig -> Maybe ContentTypeProfiles
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ContentTypeProfiles
contentTypeProfiles
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
forwardWhenContentTypeIsUnknown

instance Prelude.NFData ContentTypeProfileConfig where
  rnf :: ContentTypeProfileConfig -> ()
rnf ContentTypeProfileConfig' {Bool
Maybe ContentTypeProfiles
forwardWhenContentTypeIsUnknown :: Bool
contentTypeProfiles :: Maybe ContentTypeProfiles
$sel:forwardWhenContentTypeIsUnknown:ContentTypeProfileConfig' :: ContentTypeProfileConfig -> Bool
$sel:contentTypeProfiles:ContentTypeProfileConfig' :: ContentTypeProfileConfig -> Maybe ContentTypeProfiles
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ContentTypeProfiles
contentTypeProfiles
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Bool
forwardWhenContentTypeIsUnknown

instance Data.ToXML ContentTypeProfileConfig where
  toXML :: ContentTypeProfileConfig -> XML
toXML ContentTypeProfileConfig' {Bool
Maybe ContentTypeProfiles
forwardWhenContentTypeIsUnknown :: Bool
contentTypeProfiles :: Maybe ContentTypeProfiles
$sel:forwardWhenContentTypeIsUnknown:ContentTypeProfileConfig' :: ContentTypeProfileConfig -> Bool
$sel:contentTypeProfiles:ContentTypeProfileConfig' :: ContentTypeProfileConfig -> Maybe ContentTypeProfiles
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"ContentTypeProfiles" forall a. ToXML a => Name -> a -> XML
Data.@= Maybe ContentTypeProfiles
contentTypeProfiles,
        Name
"ForwardWhenContentTypeIsUnknown"
          forall a. ToXML a => Name -> a -> XML
Data.@= Bool
forwardWhenContentTypeIsUnknown
      ]