{-# 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.CachedMethods where
import Amazonka.CloudFront.Types.Method
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data CachedMethods = CachedMethods'
{
CachedMethods -> Int
quantity :: Prelude.Int,
CachedMethods -> [Method]
items :: [Method]
}
deriving (CachedMethods -> CachedMethods -> Bool
(CachedMethods -> CachedMethods -> Bool)
-> (CachedMethods -> CachedMethods -> Bool) -> Eq CachedMethods
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CachedMethods -> CachedMethods -> Bool
$c/= :: CachedMethods -> CachedMethods -> Bool
== :: CachedMethods -> CachedMethods -> Bool
$c== :: CachedMethods -> CachedMethods -> Bool
Prelude.Eq, ReadPrec [CachedMethods]
ReadPrec CachedMethods
Int -> ReadS CachedMethods
ReadS [CachedMethods]
(Int -> ReadS CachedMethods)
-> ReadS [CachedMethods]
-> ReadPrec CachedMethods
-> ReadPrec [CachedMethods]
-> Read CachedMethods
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CachedMethods]
$creadListPrec :: ReadPrec [CachedMethods]
readPrec :: ReadPrec CachedMethods
$creadPrec :: ReadPrec CachedMethods
readList :: ReadS [CachedMethods]
$creadList :: ReadS [CachedMethods]
readsPrec :: Int -> ReadS CachedMethods
$creadsPrec :: Int -> ReadS CachedMethods
Prelude.Read, Int -> CachedMethods -> ShowS
[CachedMethods] -> ShowS
CachedMethods -> String
(Int -> CachedMethods -> ShowS)
-> (CachedMethods -> String)
-> ([CachedMethods] -> ShowS)
-> Show CachedMethods
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CachedMethods] -> ShowS
$cshowList :: [CachedMethods] -> ShowS
show :: CachedMethods -> String
$cshow :: CachedMethods -> String
showsPrec :: Int -> CachedMethods -> ShowS
$cshowsPrec :: Int -> CachedMethods -> ShowS
Prelude.Show, (forall x. CachedMethods -> Rep CachedMethods x)
-> (forall x. Rep CachedMethods x -> CachedMethods)
-> Generic CachedMethods
forall x. Rep CachedMethods x -> CachedMethods
forall x. CachedMethods -> Rep CachedMethods x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CachedMethods x -> CachedMethods
$cfrom :: forall x. CachedMethods -> Rep CachedMethods x
Prelude.Generic)
newCachedMethods ::
Prelude.Int ->
CachedMethods
newCachedMethods :: Int -> CachedMethods
newCachedMethods Int
pQuantity_ =
CachedMethods' :: Int -> [Method] -> CachedMethods
CachedMethods'
{ $sel:quantity:CachedMethods' :: Int
quantity = Int
pQuantity_,
$sel:items:CachedMethods' :: [Method]
items = [Method]
forall a. Monoid a => a
Prelude.mempty
}
cachedMethods_quantity :: Lens.Lens' CachedMethods Prelude.Int
cachedMethods_quantity :: (Int -> f Int) -> CachedMethods -> f CachedMethods
cachedMethods_quantity = (CachedMethods -> Int)
-> (CachedMethods -> Int -> CachedMethods)
-> Lens CachedMethods CachedMethods Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CachedMethods' {Int
quantity :: Int
$sel:quantity:CachedMethods' :: CachedMethods -> Int
quantity} -> Int
quantity) (\s :: CachedMethods
s@CachedMethods' {} Int
a -> CachedMethods
s {$sel:quantity:CachedMethods' :: Int
quantity = Int
a} :: CachedMethods)
cachedMethods_items :: Lens.Lens' CachedMethods [Method]
cachedMethods_items :: ([Method] -> f [Method]) -> CachedMethods -> f CachedMethods
cachedMethods_items = (CachedMethods -> [Method])
-> (CachedMethods -> [Method] -> CachedMethods)
-> Lens CachedMethods CachedMethods [Method] [Method]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CachedMethods' {[Method]
items :: [Method]
$sel:items:CachedMethods' :: CachedMethods -> [Method]
items} -> [Method]
items) (\s :: CachedMethods
s@CachedMethods' {} [Method]
a -> CachedMethods
s {$sel:items:CachedMethods' :: [Method]
items = [Method]
a} :: CachedMethods) (([Method] -> f [Method]) -> CachedMethods -> f CachedMethods)
-> (([Method] -> f [Method]) -> [Method] -> f [Method])
-> ([Method] -> f [Method])
-> CachedMethods
-> f CachedMethods
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 CachedMethods where
parseXML :: [Node] -> Either String CachedMethods
parseXML [Node]
x =
Int -> [Method] -> CachedMethods
CachedMethods'
(Int -> [Method] -> CachedMethods)
-> Either String Int -> Either String ([Method] -> CachedMethods)
forall (f :: * -> *) a b. Functor 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] -> CachedMethods)
-> Either String [Method] -> Either String CachedMethods
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 CachedMethods
instance Prelude.NFData CachedMethods
instance Core.ToXML CachedMethods where
toXML :: CachedMethods -> XML
toXML CachedMethods' {Int
[Method]
items :: [Method]
quantity :: Int
$sel:items:CachedMethods' :: CachedMethods -> [Method]
$sel:quantity:CachedMethods' :: CachedMethods -> Int
..} =
[XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ 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
]