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