{-# 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.S3.Types.CORSRule where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.S3.Internal
data CORSRule = CORSRule'
{
CORSRule -> Maybe Int
maxAgeSeconds :: Prelude.Maybe Prelude.Int,
:: Prelude.Maybe [Prelude.Text],
:: Prelude.Maybe [Prelude.Text],
CORSRule -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
CORSRule -> [Text]
allowedMethods :: [Prelude.Text],
CORSRule -> [Text]
allowedOrigins :: [Prelude.Text]
}
deriving (CORSRule -> CORSRule -> Bool
(CORSRule -> CORSRule -> Bool)
-> (CORSRule -> CORSRule -> Bool) -> Eq CORSRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CORSRule -> CORSRule -> Bool
$c/= :: CORSRule -> CORSRule -> Bool
== :: CORSRule -> CORSRule -> Bool
$c== :: CORSRule -> CORSRule -> Bool
Prelude.Eq, ReadPrec [CORSRule]
ReadPrec CORSRule
Int -> ReadS CORSRule
ReadS [CORSRule]
(Int -> ReadS CORSRule)
-> ReadS [CORSRule]
-> ReadPrec CORSRule
-> ReadPrec [CORSRule]
-> Read CORSRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CORSRule]
$creadListPrec :: ReadPrec [CORSRule]
readPrec :: ReadPrec CORSRule
$creadPrec :: ReadPrec CORSRule
readList :: ReadS [CORSRule]
$creadList :: ReadS [CORSRule]
readsPrec :: Int -> ReadS CORSRule
$creadsPrec :: Int -> ReadS CORSRule
Prelude.Read, Int -> CORSRule -> ShowS
[CORSRule] -> ShowS
CORSRule -> String
(Int -> CORSRule -> ShowS)
-> (CORSRule -> String) -> ([CORSRule] -> ShowS) -> Show CORSRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CORSRule] -> ShowS
$cshowList :: [CORSRule] -> ShowS
show :: CORSRule -> String
$cshow :: CORSRule -> String
showsPrec :: Int -> CORSRule -> ShowS
$cshowsPrec :: Int -> CORSRule -> ShowS
Prelude.Show, (forall x. CORSRule -> Rep CORSRule x)
-> (forall x. Rep CORSRule x -> CORSRule) -> Generic CORSRule
forall x. Rep CORSRule x -> CORSRule
forall x. CORSRule -> Rep CORSRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CORSRule x -> CORSRule
$cfrom :: forall x. CORSRule -> Rep CORSRule x
Prelude.Generic)
newCORSRule ::
CORSRule
newCORSRule :: CORSRule
newCORSRule =
CORSRule' :: Maybe Int
-> Maybe [Text]
-> Maybe [Text]
-> Maybe Text
-> [Text]
-> [Text]
-> CORSRule
CORSRule'
{ $sel:maxAgeSeconds:CORSRule' :: Maybe Int
maxAgeSeconds = Maybe Int
forall a. Maybe a
Prelude.Nothing,
$sel:allowedHeaders:CORSRule' :: Maybe [Text]
allowedHeaders = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
$sel:exposeHeaders:CORSRule' :: Maybe [Text]
exposeHeaders = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
$sel:id:CORSRule' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:allowedMethods:CORSRule' :: [Text]
allowedMethods = [Text]
forall a. Monoid a => a
Prelude.mempty,
$sel:allowedOrigins:CORSRule' :: [Text]
allowedOrigins = [Text]
forall a. Monoid a => a
Prelude.mempty
}
cORSRule_maxAgeSeconds :: Lens.Lens' CORSRule (Prelude.Maybe Prelude.Int)
cORSRule_maxAgeSeconds :: (Maybe Int -> f (Maybe Int)) -> CORSRule -> f CORSRule
cORSRule_maxAgeSeconds = (CORSRule -> Maybe Int)
-> (CORSRule -> Maybe Int -> CORSRule)
-> Lens CORSRule CORSRule (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CORSRule' {Maybe Int
maxAgeSeconds :: Maybe Int
$sel:maxAgeSeconds:CORSRule' :: CORSRule -> Maybe Int
maxAgeSeconds} -> Maybe Int
maxAgeSeconds) (\s :: CORSRule
s@CORSRule' {} Maybe Int
a -> CORSRule
s {$sel:maxAgeSeconds:CORSRule' :: Maybe Int
maxAgeSeconds = Maybe Int
a} :: CORSRule)
cORSRule_allowedHeaders :: Lens.Lens' CORSRule (Prelude.Maybe [Prelude.Text])
= (CORSRule -> Maybe [Text])
-> (CORSRule -> Maybe [Text] -> CORSRule)
-> Lens CORSRule CORSRule (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CORSRule' {Maybe [Text]
allowedHeaders :: Maybe [Text]
$sel:allowedHeaders:CORSRule' :: CORSRule -> Maybe [Text]
allowedHeaders} -> Maybe [Text]
allowedHeaders) (\s :: CORSRule
s@CORSRule' {} Maybe [Text]
a -> CORSRule
s {$sel:allowedHeaders:CORSRule' :: Maybe [Text]
allowedHeaders = Maybe [Text]
a} :: CORSRule) ((Maybe [Text] -> f (Maybe [Text])) -> CORSRule -> f CORSRule)
-> ((Maybe [Text] -> f (Maybe [Text]))
-> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> CORSRule
-> f CORSRule
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
cORSRule_exposeHeaders :: Lens.Lens' CORSRule (Prelude.Maybe [Prelude.Text])
= (CORSRule -> Maybe [Text])
-> (CORSRule -> Maybe [Text] -> CORSRule)
-> Lens CORSRule CORSRule (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CORSRule' {Maybe [Text]
exposeHeaders :: Maybe [Text]
$sel:exposeHeaders:CORSRule' :: CORSRule -> Maybe [Text]
exposeHeaders} -> Maybe [Text]
exposeHeaders) (\s :: CORSRule
s@CORSRule' {} Maybe [Text]
a -> CORSRule
s {$sel:exposeHeaders:CORSRule' :: Maybe [Text]
exposeHeaders = Maybe [Text]
a} :: CORSRule) ((Maybe [Text] -> f (Maybe [Text])) -> CORSRule -> f CORSRule)
-> ((Maybe [Text] -> f (Maybe [Text]))
-> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> CORSRule
-> f CORSRule
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
cORSRule_id :: Lens.Lens' CORSRule (Prelude.Maybe Prelude.Text)
cORSRule_id :: (Maybe Text -> f (Maybe Text)) -> CORSRule -> f CORSRule
cORSRule_id = (CORSRule -> Maybe Text)
-> (CORSRule -> Maybe Text -> CORSRule)
-> Lens CORSRule CORSRule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CORSRule' {Maybe Text
id :: Maybe Text
$sel:id:CORSRule' :: CORSRule -> Maybe Text
id} -> Maybe Text
id) (\s :: CORSRule
s@CORSRule' {} Maybe Text
a -> CORSRule
s {$sel:id:CORSRule' :: Maybe Text
id = Maybe Text
a} :: CORSRule)
cORSRule_allowedMethods :: Lens.Lens' CORSRule [Prelude.Text]
cORSRule_allowedMethods :: ([Text] -> f [Text]) -> CORSRule -> f CORSRule
cORSRule_allowedMethods = (CORSRule -> [Text])
-> (CORSRule -> [Text] -> CORSRule)
-> Lens CORSRule CORSRule [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CORSRule' {[Text]
allowedMethods :: [Text]
$sel:allowedMethods:CORSRule' :: CORSRule -> [Text]
allowedMethods} -> [Text]
allowedMethods) (\s :: CORSRule
s@CORSRule' {} [Text]
a -> CORSRule
s {$sel:allowedMethods:CORSRule' :: [Text]
allowedMethods = [Text]
a} :: CORSRule) (([Text] -> f [Text]) -> CORSRule -> f CORSRule)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> CORSRule
-> f CORSRule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
cORSRule_allowedOrigins :: Lens.Lens' CORSRule [Prelude.Text]
cORSRule_allowedOrigins :: ([Text] -> f [Text]) -> CORSRule -> f CORSRule
cORSRule_allowedOrigins = (CORSRule -> [Text])
-> (CORSRule -> [Text] -> CORSRule)
-> Lens CORSRule CORSRule [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CORSRule' {[Text]
allowedOrigins :: [Text]
$sel:allowedOrigins:CORSRule' :: CORSRule -> [Text]
allowedOrigins} -> [Text]
allowedOrigins) (\s :: CORSRule
s@CORSRule' {} [Text]
a -> CORSRule
s {$sel:allowedOrigins:CORSRule' :: [Text]
allowedOrigins = [Text]
a} :: CORSRule) (([Text] -> f [Text]) -> CORSRule -> f CORSRule)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> CORSRule
-> f CORSRule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.FromXML CORSRule where
parseXML :: [Node] -> Either String CORSRule
parseXML [Node]
x =
Maybe Int
-> Maybe [Text]
-> Maybe [Text]
-> Maybe Text
-> [Text]
-> [Text]
-> CORSRule
CORSRule'
(Maybe Int
-> Maybe [Text]
-> Maybe [Text]
-> Maybe Text
-> [Text]
-> [Text]
-> CORSRule)
-> Either String (Maybe Int)
-> Either
String
(Maybe [Text]
-> Maybe [Text] -> Maybe Text -> [Text] -> [Text] -> CORSRule)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Int)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"MaxAgeSeconds")
Either
String
(Maybe [Text]
-> Maybe [Text] -> Maybe Text -> [Text] -> [Text] -> CORSRule)
-> Either String (Maybe [Text])
-> Either
String (Maybe [Text] -> Maybe Text -> [Text] -> [Text] -> CORSRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f 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
"AllowedHeader") [Node]
x)
Either
String (Maybe [Text] -> Maybe Text -> [Text] -> [Text] -> CORSRule)
-> Either String (Maybe [Text])
-> Either String (Maybe Text -> [Text] -> [Text] -> CORSRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f 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
"ExposeHeader") [Node]
x)
Either String (Maybe Text -> [Text] -> [Text] -> CORSRule)
-> Either String (Maybe Text)
-> Either String ([Text] -> [Text] -> CORSRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ID")
Either String ([Text] -> [Text] -> CORSRule)
-> Either String [Text] -> Either String ([Text] -> CORSRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Text -> [Node] -> Either String [Text]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"AllowedMethod" [Node]
x)
Either String ([Text] -> CORSRule)
-> Either String [Text] -> Either String CORSRule
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Text -> [Node] -> Either String [Text]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"AllowedOrigin" [Node]
x)
instance Prelude.Hashable CORSRule
instance Prelude.NFData CORSRule
instance Core.ToXML CORSRule where
toXML :: CORSRule -> XML
toXML CORSRule' {[Text]
Maybe Int
Maybe [Text]
Maybe Text
allowedOrigins :: [Text]
allowedMethods :: [Text]
id :: Maybe Text
exposeHeaders :: Maybe [Text]
allowedHeaders :: Maybe [Text]
maxAgeSeconds :: Maybe Int
$sel:allowedOrigins:CORSRule' :: CORSRule -> [Text]
$sel:allowedMethods:CORSRule' :: CORSRule -> [Text]
$sel:id:CORSRule' :: CORSRule -> Maybe Text
$sel:exposeHeaders:CORSRule' :: CORSRule -> Maybe [Text]
$sel:allowedHeaders:CORSRule' :: CORSRule -> Maybe [Text]
$sel:maxAgeSeconds:CORSRule' :: CORSRule -> Maybe Int
..} =
[XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ Name
"MaxAgeSeconds" Name -> Maybe Int -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe Int
maxAgeSeconds,
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
"AllowedHeader"
([Text] -> XML) -> Maybe [Text] -> Maybe XML
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
allowedHeaders
),
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
"ExposeHeader"
([Text] -> XML) -> Maybe [Text] -> Maybe XML
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
exposeHeaders
),
Name
"ID" Name -> Maybe Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe Text
id,
Name -> [Text] -> XML
forall a. (IsList a, ToXML (Item a)) => Name -> a -> XML
Core.toXMLList Name
"AllowedMethod" [Text]
allowedMethods,
Name -> [Text] -> XML
forall a. (IsList a, ToXML (Item a)) => Name -> a -> XML
Core.toXMLList Name
"AllowedOrigin" [Text]
allowedOrigins
]