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

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

-- | Field-level encryption content type-profile.
--
-- /See:/ 'newContentTypeProfiles' smart constructor.
data ContentTypeProfiles = ContentTypeProfiles'
  { -- | Items in a field-level encryption content type-profile mapping.
    ContentTypeProfiles -> Maybe [ContentTypeProfile]
items :: Prelude.Maybe [ContentTypeProfile],
    -- | The number of field-level encryption content type-profile mappings.
    ContentTypeProfiles -> Int
quantity :: Prelude.Int
  }
  deriving (ContentTypeProfiles -> ContentTypeProfiles -> Bool
(ContentTypeProfiles -> ContentTypeProfiles -> Bool)
-> (ContentTypeProfiles -> ContentTypeProfiles -> Bool)
-> Eq ContentTypeProfiles
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ContentTypeProfiles -> ContentTypeProfiles -> Bool
$c/= :: ContentTypeProfiles -> ContentTypeProfiles -> Bool
== :: ContentTypeProfiles -> ContentTypeProfiles -> Bool
$c== :: ContentTypeProfiles -> ContentTypeProfiles -> Bool
Prelude.Eq, ReadPrec [ContentTypeProfiles]
ReadPrec ContentTypeProfiles
Int -> ReadS ContentTypeProfiles
ReadS [ContentTypeProfiles]
(Int -> ReadS ContentTypeProfiles)
-> ReadS [ContentTypeProfiles]
-> ReadPrec ContentTypeProfiles
-> ReadPrec [ContentTypeProfiles]
-> Read ContentTypeProfiles
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ContentTypeProfiles]
$creadListPrec :: ReadPrec [ContentTypeProfiles]
readPrec :: ReadPrec ContentTypeProfiles
$creadPrec :: ReadPrec ContentTypeProfiles
readList :: ReadS [ContentTypeProfiles]
$creadList :: ReadS [ContentTypeProfiles]
readsPrec :: Int -> ReadS ContentTypeProfiles
$creadsPrec :: Int -> ReadS ContentTypeProfiles
Prelude.Read, Int -> ContentTypeProfiles -> ShowS
[ContentTypeProfiles] -> ShowS
ContentTypeProfiles -> String
(Int -> ContentTypeProfiles -> ShowS)
-> (ContentTypeProfiles -> String)
-> ([ContentTypeProfiles] -> ShowS)
-> Show ContentTypeProfiles
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ContentTypeProfiles] -> ShowS
$cshowList :: [ContentTypeProfiles] -> ShowS
show :: ContentTypeProfiles -> String
$cshow :: ContentTypeProfiles -> String
showsPrec :: Int -> ContentTypeProfiles -> ShowS
$cshowsPrec :: Int -> ContentTypeProfiles -> ShowS
Prelude.Show, (forall x. ContentTypeProfiles -> Rep ContentTypeProfiles x)
-> (forall x. Rep ContentTypeProfiles x -> ContentTypeProfiles)
-> Generic ContentTypeProfiles
forall x. Rep ContentTypeProfiles x -> ContentTypeProfiles
forall x. ContentTypeProfiles -> Rep ContentTypeProfiles x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ContentTypeProfiles x -> ContentTypeProfiles
$cfrom :: forall x. ContentTypeProfiles -> Rep ContentTypeProfiles x
Prelude.Generic)

-- |
-- Create a value of 'ContentTypeProfiles' 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:
--
-- 'items', 'contentTypeProfiles_items' - Items in a field-level encryption content type-profile mapping.
--
-- 'quantity', 'contentTypeProfiles_quantity' - The number of field-level encryption content type-profile mappings.
newContentTypeProfiles ::
  -- | 'quantity'
  Prelude.Int ->
  ContentTypeProfiles
newContentTypeProfiles :: Int -> ContentTypeProfiles
newContentTypeProfiles Int
pQuantity_ =
  ContentTypeProfiles' :: Maybe [ContentTypeProfile] -> Int -> ContentTypeProfiles
ContentTypeProfiles'
    { $sel:items:ContentTypeProfiles' :: Maybe [ContentTypeProfile]
items = Maybe [ContentTypeProfile]
forall a. Maybe a
Prelude.Nothing,
      $sel:quantity:ContentTypeProfiles' :: Int
quantity = Int
pQuantity_
    }

-- | Items in a field-level encryption content type-profile mapping.
contentTypeProfiles_items :: Lens.Lens' ContentTypeProfiles (Prelude.Maybe [ContentTypeProfile])
contentTypeProfiles_items :: (Maybe [ContentTypeProfile] -> f (Maybe [ContentTypeProfile]))
-> ContentTypeProfiles -> f ContentTypeProfiles
contentTypeProfiles_items = (ContentTypeProfiles -> Maybe [ContentTypeProfile])
-> (ContentTypeProfiles
    -> Maybe [ContentTypeProfile] -> ContentTypeProfiles)
