{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.SecurityHub.Types.AwsCorsConfiguration
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SecurityHub.Types.AwsCorsConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains the cross-origin resource sharing (CORS) configuration for the
-- API. CORS is only supported for HTTP APIs.
--
-- /See:/ 'newAwsCorsConfiguration' smart constructor.
data AwsCorsConfiguration = AwsCorsConfiguration'
  { -- | The number of seconds for which the browser caches preflight request
    -- results.
    AwsCorsConfiguration -> Maybe Int
maxAge :: Prelude.Maybe Prelude.Int,
    -- | The allowed methods for CORS requests.
    AwsCorsConfiguration -> Maybe [Text]
allowMethods :: Prelude.Maybe [Prelude.Text],
    -- | The allowed headers for CORS requests.
    AwsCorsConfiguration -> Maybe [Text]
allowHeaders :: Prelude.Maybe [Prelude.Text],
    -- | The exposed headers for CORS requests.
    AwsCorsConfiguration -> Maybe [Text]
exposeHeaders :: Prelude.Maybe [Prelude.Text],
    -- | The allowed origins for CORS requests.
    AwsCorsConfiguration -> Maybe [Text]
allowOrigins :: Prelude.Maybe [Prelude.Text],
    -- | Indicates whether the CORS request includes credentials.
    AwsCorsConfiguration -> Maybe Bool
allowCredentials :: Prelude.Maybe Prelude.Bool
  }
  deriving (AwsCorsConfiguration -> AwsCorsConfiguration -> Bool
(AwsCorsConfiguration -> AwsCorsConfiguration -> Bool)
-> (AwsCorsConfiguration -> AwsCorsConfiguration -> Bool)
-> Eq AwsCorsConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsCorsConfiguration -> AwsCorsConfiguration -> Bool
$c/= :: AwsCorsConfiguration -> AwsCorsConfiguration -> Bool
== :: AwsCorsConfiguration -> AwsCorsConfiguration -> Bool
$c== :: AwsCorsConfiguration -> AwsCorsConfiguration -> Bool
Prelude.Eq, ReadPrec [AwsCorsConfiguration]
ReadPrec AwsCorsConfiguration
Int -> ReadS AwsCorsConfiguration
ReadS [AwsCorsConfiguration]
(Int -> ReadS AwsCorsConfiguration)
-> ReadS [AwsCorsConfiguration]
-> ReadPrec AwsCorsConfiguration
-> ReadPrec [AwsCorsConfiguration]
-> Read AwsCorsConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsCorsConfiguration]
$creadListPrec :: ReadPrec [AwsCorsConfiguration]
readPrec :: ReadPrec AwsCorsConfiguration
$creadPrec :: ReadPrec AwsCorsConfiguration
readList :: ReadS [AwsCorsConfiguration]
$creadList :: ReadS [AwsCorsConfiguration]
readsPrec :: Int -> ReadS AwsCorsConfiguration
$creadsPrec :: Int -> ReadS AwsCorsConfiguration
Prelude.Read, Int -> AwsCorsConfiguration -> ShowS
[AwsCorsConfiguration] -> ShowS
AwsCorsConfiguration -> String
(Int -> AwsCorsConfiguration -> ShowS)
-> (AwsCorsConfiguration -> String)
-> ([AwsCorsConfiguration] -> ShowS)
-> Show AwsCorsConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsCorsConfiguration] -> ShowS
$cshowList :: [AwsCorsConfiguration] -> ShowS
show :: AwsCorsConfiguration -> String
$cshow :: AwsCorsConfiguration -> String
showsPrec :: Int -> AwsCorsConfiguration -> ShowS
$cshowsPrec :: Int -> AwsCorsConfiguration -> ShowS
Prelude.Show, (forall x. AwsCorsConfiguration -> Rep AwsCorsConfiguration x)
-> (forall x. Rep AwsCorsConfiguration x -> AwsCorsConfiguration)
-> Generic AwsCorsConfiguration
forall x. Rep AwsCorsConfiguration x -> AwsCorsConfiguration
forall x. AwsCorsConfiguration -> Rep AwsCorsConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AwsCorsConfiguration x -> AwsCorsConfiguration
$cfrom :: forall x. AwsCorsConfiguration -> Rep AwsCorsConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'AwsCorsConfiguration' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'maxAge', 'awsCorsConfiguration_maxAge' - The number of seconds for which the browser caches preflight request
-- results.
--
-- 'allowMethods', 'awsCorsConfiguration_allowMethods' - The allowed methods for CORS requests.
--
-- 'allowHeaders', 'awsCorsConfiguration_allowHeaders' - The allowed headers for CORS requests.
--
-- 'exposeHeaders', 'awsCorsConfiguration_exposeHeaders' - The exposed headers for CORS requests.
--
-- 'allowOrigins', 'awsCorsConfiguration_allowOrigins' - The allowed origins for CORS requests.
--
-- 'allowCredentials', 'awsCorsConfiguration_allowCredentials' - Indicates whether the CORS request includes credentials.
newAwsCorsConfiguration ::
  AwsCorsConfiguration
