{-# 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 #-}
module Amazonka.CloudFront.Types.CustomHeaders where
import Amazonka.CloudFront.Types.OriginCustomHeader
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data =
{
:: Prelude.Maybe [OriginCustomHeader],
:: Prelude.Int
}
deriving (CustomHeaders -> CustomHeaders -> Bool
(CustomHeaders -> CustomHeaders -> Bool)
-> (CustomHeaders -> CustomHeaders -> Bool) -> Eq CustomHeaders
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomHeaders -> CustomHeaders -> Bool
$c/= :: CustomHeaders -> CustomHeaders -> Bool
== :: CustomHeaders -> CustomHeaders -> Bool
$c== :: CustomHeaders -> CustomHeaders -> Bool
Prelude.Eq, ReadPrec [CustomHeaders]
ReadPrec CustomHeaders
Int -> ReadS CustomHeaders
ReadS [CustomHeaders]
(Int -> ReadS CustomHeaders)
-> ReadS [CustomHeaders]
-> ReadPrec CustomHeaders
-> ReadPrec [CustomHeaders]
-> Read CustomHeaders
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CustomHeaders]
$creadListPrec :: ReadPrec [CustomHeaders]
readPrec :: ReadPrec CustomHeaders
$creadPrec :: ReadPrec CustomHeaders
readList :: ReadS [CustomHeaders]
$creadList :: ReadS [CustomHeaders]
readsPrec :: Int -> ReadS CustomHeaders
$creadsPrec :: Int -> ReadS CustomHeaders
Prelude.Read, Int -> CustomHeaders -> ShowS
[CustomHeaders] -> ShowS
CustomHeaders -> String
(Int -> CustomHeaders -> ShowS)
-> (CustomHeaders -> String)
-> ([CustomHeaders] -> ShowS)
-> Show CustomHeaders
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomHeaders] -> ShowS
$cshowList :: [CustomHeaders] -> ShowS
show :: CustomHeaders -> String
$cshow :: CustomHeaders -> String
showsPrec :: Int -> CustomHeaders -> ShowS
$cshowsPrec :: Int -> CustomHeaders -> ShowS
Prelude.Show, (forall x. CustomHeaders -> Rep CustomHeaders x)
-> (forall x. Rep CustomHeaders x -> CustomHeaders)
-> Generic CustomHeaders
forall x. Rep CustomHeaders x -> CustomHeaders
forall x. CustomHeaders -> Rep CustomHeaders x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CustomHeaders x -> CustomHeaders
$cfrom :: forall x. CustomHeaders -> Rep CustomHeaders x
Prelude.Generic)
newCustomHeaders ::
Prelude.Int ->
CustomHeaders
Int
pQuantity_ =
CustomHeaders' :: Maybe [OriginCustomHeader] -> Int -> CustomHeaders
CustomHeaders'
{ $sel:items:CustomHeaders' :: Maybe [OriginCustomHeader]
items = Maybe [OriginCustomHeader]
forall a. Maybe a
Prelude.Nothing,
$sel:quantity:CustomHeaders' :: Int
quantity = Int
pQuantity_
}
customHeaders_items :: Lens.Lens' CustomHeaders (Prelude.Maybe [OriginCustomHeader])
= (CustomHeaders -> Maybe [OriginCustomHeader])
-> (CustomHeaders -> Maybe [OriginCustomHeader] -> CustomHeaders)
-> Lens
CustomHeaders
CustomHeaders
(Maybe [OriginCustomHeader])
(Maybe [OriginCustomHeader])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomHeaders' {Maybe [OriginCustomHeader]
items :: Maybe [OriginCustomHeader]
$sel:items:CustomHeaders' :: CustomHeaders -> Maybe [OriginCustomHeader]
items} -> Maybe [OriginCustomHeader]
items) (\s :: CustomHeaders
s@CustomHeaders' {} Maybe [OriginCustomHeader]
a -> CustomHeaders
s {$sel:items:CustomHeaders' :: Maybe [OriginCustomHeader]
items = Maybe [OriginCustomHeader]
a} :: CustomHeaders) ((Maybe [OriginCustomHeader] -> f (Maybe [OriginCustomHeader]))
-> CustomHeaders -> f CustomHeaders)
-> ((Maybe [OriginCustomHeader] -> f (Maybe [OriginCustomHeader]))
-> Maybe [OriginCustomHeader] -> f (Maybe [OriginCustomHeader]))
-> (Maybe [OriginCustomHeader] -> f (Maybe [OriginCustomHeader]))
-> CustomHeaders
-> f CustomHeaders
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[OriginCustomHeader]
[OriginCustomHeader]
[OriginCustomHeader]
[OriginCustomHeader]
-> Iso
(Maybe [OriginCustomHeader])
(Maybe [OriginCustomHeader])
(Maybe [OriginCustomHeader])
(Maybe [OriginCustomHeader])
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
[OriginCustomHeader]
[OriginCustomHeader]
[OriginCustomHeader]
[OriginCustomHeader]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
customHeaders_quantity :: Lens.Lens' CustomHeaders Prelude.Int
= (CustomHeaders -> Int)
-> (CustomHeaders -> Int -> CustomHeaders)
-> Lens CustomHeaders CustomHeaders Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomHeaders' {Int
quantity :: Int
$sel:quantity:CustomHeaders' :: CustomHeaders -> Int
quantity} -> Int
quantity) (\s :: CustomHeaders
s@CustomHeaders' {} Int
a -> CustomHeaders
s {$sel:quantity:CustomHeaders' :: Int
quantity = Int
a} :: CustomHeaders)
instance Core.FromXML CustomHeaders where
parseXML :: [Node] -> Either String CustomHeaders
parseXML [Node]
x =
Maybe [OriginCustomHeader] -> Int -> CustomHeaders
CustomHeaders'
(Maybe [OriginCustomHeader] -> Int -> CustomHeaders)
-> Either String (Maybe [OriginCustomHeader])
-> Either String (Int -> CustomHeaders)
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 [OriginCustomHeader]))
-> Either String (Maybe [OriginCustomHeader])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [OriginCustomHeader])
-> [Node] -> Either String (Maybe [OriginCustomHeader])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [OriginCustomHeader]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"OriginCustomHeader")
)
Either String (Int -> CustomHeaders)
-> Either String Int -> Either String CustomHeaders
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 CustomHeaders
instance Prelude.NFData CustomHeaders
instance Core.ToXML CustomHeaders where
toXML :: CustomHeaders -> XML
toXML CustomHeaders' {Int
Maybe [OriginCustomHeader]
quantity :: Int
items :: Maybe [OriginCustomHeader]
$sel:quantity:CustomHeaders' :: CustomHeaders -> Int
$sel:items:CustomHeaders' :: CustomHeaders -> Maybe [OriginCustomHeader]
..} =
[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 -> [OriginCustomHeader] -> XML
forall a. (IsList a, ToXML (Item a)) => Name -> a -> XML
Core.toXMLList Name
"OriginCustomHeader"
([OriginCustomHeader] -> XML)
-> Maybe [OriginCustomHeader] -> Maybe XML
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [OriginCustomHeader]
items
),
Name
"Quantity" Name -> Int -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Int
quantity
]