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