newAwsCorsConfiguration :: AwsCorsConfiguration
newAwsCorsConfiguration =
  AwsCorsConfiguration' :: Maybe Int
-> Maybe [Text]
-> Maybe [Text]
-> Maybe [Text]
-> Maybe [Text]
-> Maybe Bool
-> AwsCorsConfiguration
AwsCorsConfiguration'
    { $sel:maxAge:AwsCorsConfiguration' :: Maybe Int
maxAge = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:allowMethods:AwsCorsConfiguration' :: Maybe [Text]
allowMethods = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:allowHeaders:AwsCorsConfiguration' :: Maybe [Text]
allowHeaders = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:exposeHeaders:AwsCorsConfiguration' :: Maybe [Text]
exposeHeaders = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:allowOrigins:AwsCorsConfiguration' :: Maybe [Text]
allowOrigins = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:allowCredentials:AwsCorsConfiguration' :: Maybe Bool
allowCredentials = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | The number of seconds for which the browser caches preflight request
-- results.
awsCorsConfiguration_maxAge :: Lens.Lens' AwsCorsConfiguration (Prelude.Maybe Prelude.Int)
awsCorsConfiguration_maxAge :: (Maybe Int -> f (Maybe Int))
-> AwsCorsConfiguration -> f AwsCorsConfiguration
awsCorsConfiguration_maxAge = (AwsCorsConfiguration -> Maybe Int)
-> (AwsCorsConfiguration -> Maybe Int -> AwsCorsConfiguration)
-> Lens
     AwsCorsConfiguration AwsCorsConfiguration (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsCorsConfiguration' {Maybe Int
maxAge :: Maybe Int
$sel:maxAge:AwsCorsConfiguration' :: AwsCorsConfiguration -> Maybe Int
maxAge} -> Maybe Int
maxAge) (\s :: AwsCorsConfiguration
s@AwsCorsConfiguration' {} Maybe Int
a -> AwsCorsConfiguration
s {$sel:maxAge:AwsCorsConfiguration' :: Maybe Int
maxAge = Maybe Int
a} :: AwsCorsConfiguration)

-- | The allowed methods for CORS requests.
awsCorsConfiguration_allowMethods :: Lens.Lens' AwsCorsConfiguration (Prelude.Maybe [Prelude.Text])
awsCorsConfiguration_allowMethods :: (Maybe [Text] -> f (Maybe [Text]))
-> AwsCorsConfiguration -> f AwsCorsConfiguration
awsCorsConfiguration_allowMethods = (AwsCorsConfiguration -> Maybe [Text])
-> (AwsCorsConfiguration -> Maybe [Text] -> AwsCorsConfiguration)
-> Lens
     AwsCorsConfiguration
     AwsCorsConfiguration
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsCorsConfiguration' {Maybe [Text]
allowMethods :: Maybe [Text]
$sel:allowMethods:AwsCorsConfiguration' :: AwsCorsConfiguration -> Maybe [Text]
allowMethods} -> Maybe [Text]
allowMethods) (\s :: AwsCorsConfiguration
s@AwsCorsConfiguration' {} Maybe [Text]
a -> AwsCorsConfiguration
s {$sel:allowMethods:AwsCorsConfiguration' :: Maybe [Text]
allowMethods = Maybe [Text]
a} :: AwsCorsConfiguration) ((Maybe [Text] -> f (Maybe [Text]))
 -> AwsCorsConfiguration -> f AwsCorsConfiguration)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> AwsCorsConfiguration
