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