{-# 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
{ $sel:cachedMethods:AllowedMethods' :: Maybe CachedMethods
cachedMethods = forall a. Maybe a
Prelude.Nothing,
$sel:quantity:AllowedMethods' :: Int
quantity = Int
pQuantity_,
$sel:items:AllowedMethods' :: [Method]
items = forall a. Monoid a => a
Prelude.mempty
}
allowedMethods_cachedMethods :: Lens.Lens' AllowedMethods (Prelude.Maybe CachedMethods)
allowedMethods_cachedMethods :: Lens' AllowedMethods (Maybe CachedMethods)
allowedMethods_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 :: Lens' AllowedMethods Int
allowedMethods_quantity = 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 :: Lens' AllowedMethods [Method]
allowedMethods_items = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Data.FromXML AllowedMethods where
parseXML :: [Node] -> Either String AllowedMethods
parseXML [Node]
x =
Maybe CachedMethods -> Int -> [Method] -> AllowedMethods
AllowedMethods'
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
"CachedMethods")
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
"Quantity")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Items"
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"Method"
)
instance Prelude.Hashable AllowedMethods where
hashWithSalt :: Int -> AllowedMethods -> Int
hashWithSalt Int
_salt 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
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CachedMethods
cachedMethods
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
quantity
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Method]
items
instance Prelude.NFData AllowedMethods where
rnf :: AllowedMethods -> ()
rnf 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
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe CachedMethods
cachedMethods
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
quantity
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Method]
items
instance Data.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
..} =
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ Name
"CachedMethods" forall a. ToXML a => Name -> a -> XML
Data.@= Maybe CachedMethods
cachedMethods,
Name
"Quantity" forall a. ToXML a => Name -> a -> XML
Data.@= Int
quantity,
Name
"Items" forall a. ToXML a => Name -> a -> XML
Data.@= forall a. (IsList a, ToXML (Item a)) => Name -> a -> XML
Data.toXMLList Name
"Method" [Method]
items
]