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

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

-- | A field-level encryption content type profile.
--
-- /See:/ 'newContentTypeProfile' smart constructor.
data ContentTypeProfile = ContentTypeProfile'
  { -- | The profile ID for a field-level encryption content type-profile
    -- mapping.
    ContentTypeProfile -> Maybe Text
profileId :: Prelude.Maybe Prelude.Text,
    -- | The format for a field-level encryption content type-profile mapping.
    ContentTypeProfile -> Format
format :: Format,
    -- | The content type for a field-level encryption content type-profile
    -- mapping.
    ContentTypeProfile -> Text
contentType :: Prelude.Text
  }
  deriving (ContentTypeProfile -> ContentTypeProfile -> Bool
(ContentTypeProfile -> ContentTypeProfile -> Bool)
-> (ContentTypeProfile -> ContentTypeProfile -> Bool)
-> Eq ContentTypeProfile
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ContentTypeProfile -> ContentTypeProfile -> Bool
$c/= :: ContentTypeProfile -> ContentTypeProfile -> Bool
== :: ContentTypeProfile -> ContentTypeProfile -> Bool
$c== :: ContentTypeProfile -> ContentTypeProfile -> Bool
Prelude.Eq, ReadPrec [ContentTypeProfile]
ReadPrec ContentTypeProfile
Int -> ReadS ContentTypeProfile
ReadS [ContentTypeProfile]
(Int -> ReadS ContentTypeProfile)
-> ReadS [ContentTypeProfile]
-> ReadPrec ContentTypeProfile
-> ReadPrec [ContentTypeProfile]
-> Read ContentTypeProfile
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ContentTypeProfile]
$creadListPrec :: ReadPrec [ContentTypeProfile]
readPrec :: ReadPrec ContentTypeProfile
$creadPrec :: ReadPrec ContentTypeProfile
readList :: ReadS [ContentTypeProfile]
$creadList :: ReadS [ContentTypeProfile]
readsPrec :: Int -> ReadS ContentTypeProfile
$creadsPrec :: Int -> ReadS ContentTypeProfile
Prelude.Read, Int -> ContentTypeProfile -> ShowS
[ContentTypeProfile] -> ShowS
ContentTypeProfile -> String
(Int -> ContentTypeProfile -> ShowS)
-> (ContentTypeProfile -> String)
-> ([ContentTypeProfile] -> ShowS)
-> Show ContentTypeProfile
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ContentTypeProfile] -> ShowS
$cshowList :: [ContentTypeProfile] -> ShowS
show :: ContentTypeProfile -> String
$cshow :: ContentTypeProfile -> String
showsPrec :: Int -> ContentTypeProfile -> ShowS
$cshowsPrec :: Int -> ContentTypeProfile -> ShowS
Prelude.Show, (forall x. ContentTypeProfile -> Rep ContentTypeProfile x)
-> (forall x. Rep ContentTypeProfile x -> ContentTypeProfile)
-> Generic ContentTypeProfile
forall x. Rep ContentTypeProfile x -> ContentTypeProfile
forall x. ContentTypeProfile -> Rep ContentTypeProfile x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ContentTypeProfile x -> ContentTypeProfile
$cfrom :: forall x. ContentTypeProfile -> Rep ContentTypeProfile x
Prelude.Generic)

-- |
-- Create a value of 'ContentTypeProfile' 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:
--
-- 'profileId', 'contentTypeProfile_profileId' - The profile ID for a field-level encryption content type-profile
-- mapping.
--
-- 'format', 'contentTypeProfile_format' - The format for a field-level encryption content type-profile mapping.
--
-- 'contentType', 'contentTypeProfile_contentType' - The content type for a field-level encryption content type-profile
-- mapping.
newContentTypeProfile ::
  -- | 'format'
  Format ->
  -- | 'contentType'
  Prelude.Text ->
  ContentTypeProfile
newContentTypeProfile :: Format -> Text -> ContentTypeProfile
newContentTypeProfile Format
pFormat_ Text
pContentType_ =
  ContentTypeProfile' :: Maybe Text -> Format -> Text -> ContentTypeProfile
ContentTypeProfile'
    { $sel:profileId:ContentTypeProfile' :: Maybe Text
profileId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:format:ContentTypeProfile' :: Format
format = Format
pFormat_,
      $sel:contentType:ContentTypeProfile' :: Text
contentType = Text
pContentType_
    }