-> f AwsCorsConfiguration
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

-- | The allowed headers for CORS requests.
awsCorsConfiguration_allowHeaders :: Lens.Lens' AwsCorsConfiguration (Prelude.Maybe [Prelude.Text])
awsCorsConfiguration_allowHeaders :: (Maybe [Text] -> f (Maybe [Text]))
-> AwsCorsConfiguration -> f AwsCorsConfiguration
awsCorsConfiguration_allowHeaders = (AwsCorsConfiguration -> Maybe [Text])
-> (AwsCorsConfiguration -> Maybe [Text] -> AwsCorsConfiguration)
-> Lens
     AwsCorsConfiguration
     AwsCorsConfiguration
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsCorsConfiguration' {Maybe [Text]
allowHeaders :: Maybe [Text]
$sel:allowHeaders:AwsCorsConfiguration' :: AwsCorsConfiguration -> Maybe [Text]
allowHeaders} -> Maybe [Text]
allowHeaders) (\s :: AwsCorsConfiguration
s@AwsCorsConfiguration' {} Maybe [Text]
a -> AwsCorsConfiguration
s {$sel:allowHeaders:AwsCorsConfiguration' :: Maybe [Text]
allowHeaders = Maybe [Text]
a} :: AwsCorsConfiguration) ((Maybe [Text] -> f (Maybe [Text]))
 -> AwsCorsConfiguration -> f AwsCorsConfiguration)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> AwsCorsConfiguration
-> f AwsCorsConfiguration
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

-- | The exposed headers for CORS requests.
awsCorsConfiguration_exposeHeaders :: Lens.Lens' AwsCorsConfiguration (Prelude.Maybe [Prelude.Text])
awsCorsConfiguration_exposeHeaders :: (Maybe [Text] -> f (Maybe [Text]))
-> AwsCorsConfiguration -> f AwsCorsConfiguration
awsCorsConfiguration_exposeHeaders = (AwsCorsConfiguration -> Maybe [Text])
-> (AwsCorsConfiguration -> Maybe [Text] -> AwsCorsConfiguration)
-> Lens
     AwsCorsConfiguration
     AwsCorsConfiguration
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsCorsConfiguration' {Maybe [Text]
exposeHeaders :: Maybe [Text]
$sel:exposeHeaders:AwsCorsConfiguration' :: AwsCorsConfiguration -> Maybe [Text]
exposeHeaders} -> Maybe [Text]
exposeHeaders) (\s :: AwsCorsConfiguration
s@AwsCorsConfiguration' {} Maybe [Text]
a -> AwsCorsConfiguration
s {$sel:exposeHeaders:AwsCorsConfiguration' :: Maybe [Text]
exposeHeaders = Maybe [Text]
a} :: AwsCorsConfiguration) ((Maybe [Text] -> f (Maybe [Text]))
 -> AwsCorsConfiguration -> f AwsCorsConfiguration)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> AwsCorsConfiguration
-> f AwsCorsConfiguration
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

-- | The allowed origins for CORS requests.
awsCorsConfiguration_allowOrigins :: Lens.Lens' AwsCorsConfiguration (Prelude.Maybe [Prelude.Text])
awsCorsConfiguration_allowOrigins :: (Maybe [Text] -> f (Maybe [Text]))
-> AwsCorsConfiguration -> f AwsCorsConfiguration
awsCorsConfiguration_allowOrigins = (AwsCorsConfiguration -> Maybe [Text])
-> (AwsCorsConfiguration -> Maybe [Text] -> AwsCorsConfiguration)
-> Lens
     AwsCorsConfiguration
     AwsCorsConfiguration
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsCorsConfiguration' {Maybe [Text]
allowOrigins :: Maybe [Text]
$sel:allowOrigins:AwsCorsConfiguration' :: AwsCorsConfiguration -> Maybe [Text]
allowOrigins} -> Maybe [Text]
allowOrigins) (\s :: AwsCorsConfiguration
s@AwsCorsConfiguration' {} Maybe [Text]
a -> AwsCorsConfiguration
s {$sel:allowOrigins:AwsCorsConfiguration' :: Maybe [Text]
allowOrigins = Maybe [Text]
a} :: AwsCorsConfiguration) ((Maybe [Text] -> f (Maybe [Text]))
 -> AwsCorsConfiguration -> f AwsCorsConfiguration)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> AwsCorsConfiguration
