{-# 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.ApiGatewayV2.Types.Cors where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data Cors = Cors'
{
Cors -> Maybe Int
maxAge :: Prelude.Maybe Prelude.Int,
Cors -> Maybe [Text]
allowMethods :: Prelude.Maybe [Prelude.Text],
:: Prelude.Maybe [Prelude.Text],
:: Prelude.Maybe [Prelude.Text],
Cors -> Maybe [Text]
allowOrigins :: Prelude.Maybe [Prelude.Text],
Cors -> Maybe Bool
allowCredentials :: Prelude.Maybe Prelude.Bool
}
deriving (Cors -> Cors -> Bool
(Cors -> Cors -> Bool) -> (Cors -> Cors -> Bool) -> Eq Cors
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Cors -> Cors -> Bool
$c/= :: Cors -> Cors -> Bool
== :: Cors -> Cors -> Bool
$c== :: Cors -> Cors -> Bool
Prelude.Eq, ReadPrec [Cors]
ReadPrec Cors
Int -> ReadS Cors
ReadS [Cors]
(Int -> ReadS Cors)
-> ReadS [Cors] -> ReadPrec Cors -> ReadPrec [Cors] -> Read Cors
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Cors]
$creadListPrec :: ReadPrec [Cors]
readPrec :: ReadPrec Cors
$creadPrec :: ReadPrec Cors
readList :: ReadS [Cors]
$creadList :: ReadS [Cors]
readsPrec :: Int -> ReadS Cors
$creadsPrec :: Int -> ReadS Cors
Prelude.Read, Int -> Cors -> ShowS
[Cors] -> ShowS
Cors -> String
(Int -> Cors -> ShowS)
-> (Cors -> String) -> ([Cors] -> ShowS) -> Show Cors
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Cors] -> ShowS
$cshowList :: [Cors] -> ShowS
show :: Cors -> String
$cshow :: Cors -> String
showsPrec :: Int -> Cors -> ShowS
$cshowsPrec :: Int -> Cors -> ShowS
Prelude.Show, (forall x. Cors -> Rep Cors x)
-> (forall x. Rep Cors x -> Cors) -> Generic Cors
forall x. Rep Cors x -> Cors
forall x. Cors -> Rep Cors x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Cors x -> Cors
$cfrom :: forall x. Cors -> Rep Cors x
Prelude.Generic)
newCors ::
Cors
newCors :: Cors
newCors =
Cors' :: Maybe Int
-> Maybe [Text]
-> Maybe [Text]
-> Maybe [Text]
-> Maybe [Text]
-> Maybe Bool
-> Cors
Cors'
{ $sel:maxAge:Cors' :: Maybe Int
maxAge = Maybe Int
forall a. Maybe a
Prelude.Nothing,
$sel:allowMethods:Cors' :: Maybe [Text]
allowMethods = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
$sel:allowHeaders:Cors' :: Maybe [Text]
allowHeaders = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
$sel:exposeHeaders:Cors' :: Maybe [Text]
exposeHeaders = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
$sel:allowOrigins:Cors' :: Maybe [Text]
allowOrigins = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
$sel:allowCredentials:Cors' :: Maybe Bool
allowCredentials = Maybe Bool
forall a. Maybe a
Prelude.Nothing
}
cors_maxAge :: Lens.Lens' Cors (Prelude.Maybe Prelude.Int)
cors_maxAge :: (Maybe Int -> f (Maybe Int)) -> Cors -> f Cors
cors_maxAge = (Cors -> Maybe Int)
-> (Cors -> Maybe Int -> Cors)
-> Lens Cors Cors (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Cors' {Maybe Int
maxAge :: Maybe Int
$sel:maxAge:Cors' :: Cors -> Maybe Int
maxAge} -> Maybe Int
maxAge) (\s :: Cors
s@Cors' {} Maybe Int
a -> Cors
s {$sel:maxAge:Cors' :: Maybe Int
maxAge = Maybe Int
a} :: Cors)
cors_allowMethods :: Lens.Lens' Cors (Prelude.Maybe [Prelude.Text])
cors_allowMethods :: (Maybe [Text] -> f (Maybe [Text])) -> Cors -> f Cors
cors_allowMethods = (Cors -> Maybe [Text])
-> (Cors -> Maybe [Text] -> Cors)
-> Lens Cors Cors (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Cors' {Maybe [Text]
allowMethods :: Maybe [Text]
$sel:allowMethods:Cors' :: Cors -> Maybe [Text]
allowMethods} -> Maybe [Text]
allowMethods) (\s :: Cors
s@Cors' {} Maybe [Text]
a -> Cors
s {$sel:allowMethods:Cors' :: Maybe [Text]
allowMethods = Maybe [Text]
a} :: Cors) ((Maybe [Text] -> f (Maybe [Text])) -> Cors -> f Cors)
-> ((Maybe [Text] -> f (Maybe [Text]))
-> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Cors
-> f Cors
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
cors_allowHeaders :: Lens.Lens' Cors (Prelude.Maybe [Prelude.Text])
= (Cors -> Maybe [Text])
-> (Cors -> Maybe [Text] -> Cors)
-> Lens Cors Cors (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Cors' {Maybe [Text]
allowHeaders :: Maybe [Text]
$sel:allowHeaders:Cors' :: Cors -> Maybe [Text]
allowHeaders} -> Maybe [Text]
allowHeaders) (\s :: Cors
s@Cors' {} Maybe [Text]
a -> Cors
s {$sel:allowHeaders:Cors' :: Maybe [Text]
allowHeaders = Maybe [Text]
a} :: Cors) ((Maybe [Text] -> f (Maybe [Text])) -> Cors -> f Cors)
-> ((Maybe [Text] -> f (Maybe [Text]))
-> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Cors
-> f Cors
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
cors_exposeHeaders :: Lens.Lens' Cors (Prelude.Maybe [Prelude.Text])
= (Cors -> Maybe [Text])
-> (Cors -> Maybe [Text] -> Cors)
-> Lens Cors Cors (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Cors' {Maybe [Text]
exposeHeaders :: Maybe [Text]
$sel:exposeHeaders:Cors' :: Cors -> Maybe [Text]
exposeHeaders} -> Maybe [Text]
exposeHeaders) (\s :: Cors
s@Cors' {} Maybe [Text]
a -> Cors
s {$sel:exposeHeaders:Cors' :: Maybe [Text]
exposeHeaders = Maybe [Text]
a} :: Cors) ((Maybe [Text] -> f (Maybe [Text])) -> Cors -> f Cors)
-> ((Maybe [Text] -> f (Maybe [Text]))
-> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Cors
-> f Cors
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
cors_allowOrigins :: Lens.Lens' Cors (Prelude.Maybe [Prelude.Text])
cors_allowOrigins :: (Maybe [Text] -> f (Maybe [Text])) -> Cors -> f Cors
cors_allowOrigins = (Cors -> Maybe [Text])
-> (Cors -> Maybe [Text] -> Cors)
-> Lens Cors Cors (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Cors' {Maybe [Text]
allowOrigins :: Maybe [Text]
$sel:allowOrigins:Cors' :: Cors -> Maybe [Text]
allowOrigins} -> Maybe [Text]
allowOrigins) (\s :: Cors
s@Cors' {} Maybe [Text]
a -> Cors
s {$sel:allowOrigins:Cors' :: Maybe [Text]
allowOrigins = Maybe [Text]
a} :: Cors) ((Maybe [Text] -> f (Maybe [Text])) -> Cors -> f Cors)
-> ((Maybe [Text] -> f (Maybe [Text]))
-> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Cors
-> f Cors
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
cors_allowCredentials :: Lens.Lens' Cors (Prelude.Maybe Prelude.Bool)
cors_allowCredentials :: (Maybe Bool -> f (Maybe Bool)) -> Cors -> f Cors
cors_allowCredentials = (Cors -> Maybe Bool)
-> (Cors -> Maybe Bool -> Cors)
-> Lens Cors Cors (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Cors' {Maybe Bool
allowCredentials :: Maybe Bool
$sel:allowCredentials:Cors' :: Cors -> Maybe Bool
allowCredentials} -> Maybe Bool
allowCredentials) (\s :: Cors
s@Cors' {} Maybe Bool
a -> Cors
s {$sel:allowCredentials:Cors' :: Maybe Bool
allowCredentials = Maybe Bool
a} :: Cors)
instance Core.FromJSON Cors where
parseJSON :: Value -> Parser Cors
parseJSON =
String -> (Object -> Parser Cors) -> Value -> Parser Cors
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"Cors"
( \Object
x ->
Maybe Int
-> Maybe [Text]
-> Maybe [Text]
-> Maybe [Text]
-> Maybe [Text]
-> Maybe Bool
-> Cors
Cors'
(Maybe Int
-> Maybe [Text]
-> Maybe [Text]
-> Maybe [Text]
-> Maybe [Text]
-> Maybe Bool
-> Cors)
-> Parser (Maybe Int)
-> Parser
(Maybe [Text]
-> Maybe [Text]
-> Maybe [Text]
-> Maybe [Text]
-> Maybe Bool
-> Cors)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"maxAge")
Parser
(Maybe [Text]
-> Maybe [Text]
-> Maybe [Text]
-> Maybe [Text]
-> Maybe Bool
-> Cors)
-> Parser (Maybe [Text])
-> Parser
(Maybe [Text]
-> Maybe [Text] -> Maybe [Text] -> Maybe Bool -> Cors)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"allowMethods" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
Parser
(Maybe [Text]
-> Maybe [Text] -> Maybe [Text] -> Maybe Bool -> Cors)
-> Parser (Maybe [Text])
-> Parser (Maybe [Text] -> Maybe [Text] -> Maybe Bool -> Cors)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"allowHeaders" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
Parser (Maybe [Text] -> Maybe [Text] -> Maybe Bool -> Cors)
-> Parser (Maybe [Text])
-> Parser (Maybe [Text] -> Maybe Bool -> Cors)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"exposeHeaders" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
Parser (Maybe [Text] -> Maybe Bool -> Cors)
-> Parser (Maybe [Text]) -> Parser (Maybe Bool -> Cors)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"allowOrigins" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
Parser (Maybe Bool -> Cors) -> Parser (Maybe Bool) -> Parser Cors
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"allowCredentials")
)
instance Prelude.Hashable Cors
instance Prelude.NFData Cors
instance Core.ToJSON Cors where
toJSON :: Cors -> Value
toJSON Cors' {Maybe Bool
Maybe Int
Maybe [Text]
allowCredentials :: Maybe Bool
allowOrigins :: Maybe [Text]
exposeHeaders :: Maybe [Text]
allowHeaders :: Maybe [Text]
allowMethods :: Maybe [Text]
maxAge :: Maybe Int
$sel:allowCredentials:Cors' :: Cors -> Maybe Bool
$sel:allowOrigins:Cors' :: Cors -> Maybe [Text]
$sel:exposeHeaders:Cors' :: Cors -> Maybe [Text]
$sel:allowHeaders:Cors' :: Cors -> Maybe [Text]
$sel:allowMethods:Cors' :: Cors -> Maybe [Text]
$sel:maxAge:Cors' :: Cors -> Maybe Int
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"maxAge" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
maxAge,
(Text
"allowMethods" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
allowMethods,
(Text
"allowHeaders" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
allowHeaders,
(Text
"exposeHeaders" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
exposeHeaders,
(Text
"allowOrigins" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
allowOrigins,
(Text
"allowCredentials" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
allowCredentials
]
)