{-# 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
{ $sel:items:GeoRestriction' :: Maybe [Text]
items = 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 :: Lens' GeoRestriction (Maybe [Text])
geoRestriction_items = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 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 :: Lens' GeoRestriction GeoRestrictionType
geoRestriction_restrictionType = 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 :: Lens' GeoRestriction Int
geoRestriction_quantity = 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 Data.FromXML GeoRestriction where
parseXML :: [Node] -> Either String GeoRestriction
parseXML [Node]
x =
Maybe [Text] -> GeoRestrictionType -> Int -> GeoRestriction
GeoRestriction'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Items"
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"Location")
)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"RestrictionType")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Quantity")
instance Prelude.Hashable GeoRestriction where
hashWithSalt :: Int -> GeoRestriction -> Int
hashWithSalt Int
_salt 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]
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
items
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` GeoRestrictionType
restrictionType
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
quantity
instance Prelude.NFData GeoRestriction where
rnf :: GeoRestriction -> ()
rnf 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]
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
items
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf GeoRestrictionType
restrictionType
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
quantity
instance Data.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]
..} =
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ Name
"Items"
forall a. ToXML a => Name -> a -> XML
Data.@= forall a. ToXML a => a -> XML
Data.toXML
(forall a. (IsList a, ToXML (Item a)) => Name -> a -> XML
Data.toXMLList Name
"Location" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
items),
Name
"RestrictionType" forall a. ToXML a => Name -> a -> XML
Data.@= GeoRestrictionType
restrictionType,
Name
"Quantity" forall a. ToXML a => Name -> a -> XML
Data.@= Int
quantity
]