{-# 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.MediaStore.Types.CorsRule
-- 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.MediaStore.Types.CorsRule where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaStore.Types.MethodName
import qualified Amazonka.Prelude as Prelude

-- | A rule for a CORS policy. You can add up to 100 rules to a CORS policy.
-- If more than one rule applies, the service uses the first applicable
-- rule listed.
--
-- /See:/ 'newCorsRule' smart constructor.
data CorsRule = CorsRule'
  { -- | Identifies an HTTP method that the origin that is specified in the rule
    -- is allowed to execute.
    --
    -- Each CORS rule must contain at least one @AllowedMethods@ and one
    -- @AllowedOrigins@ element.
    CorsRule -> Maybe (NonEmpty MethodName)
allowedMethods :: Prelude.Maybe (Prelude.NonEmpty MethodName),
    -- | The time in seconds that your browser caches the preflight response for
    -- the specified resource.
    --
    -- A CORS rule can have only one @MaxAgeSeconds@ element.
    CorsRule -> Maybe Natural
maxAgeSeconds :: Prelude.Maybe Prelude.Natural,
    -- | One or more headers in the response that you want users to be able to
    -- access from their applications (for example, from a JavaScript
    -- @XMLHttpRequest@ object).
    --
    -- This element is optional for each rule.
    CorsRule -> Maybe [Text]
exposeHeaders :: Prelude.Maybe [Prelude.Text],
    -- | One or more response headers that you want users to be able to access
    -- from their applications (for example, from a JavaScript @XMLHttpRequest@
    -- object).
    --
    -- Each CORS rule must have at least one @AllowedOrigins@ element. The
    -- string value can include only one wildcard character (*), for example,
    -- http:\/\/*.example.com. Additionally, you can specify only one wildcard
    -- character to allow cross-origin access for all origins.
    CorsRule -> NonEmpty Text
allowedOrigins :: Prelude.NonEmpty Prelude.Text,
    -- | Specifies which headers are allowed in a preflight @OPTIONS@ request
    -- through the @Access-Control-Request-Headers@ header. Each header name
    -- that is specified in @Access-Control-Request-Headers@ must have a
    -- corresponding entry in the rule. Only the headers that were requested
    -- are sent back.
    --
    -- This element can contain only one wildcard character (*).
    CorsRule -> [Text]
allowedHeaders :: [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)

-- |
-- Create a value of 'CorsRule' 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:
--
-- 'allowedMethods', 'corsRule_allowedMethods' - Identifies an HTTP method that the origin that is specified in the rule
-- is allowed to execute.
--
-- Each CORS rule must contain at least one @AllowedMethods@ and one
-- @AllowedOrigins@ element.
--
-- 'maxAgeSeconds', 'corsRule_maxAgeSeconds' - The time in seconds that your browser caches the preflight response for
-- the specified resource.
--
-- A CORS rule can have only one @MaxAgeSeconds@ element.
--
-- 'exposeHeaders', 'corsRule_exposeHeaders' - One or more headers in the response that you want users to be able to
-- access from their applications (for example, from a JavaScript
-- @XMLHttpRequest@ object).
--
-- This element is optional for each rule.
--
-- 'allowedOrigins', 'corsRule_allowedOrigins' - One or more response headers that you want users to be able to access
-- from their applications (for example, from a JavaScript @XMLHttpRequest@
-- object).
--
-- Each CORS rule must have at least one @AllowedOrigins@ element. The
-- string value can include only one wildcard character (*), for example,
-- http:\/\/*.example.com. Additionally, you can specify only one wildcard
-- character to allow cross-origin access for all origins.
--
-- 'allowedHeaders', 'corsRule_allowedHeaders' - Specifies which headers are allowed in a preflight @OPTIONS@ request
-- through the @Access-Control-Request-Headers@ header. Each header name
-- that is specified in @Access-Control-Request-Headers@ must have a
-- corresponding entry in the rule. Only the headers that were requested
-- are sent back.
--
-- This element can contain only one wildcard character (*).
newCorsRule ::
  -- | 'allowedOrigins'
  Prelude.NonEmpty Prelude.Text ->
  CorsRule
newCorsRule :: NonEmpty Text -> CorsRule
newCorsRule NonEmpty Text
pAllowedOrigins_ =
  CorsRule' :: Maybe (NonEmpty MethodName)
-> Maybe Natural
-> Maybe [Text]
-> NonEmpty Text
-> [Text]
-> CorsRule
CorsRule'
    { $sel:allowedMethods:CorsRule' :: Maybe (NonEmpty MethodName)
allowedMethods = Maybe (NonEmpty MethodName)
forall a. Maybe a
Prelude.Nothing,
      $sel:maxAgeSeconds:CorsRule' :: Maybe Natural
maxAgeSeconds = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:exposeHeaders:CorsRule' :: Maybe [Text]
exposeHeaders = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:allowedOrigins:CorsRule' :: NonEmpty Text
allowedOrigins =
        Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Text) (Identity (NonEmpty Text))
 -> Tagged (NonEmpty Text) (Identity (NonEmpty Text)))
-> NonEmpty Text -> NonEmpty Text
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pAllowedOrigins_,
      $sel:allowedHeaders:CorsRule' :: [Text]
allowedHeaders = [Text]
forall a. Monoid a => a
Prelude.mempty
    }

-- | Identifies an HTTP method that the origin that is specified in the rule
-- is allowed to execute.
--
-- Each CORS rule must contain at least one @AllowedMethods@ and one
-- @AllowedOrigins@ element.
corsRule_allowedMethods :: Lens.Lens' CorsRule (Prelude.Maybe (Prelude.NonEmpty MethodName))
corsRule_allowedMethods :: (Maybe (NonEmpty MethodName) -> f (Maybe (NonEmpty MethodName)))
-> CorsRule -> f CorsRule
corsRule_allowedMethods = (CorsRule -> Maybe (NonEmpty MethodName))
-> (CorsRule -> Maybe (NonEmpty MethodName) -> CorsRule)
-> Lens
     CorsRule
     CorsRule
     (Maybe (NonEmpty MethodName))
     (Maybe (NonEmpty MethodName))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CorsRule' {Maybe (NonEmpty MethodName)
allowedMethods :: Maybe (NonEmpty MethodName)
$sel:allowedMethods:CorsRule' :: CorsRule -> Maybe (NonEmpty MethodName)
allowedMethods} -> Maybe (NonEmpty MethodName)
allowedMethods) (\s :: CorsRule
s@CorsRule' {} Maybe (NonEmpty MethodName)
a -> CorsRule
s {$sel:allowedMethods:CorsRule' :: Maybe (NonEmpty MethodName)
allowedMethods = Maybe (NonEmpty MethodName)
a} :: CorsRule) ((Maybe (NonEmpty MethodName) -> f (Maybe (NonEmpty MethodName)))
 -> CorsRule -> f CorsRule)
-> ((Maybe (NonEmpty MethodName)
     -> f (Maybe (NonEmpty MethodName)))
    -> Maybe (NonEmpty MethodName) -> f (Maybe (NonEmpty MethodName)))
-> (Maybe (NonEmpty MethodName) -> f (Maybe (NonEmpty MethodName)))
-> CorsRule
-> f CorsRule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty MethodName)
  (NonEmpty MethodName)
  (NonEmpty MethodName)
  (NonEmpty MethodName)
-> Iso
     (Maybe (NonEmpty MethodName))
     (Maybe (NonEmpty MethodName))
     (Maybe (NonEmpty MethodName))
     (Maybe (NonEmpty MethodName))
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
  (NonEmpty MethodName)
  (NonEmpty MethodName)
  (NonEmpty MethodName)
  (NonEmpty MethodName)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The time in seconds that your browser caches the preflight response for
-- the specified resource.
--
-- A CORS rule can have only one @MaxAgeSeconds@ element.
corsRule_maxAgeSeconds :: Lens.Lens' CorsRule (Prelude.Maybe Prelude.Natural)
corsRule_maxAgeSeconds :: (Maybe Natural -> f (Maybe Natural)) -> CorsRule -> f CorsRule
corsRule_maxAgeSeconds = (CorsRule -> Maybe Natural)
-> (CorsRule -> Maybe Natural -> CorsRule)
-> Lens CorsRule CorsRule (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CorsRule' {Maybe Natural
maxAgeSeconds :: Maybe Natural
$sel:maxAgeSeconds:CorsRule' :: CorsRule -> Maybe Natural
maxAgeSeconds} -> Maybe Natural
maxAgeSeconds) (\s :: CorsRule
s@CorsRule' {} Maybe Natural
a -> CorsRule
s {$sel:maxAgeSeconds:CorsRule' :: Maybe Natural
maxAgeSeconds = Maybe Natural
a} :: CorsRule)

-- | One or more headers in the response that you want users to be able to
-- access from their applications (for example, from a JavaScript
-- @XMLHttpRequest@ object).
--
-- This element is optional for each rule.
corsRule_exposeHeaders :: Lens.Lens' CorsRule (Prelude.Maybe [Prelude.Text])
corsRule_exposeHeaders :: (Maybe [Text] -> f (Maybe [Text])) -> CorsRule -> f CorsRule
corsRule_exposeHeaders = (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

-- | One or more response headers that you want users to be able to access
-- from their applications (for example, from a JavaScript @XMLHttpRequest@
-- object).
--
-- Each CORS rule must have at least one @AllowedOrigins@ element. The
-- string value can include only one wildcard character (*), for example,
-- http:\/\/*.example.com. Additionally, you can specify only one wildcard
-- character to allow cross-origin access for all origins.
corsRule_allowedOrigins :: Lens.Lens' CorsRule (Prelude.NonEmpty Prelude.Text)
corsRule_allowedOrigins :: (NonEmpty Text -> f (NonEmpty Text)) -> CorsRule -> f CorsRule
corsRule_allowedOrigins = (CorsRule -> NonEmpty Text)
-> (CorsRule -> NonEmpty Text -> CorsRule)
-> Lens CorsRule CorsRule (NonEmpty Text) (NonEmpty Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CorsRule' {NonEmpty Text
allowedOrigins :: NonEmpty Text
$sel:allowedOrigins:CorsRule' :: CorsRule -> NonEmpty Text
allowedOrigins} -> NonEmpty Text
allowedOrigins) (\s :: CorsRule
s@CorsRule' {} NonEmpty Text
a -> CorsRule
s {$sel:allowedOrigins:CorsRule' :: NonEmpty Text
allowedOrigins = NonEmpty Text
a} :: CorsRule) ((NonEmpty Text -> f (NonEmpty Text)) -> CorsRule -> f CorsRule)
-> ((NonEmpty Text -> f (NonEmpty Text))
    -> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> CorsRule
-> f CorsRule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Specifies which headers are allowed in a preflight @OPTIONS@ request
-- through the @Access-Control-Request-Headers@ header. Each header name
-- that is specified in @Access-Control-Request-Headers@ must have a
-- corresponding entry in the rule. Only the headers that were requested
-- are sent back.
--
-- This element can contain only one wildcard character (*).
corsRule_allowedHeaders :: Lens.Lens' CorsRule [Prelude.Text]
corsRule_allowedHeaders :: ([Text] -> f [Text]) -> CorsRule -> f CorsRule
corsRule_allowedHeaders = (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]
allowedHeaders :: [Text]
$sel:allowedHeaders:CorsRule' :: CorsRule -> [Text]
allowedHeaders} -> [Text]
allowedHeaders) (\s :: CorsRule
s@CorsRule' {} [Text]
a -> CorsRule
s {$sel:allowedHeaders:CorsRule' :: [Text]
allowedHeaders = [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.FromJSON CorsRule where
  parseJSON :: Value -> Parser CorsRule
parseJSON =
    String -> (Object -> Parser CorsRule) -> Value -> Parser CorsRule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CorsRule"
      ( \Object
x ->
          Maybe (NonEmpty MethodName)
-> Maybe Natural
-> Maybe [Text]
-> NonEmpty Text
-> [Text]
-> CorsRule
CorsRule'
            (Maybe (NonEmpty MethodName)
 -> Maybe Natural
 -> Maybe [Text]
 -> NonEmpty Text
 -> [Text]
 -> CorsRule)
-> Parser (Maybe (NonEmpty MethodName))
-> Parser
     (Maybe Natural
      -> Maybe [Text] -> NonEmpty Text -> [Text] -> CorsRule)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (NonEmpty MethodName))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AllowedMethods")
            Parser
  (Maybe Natural
   -> Maybe [Text] -> NonEmpty Text -> [Text] -> CorsRule)
-> Parser (Maybe Natural)
-> Parser (Maybe [Text] -> NonEmpty Text -> [Text] -> CorsRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MaxAgeSeconds")
            Parser (Maybe [Text] -> NonEmpty Text -> [Text] -> CorsRule)
-> Parser (Maybe [Text])
-> Parser (NonEmpty Text -> [Text] -> CorsRule)
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 (NonEmpty Text -> [Text] -> CorsRule)
-> Parser (NonEmpty Text) -> Parser ([Text] -> CorsRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (NonEmpty Text)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"AllowedOrigins")
            Parser ([Text] -> CorsRule) -> Parser [Text] -> Parser CorsRule
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe [Text])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AllowedHeaders"
                            Parser (Maybe [Text]) -> [Text] -> Parser [Text]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable CorsRule

instance Prelude.NFData CorsRule

instance Core.ToJSON CorsRule where
  toJSON :: CorsRule -> Value
toJSON CorsRule' {[Text]
Maybe Natural
Maybe [Text]
Maybe (NonEmpty MethodName)
NonEmpty Text
allowedHeaders :: [Text]
allowedOrigins :: NonEmpty Text
exposeHeaders :: Maybe [Text]
maxAgeSeconds :: Maybe Natural
allowedMethods :: Maybe (NonEmpty MethodName)
$sel:allowedHeaders:CorsRule' :: CorsRule -> [Text]
$sel:allowedOrigins:CorsRule' :: CorsRule -> NonEmpty Text
$sel:exposeHeaders:CorsRule' :: CorsRule -> Maybe [Text]
$sel:maxAgeSeconds:CorsRule' :: CorsRule -> Maybe Natural
$sel:allowedMethods:CorsRule' :: CorsRule -> Maybe (NonEmpty MethodName)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AllowedMethods" Text -> NonEmpty MethodName -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NonEmpty MethodName -> Pair)
-> Maybe (NonEmpty MethodName) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty MethodName)
allowedMethods,
            (Text
"MaxAgeSeconds" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxAgeSeconds,
            (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,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"AllowedOrigins" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Text
allowedOrigins),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"AllowedHeaders" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
allowedHeaders)
          ]
      )