-> Lens
     ContentTypeProfiles
     ContentTypeProfiles
     (Maybe [ContentTypeProfile])
     (Maybe [ContentTypeProfile])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContentTypeProfiles' {Maybe [ContentTypeProfile]
items :: Maybe [ContentTypeProfile]
$sel:items:ContentTypeProfiles' :: ContentTypeProfiles -> Maybe [ContentTypeProfile]
items} -> Maybe [ContentTypeProfile]
items) (\s :: ContentTypeProfiles
s@ContentTypeProfiles' {} Maybe [ContentTypeProfile]
a -> ContentTypeProfiles
s {$sel:items:ContentTypeProfiles' :: Maybe [ContentTypeProfile]
items = Maybe [ContentTypeProfile]
a} :: ContentTypeProfiles) ((Maybe [ContentTypeProfile] -> f (Maybe [ContentTypeProfile]))
 -> ContentTypeProfiles -> f ContentTypeProfiles)
-> ((Maybe [ContentTypeProfile] -> f (Maybe [ContentTypeProfile]))
    -> Maybe [ContentTypeProfile] -> f (Maybe [ContentTypeProfile]))
-> (Maybe [ContentTypeProfile] -> f (Maybe [ContentTypeProfile]))
-> ContentTypeProfiles
-> f ContentTypeProfiles
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ContentTypeProfile]
  [ContentTypeProfile]
  [ContentTypeProfile]
  [ContentTypeProfile]
-> Iso
     (Maybe [ContentTypeProfile])
     (Maybe [ContentTypeProfile])
     (Maybe [ContentTypeProfile])
     (Maybe [ContentTypeProfile])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [ContentTypeProfile]
  [ContentTypeProfile]
  [ContentTypeProfile]
  [ContentTypeProfile]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The number of field-level encryption content type-profile mappings.
contentTypeProfiles_quantity :: Lens.Lens' ContentTypeProfiles Prelude.Int
contentTypeProfiles_quantity :: (Int -> f Int) -> ContentTypeProfiles -> f ContentTypeProfiles
contentTypeProfiles_quantity = (ContentTypeProfiles -> Int)
-> (ContentTypeProfiles -> Int -> ContentTypeProfiles)
-> Lens ContentTypeProfiles ContentTypeProfiles Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContentTypeProfiles' {Int
quantity :: Int
$sel:quantity:ContentTypeProfiles' :: ContentTypeProfiles -> Int
quantity} -> Int
quantity) (\s :: ContentTypeProfiles
s@ContentTypeProfiles' {} Int
a -> ContentTypeProfiles
s {$sel:quantity:ContentTypeProfiles' :: Int
quantity = Int
a} :: ContentTypeProfiles)

instance Core.FromXML ContentTypeProfiles where
  parseXML :: [Node] -> Either String ContentTypeProfiles
parseXML [Node]
x =
    Maybe [ContentTypeProfile] -> Int -> ContentTypeProfiles
ContentTypeProfiles'
      (Maybe [ContentTypeProfile] -> Int -> ContentTypeProfiles)
-> Either String (Maybe [ContentTypeProfile])
-> Either String (Int -> ContentTypeProfiles)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Items" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                      Either String [Node]
-> ([Node] -> Either String (Maybe [ContentTypeProfile]))
-> Either String (Maybe [ContentTypeProfile])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [ContentTypeProfile])
-> [Node] -> Either String (Maybe [ContentTypeProfile])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [ContentTypeProfile]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"ContentTypeProfile")
                  )
      Either String (Int -> ContentTypeProfiles)
-> Either String Int -> Either String ContentTypeProfiles
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Int
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Quantity")

instance Prelude.Hashable ContentTypeProfiles

instance Prelude.NFData ContentTypeProfiles

instance Core.ToXML ContentTypeProfiles where
  toXML :: ContentTypeProfiles -> XML
toXML ContentTypeProfiles' {Int
Maybe [ContentTypeProfile]
quantity :: Int
items :: Maybe [ContentTypeProfile]
$sel:quantity:ContentTypeProfiles' :: ContentTypeProfiles -> Int
$sel:items:ContentTypeProfiles' :: ContentTypeProfiles -> Maybe [ContentTypeProfile]
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"Items"
          Name -> XML -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe XML -> XML
forall a. ToXML a => a -> XML
Core.toXML
            ( Name -> [ContentTypeProfile] -> XML
forall a. (IsList a, ToXML (Item a)) => Name -> a -> XML
Core.toXMLList Name
"ContentTypeProfile"
                ([ContentTypeProfile] -> XML)
-> Maybe [ContentTypeProfile] -> Maybe XML
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [ContentTypeProfile]
items
            ),
        Name
"Quantity" Name -> Int -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Int
quantity
      ]