-> f AwsCorsConfiguration
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

-- | Indicates whether the CORS request includes credentials.
awsCorsConfiguration_allowCredentials :: Lens.Lens' AwsCorsConfiguration (Prelude.Maybe Prelude.Bool)
awsCorsConfiguration_allowCredentials :: (Maybe Bool -> f (Maybe Bool))
-> AwsCorsConfiguration -> f AwsCorsConfiguration
awsCorsConfiguration_allowCredentials = (AwsCorsConfiguration -> Maybe Bool)
-> (AwsCorsConfiguration -> Maybe Bool -> AwsCorsConfiguration)
-> Lens
     AwsCorsConfiguration AwsCorsConfiguration (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsCorsConfiguration' {Maybe Bool
allowCredentials :: Maybe Bool
$sel:allowCredentials:AwsCorsConfiguration' :: AwsCorsConfiguration -> Maybe Bool
allowCredentials} -> Maybe Bool
allowCredentials) (\s :: AwsCorsConfiguration
s@AwsCorsConfiguration' {} Maybe Bool
a -> AwsCorsConfiguration
s {$sel:allowCredentials:AwsCorsConfiguration' :: Maybe Bool
allowCredentials = Maybe Bool
a} :: AwsCorsConfiguration)

instance Core.FromJSON AwsCorsConfiguration where
  parseJSON :: Value -> Parser AwsCorsConfiguration
parseJSON =
    String
-> (Object -> Parser AwsCorsConfiguration)
-> Value
-> Parser AwsCorsConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsCorsConfiguration"
      ( \Object
x ->
          Maybe Int
-> Maybe [Text]
-> Maybe [Text]
-> Maybe [Text]
-> Maybe [Text]
-> Maybe Bool
-> AwsCorsConfiguration
AwsCorsConfiguration'
            (Maybe Int
 -> Maybe [Text]
 -> Maybe [Text]
 -> Maybe [Text]
 -> Maybe [Text]
 -> Maybe Bool
 -> AwsCorsConfiguration)
-> Parser (Maybe Int)
-> Parser
     (Maybe [Text]
      -> Maybe [Text]
      -> Maybe [Text]
      -> Maybe [Text]
      -> Maybe Bool
      -> AwsCorsConfiguration)
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
   -> AwsCorsConfiguration)
-> Parser (Maybe [Text])
-> Parser
     (Maybe [Text]
      -> Maybe [Text]
      -> Maybe [Text]
      -> Maybe Bool
      -> AwsCorsConfiguration)
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
   -> AwsCorsConfiguration)
-> Parser (Maybe [Text])
-> Parser
     (Maybe [Text]
      -> Maybe [Text] -> Maybe Bool -> AwsCorsConfiguration)
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 -> AwsCorsConfiguration)
-> Parser (Maybe [Text])
-> Parser (Maybe [Text] -> Maybe Bool -> AwsCorsConfiguration)
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 -> AwsCorsConfiguration)
-> Parser (Maybe [Text])
-> Parser (Maybe Bool -> AwsCorsConfiguration)
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 -> AwsCorsConfiguration)
-> Parser (Maybe Bool) -> Parser AwsCorsConfiguration
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 AwsCorsConfiguration

instance Prelude.NFData AwsCorsConfiguration

instance Core.ToJSON AwsCorsConfiguration where
  toJSON :: AwsCorsConfiguration -> Value
toJSON AwsCorsConfiguration' {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:AwsCorsConfiguration' :: AwsCorsConfiguration -> Maybe Bool
$sel:allowOrigins:AwsCorsConfiguration' :: AwsCorsConfiguration -> Maybe [Text]
$sel:exposeHeaders:AwsCorsConfiguration' :: AwsCorsConfiguration -> Maybe [Text]
$sel:allowHeaders:AwsCorsConfiguration' :: AwsCorsConfiguration -> Maybe [Text]
$sel:allowMethods:AwsCorsConfiguration' :: AwsCorsConfiguration -> Maybe [Text]
$sel:maxAge:AwsCorsConfiguration' :: AwsCorsConfiguration -> 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
          ]
      )