-- | The profile ID for a field-level encryption content type-profile
-- mapping.
contentTypeProfile_profileId :: Lens.Lens' ContentTypeProfile (Prelude.Maybe Prelude.Text)
contentTypeProfile_profileId :: (Maybe Text -> f (Maybe Text))
-> ContentTypeProfile -> f ContentTypeProfile
contentTypeProfile_profileId = (ContentTypeProfile -> Maybe Text)
-> (ContentTypeProfile -> Maybe Text -> ContentTypeProfile)
-> Lens
     ContentTypeProfile ContentTypeProfile (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContentTypeProfile' {Maybe Text
profileId :: Maybe Text
$sel:profileId:ContentTypeProfile' :: ContentTypeProfile -> Maybe Text
profileId} -> Maybe Text
profileId) (\s :: ContentTypeProfile
s@ContentTypeProfile' {} Maybe Text
a -> ContentTypeProfile
s {$sel:profileId:ContentTypeProfile' :: Maybe Text
profileId = Maybe Text
a} :: ContentTypeProfile)

-- | The format for a field-level encryption content type-profile mapping.
contentTypeProfile_format :: Lens.Lens' ContentTypeProfile Format
contentTypeProfile_format :: (Format -> f Format) -> ContentTypeProfile -> f ContentTypeProfile
contentTypeProfile_format = (ContentTypeProfile -> Format)
-> (ContentTypeProfile -> Format -> ContentTypeProfile)
-> Lens ContentTypeProfile ContentTypeProfile Format Format
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContentTypeProfile' {Format
format :: Format
$sel:format:ContentTypeProfile' :: ContentTypeProfile -> Format
format} -> Format
format) (\s :: ContentTypeProfile
s@ContentTypeProfile' {} Format
a -> ContentTypeProfile
s {$sel:format:ContentTypeProfile' :: Format
format = Format
a} :: ContentTypeProfile)

-- | The content type for a field-level encryption content type-profile
-- mapping.
contentTypeProfile_contentType :: Lens.Lens' ContentTypeProfile Prelude.Text
contentTypeProfile_contentType :: (Text -> f Text) -> ContentTypeProfile -> f ContentTypeProfile
contentTypeProfile_contentType = (ContentTypeProfile -> Text)
-> (ContentTypeProfile -> Text -> ContentTypeProfile)
-> Lens ContentTypeProfile ContentTypeProfile Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContentTypeProfile' {Text
contentType :: Text
$sel:contentType:ContentTypeProfile' :: ContentTypeProfile -> Text
contentType} -> Text
contentType) (\s :: ContentTypeProfile
s@ContentTypeProfile' {} Text
a -> ContentTypeProfile
s {$sel:contentType:ContentTypeProfile' :: Text
contentType = Text
a} :: ContentTypeProfile)

instance Core.FromXML ContentTypeProfile where
  parseXML :: [Node] -> Either String ContentTypeProfile
parseXML [Node]
x =
    Maybe Text -> Format -> Text -> ContentTypeProfile
ContentTypeProfile'
      (Maybe Text -> Format -> Text -> ContentTypeProfile)
-> Either String (Maybe Text)
-> Either String (Format -> Text -> ContentTypeProfile)
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
"ProfileId")
      Either String (Format -> Text -> ContentTypeProfile)
-> Either String Format
-> Either String (Text -> ContentTypeProfile)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Format
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Format")
      Either String (Text -> ContentTypeProfile)
-> Either String Text -> Either String ContentTypeProfile
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
"ContentType")

instance Prelude.Hashable ContentTypeProfile

instance Prelude.NFData ContentTypeProfile

instance Core.ToXML ContentTypeProfile where
  toXML :: ContentTypeProfile -> XML
toXML ContentTypeProfile' {Maybe Text
Text
Format
contentType :: Text
format :: Format
profileId :: Maybe Text
$sel:contentType:ContentTypeProfile' :: ContentTypeProfile -> Text
$sel:format:ContentTypeProfile' :: ContentTypeProfile -> Format
$sel:profileId:ContentTypeProfile' :: ContentTypeProfile -> Maybe Text
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"ProfileId" Name -> Maybe Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe Text
profileId,
        Name
"Format" Name -> Format -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Format
format,
        Name
"ContentType" Name -> Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Text
contentType
      ]