{-# 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.StatusCodes where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data StatusCodes = StatusCodes'
{
StatusCodes -> Int
quantity :: Prelude.Int,
StatusCodes -> NonEmpty Int
items :: Prelude.NonEmpty Prelude.Int
}
deriving (StatusCodes -> StatusCodes -> Bool
(StatusCodes -> StatusCodes -> Bool)
-> (StatusCodes -> StatusCodes -> Bool) -> Eq StatusCodes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StatusCodes -> StatusCodes -> Bool
$c/= :: StatusCodes -> StatusCodes -> Bool
== :: StatusCodes -> StatusCodes -> Bool
$c== :: StatusCodes -> StatusCodes -> Bool
Prelude.Eq, ReadPrec [StatusCodes]
ReadPrec StatusCodes
Int -> ReadS StatusCodes
ReadS [StatusCodes]
(Int -> ReadS StatusCodes)
-> ReadS [StatusCodes]
-> ReadPrec StatusCodes
-> ReadPrec [StatusCodes]
-> Read StatusCodes
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StatusCodes]
$creadListPrec :: ReadPrec [StatusCodes]
readPrec :: ReadPrec StatusCodes
$creadPrec :: ReadPrec StatusCodes
readList :: ReadS [StatusCodes]
$creadList :: ReadS [StatusCodes]
readsPrec :: Int -> ReadS StatusCodes
$creadsPrec :: Int -> ReadS StatusCodes
Prelude.Read, Int -> StatusCodes -> ShowS
[StatusCodes] -> ShowS
StatusCodes -> String
(Int -> StatusCodes -> ShowS)
-> (StatusCodes -> String)
-> ([StatusCodes] -> ShowS)
-> Show StatusCodes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StatusCodes] -> ShowS
$cshowList :: [StatusCodes] -> ShowS
show :: StatusCodes -> String
$cshow :: StatusCodes -> String
showsPrec :: Int -> StatusCodes -> ShowS
$cshowsPrec :: Int -> StatusCodes -> ShowS
Prelude.Show, (forall x. StatusCodes -> Rep StatusCodes x)
-> (forall x. Rep StatusCodes x -> StatusCodes)
-> Generic StatusCodes
forall x. Rep StatusCodes x -> StatusCodes
forall x. StatusCodes -> Rep StatusCodes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StatusCodes x -> StatusCodes
$cfrom :: forall x. StatusCodes -> Rep StatusCodes x
Prelude.Generic)
newStatusCodes ::
Prelude.Int ->
Prelude.NonEmpty Prelude.Int ->
StatusCodes
newStatusCodes :: Int -> NonEmpty Int -> StatusCodes
newStatusCodes Int
pQuantity_ NonEmpty Int
pItems_ =
StatusCodes' :: Int -> NonEmpty Int -> StatusCodes
StatusCodes'
{ $sel:quantity:StatusCodes' :: Int
quantity = Int
pQuantity_,
$sel:items:StatusCodes' :: NonEmpty Int
items = Tagged (NonEmpty Int) (Identity (NonEmpty Int))
-> Tagged (NonEmpty Int) (Identity (NonEmpty Int))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Int) (Identity (NonEmpty Int))
-> Tagged (NonEmpty Int) (Identity (NonEmpty Int)))
-> NonEmpty Int -> NonEmpty Int
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Int
pItems_
}
statusCodes_quantity :: Lens.Lens' StatusCodes Prelude.Int
statusCodes_quantity :: (Int -> f Int) -> StatusCodes -> f StatusCodes
statusCodes_quantity = (StatusCodes -> Int)
-> (StatusCodes -> Int -> StatusCodes)
-> Lens StatusCodes StatusCodes Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StatusCodes' {Int
quantity :: Int
$sel:quantity:StatusCodes' :: StatusCodes -> Int
quantity} -> Int
quantity) (\s :: StatusCodes
s@StatusCodes' {} Int
a -> StatusCodes
s {$sel:quantity:StatusCodes' :: Int
quantity = Int
a} :: StatusCodes)
statusCodes_items :: Lens.Lens' StatusCodes (Prelude.NonEmpty Prelude.Int)
statusCodes_items :: (NonEmpty Int -> f (NonEmpty Int)) -> StatusCodes -> f StatusCodes
statusCodes_items = (StatusCodes -> NonEmpty Int)
-> (StatusCodes -> NonEmpty Int -> StatusCodes)
-> Lens StatusCodes StatusCodes (NonEmpty Int) (NonEmpty Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StatusCodes' {NonEmpty Int
items :: NonEmpty Int
$sel:items:StatusCodes' :: StatusCodes -> NonEmpty Int
items} -> NonEmpty Int
items) (\s :: StatusCodes
s@StatusCodes' {} NonEmpty Int
a -> StatusCodes
s {$sel:items:StatusCodes' :: NonEmpty Int
items = NonEmpty Int
a} :: StatusCodes) ((NonEmpty Int -> f (NonEmpty Int))
-> StatusCodes -> f StatusCodes)
-> ((NonEmpty Int -> f (NonEmpty Int))
-> NonEmpty Int -> f (NonEmpty Int))
-> (NonEmpty Int -> f (NonEmpty Int))
-> StatusCodes
-> f StatusCodes
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Int -> f (NonEmpty Int))
-> NonEmpty Int -> f (NonEmpty Int)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.FromXML StatusCodes where
parseXML :: [Node] -> Either String StatusCodes
parseXML [Node]
x =
Int -> NonEmpty Int -> StatusCodes
StatusCodes'
(Int -> NonEmpty Int -> StatusCodes)
-> Either String Int -> Either String (NonEmpty Int -> StatusCodes)
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 (NonEmpty Int -> StatusCodes)
-> Either String (NonEmpty Int) -> Either String StatusCodes
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 (NonEmpty Int))
-> Either String (NonEmpty Int)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= Text -> [Node] -> Either String (NonEmpty Int)
forall a. FromXML a => Text -> [Node] -> Either String (NonEmpty a)
Core.parseXMLList1 Text
"StatusCode"
)
instance Prelude.Hashable StatusCodes
instance Prelude.NFData StatusCodes
instance Core.ToXML StatusCodes where
toXML :: StatusCodes -> XML
toXML StatusCodes' {Int
NonEmpty Int
items :: NonEmpty Int
quantity :: Int
$sel:items:StatusCodes' :: StatusCodes -> NonEmpty Int
$sel:quantity:StatusCodes' :: StatusCodes -> 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 -> NonEmpty Int -> XML
forall a. (IsList a, ToXML (Item a)) => Name -> a -> XML
Core.toXMLList Name
"StatusCode" NonEmpty Int
items
]