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