{-# 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.Lambda.Types.FunctionUrlConfig
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Lambda.Types.FunctionUrlConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Lambda.Types.Cors
import Amazonka.Lambda.Types.FunctionUrlAuthType
import qualified Amazonka.Prelude as Prelude

-- | Details about a Lambda function URL.
--
-- /See:/ 'newFunctionUrlConfig' smart constructor.
data FunctionUrlConfig = FunctionUrlConfig'
  { -- | The
    -- <https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS cross-origin resource sharing (CORS)>
    -- settings for your function URL.
    FunctionUrlConfig -> Maybe Cors
cors :: Prelude.Maybe Cors,
    -- | The HTTP URL endpoint for your function.
    FunctionUrlConfig -> Text
functionUrl :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) of your function.
    FunctionUrlConfig -> Text
functionArn :: Prelude.Text,
    -- | When the function URL was created, in
    -- <https://www.w3.org/TR/NOTE-datetime ISO-8601 format>
    -- (YYYY-MM-DDThh:mm:ss.sTZD).
    FunctionUrlConfig -> Text
creationTime :: Prelude.Text,
    -- | When the function URL configuration was last updated, in
    -- <https://www.w3.org/TR/NOTE-datetime ISO-8601 format>
    -- (YYYY-MM-DDThh:mm:ss.sTZD).
    FunctionUrlConfig -> Text
lastModifiedTime :: Prelude.Text,
    -- | The type of authentication that your function URL uses. Set to @AWS_IAM@
    -- if you want to restrict access to authenticated IAM users only. Set to
    -- @NONE@ if you want to bypass IAM authentication to create a public
    -- endpoint. For more information, see
    -- <https://docs.aws.amazon.com/lambda/latest/dg/urls-auth.html Security and auth model for Lambda function URLs>.
    FunctionUrlConfig -> FunctionUrlAuthType
authType :: FunctionUrlAuthType
  }
  deriving (FunctionUrlConfig -> FunctionUrlConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FunctionUrlConfig -> FunctionUrlConfig -> Bool
$c/= :: FunctionUrlConfig -> FunctionUrlConfig -> Bool
== :: FunctionUrlConfig -> FunctionUrlConfig -> Bool
$c== :: FunctionUrlConfig -> FunctionUrlConfig -> Bool
Prelude.Eq, ReadPrec [FunctionUrlConfig]
ReadPrec FunctionUrlConfig
Int -> ReadS FunctionUrlConfig
ReadS [FunctionUrlConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FunctionUrlConfig]
$creadListPrec :: ReadPrec [FunctionUrlConfig]
readPrec :: ReadPrec FunctionUrlConfig
$creadPrec :: ReadPrec FunctionUrlConfig
readList :: ReadS [FunctionUrlConfig]
$creadList :: ReadS [FunctionUrlConfig]
readsPrec :: Int -> ReadS FunctionUrlConfig
$creadsPrec :: Int -> ReadS FunctionUrlConfig
Prelude.Read, Int -> FunctionUrlConfig -> ShowS
[FunctionUrlConfig] -> ShowS
FunctionUrlConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FunctionUrlConfig] -> ShowS
$cshowList :: [FunctionUrlConfig] -> ShowS
show :: FunctionUrlConfig -> String
$cshow :: FunctionUrlConfig -> String
showsPrec :: Int -> FunctionUrlConfig -> ShowS
$cshowsPrec :: Int -> FunctionUrlConfig -> ShowS
Prelude.Show, forall x. Rep FunctionUrlConfig x -> FunctionUrlConfig
forall x. FunctionUrlConfig -> Rep FunctionUrlConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FunctionUrlConfig x -> FunctionUrlConfig
$cfrom :: forall x. FunctionUrlConfig -> Rep FunctionUrlConfig x
Prelude.Generic)

-- |
-- Create a value of 'FunctionUrlConfig' 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:
--
-- 'cors', 'functionUrlConfig_cors' - The
-- <https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS cross-origin resource sharing (CORS)>
-- settings for your function URL.
--
-- 'functionUrl', 'functionUrlConfig_functionUrl' - The HTTP URL endpoint for your function.
--
-- 'functionArn', 'functionUrlConfig_functionArn' - The Amazon Resource Name (ARN) of your function.
--
-- 'creationTime', 'functionUrlConfig_creationTime' - When the function URL was created, in
-- <https://www.w3.org/TR/NOTE-datetime ISO-8601 format>
-- (YYYY-MM-DDThh:mm:ss.sTZD).
--
-- 'lastModifiedTime', 'functionUrlConfig_lastModifiedTime' - When the function URL configuration was last updated, in
-- <https://www.w3.org/TR/NOTE-datetime ISO-8601 format>
-- (YYYY-MM-DDThh:mm:ss.sTZD).
--
-- 'authType', 'functionUrlConfig_authType' - The type of authentication that your function URL uses. Set to @AWS_IAM@
-- if you want to restrict access to authenticated IAM users only. Set to
-- @NONE@ if you want to bypass IAM authentication to create a public
-- endpoint. For more information, see
-- <https://docs.aws.amazon.com/lambda/latest/dg/urls-auth.html Security and auth model for Lambda function URLs>.
newFunctionUrlConfig ::
  -- | 'functionUrl'
  Prelude.Text ->
  -- | 'functionArn'
  Prelude.Text ->
  -- | 'creationTime'
  Prelude.Text ->
  -- | 'lastModifiedTime'
  Prelude.Text ->
  -- | 'authType'
  FunctionUrlAuthType ->
  FunctionUrlConfig
newFunctionUrlConfig :: Text
-> Text -> Text -> Text -> FunctionUrlAuthType -> FunctionUrlConfig
newFunctionUrlConfig
  Text
pFunctionUrl_
  Text
pFunctionArn_
  Text
pCreationTime_
  Text
pLastModifiedTime_
  FunctionUrlAuthType
pAuthType_ =
    FunctionUrlConfig'
      { $sel:cors:FunctionUrlConfig' :: Maybe Cors
cors = forall a. Maybe a
Prelude.Nothing,
        $sel:functionUrl:FunctionUrlConfig' :: Text
functionUrl = Text
pFunctionUrl_,
        $sel:functionArn:FunctionUrlConfig' :: Text
functionArn = Text
pFunctionArn_,
        $sel:creationTime:FunctionUrlConfig' :: Text
creationTime = Text
pCreationTime_,
        $sel:lastModifiedTime:FunctionUrlConfig' :: Text
lastModifiedTime = Text
pLastModifiedTime_,
        $sel:authType:FunctionUrlConfig' :: FunctionUrlAuthType
authType = FunctionUrlAuthType
pAuthType_
      }

-- | The
-- <https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS cross-origin resource sharing (CORS)>
-- settings for your function URL.
functionUrlConfig_cors :: Lens.Lens' FunctionUrlConfig (Prelude.Maybe Cors)
functionUrlConfig_cors :: Lens' FunctionUrlConfig (Maybe Cors)
functionUrlConfig_cors = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FunctionUrlConfig' {Maybe Cors
cors :: Maybe Cors
$sel:cors:FunctionUrlConfig' :: FunctionUrlConfig -> Maybe Cors
cors} -> Maybe Cors
cors) (\s :: FunctionUrlConfig
s@FunctionUrlConfig' {} Maybe Cors
a -> FunctionUrlConfig
s {$sel:cors:FunctionUrlConfig' :: Maybe Cors
cors = Maybe Cors
a} :: FunctionUrlConfig)

-- | The HTTP URL endpoint for your function.
functionUrlConfig_functionUrl :: Lens.Lens' FunctionUrlConfig Prelude.Text
functionUrlConfig_functionUrl :: Lens' FunctionUrlConfig Text
functionUrlConfig_functionUrl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FunctionUrlConfig' {Text
functionUrl :: Text
$sel:functionUrl:FunctionUrlConfig' :: FunctionUrlConfig -> Text
functionUrl} -> Text
functionUrl) (\s :: FunctionUrlConfig
s@FunctionUrlConfig' {} Text
a -> FunctionUrlConfig
s {$sel:functionUrl:FunctionUrlConfig' :: Text
functionUrl = Text
a} :: FunctionUrlConfig)

-- | The Amazon Resource Name (ARN) of your function.
functionUrlConfig_functionArn :: Lens.Lens' FunctionUrlConfig Prelude.Text
functionUrlConfig_functionArn :: Lens' FunctionUrlConfig Text
functionUrlConfig_functionArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FunctionUrlConfig' {Text
functionArn :: Text
$sel:functionArn:FunctionUrlConfig' :: FunctionUrlConfig -> Text
functionArn} -> Text
functionArn) (\s :: FunctionUrlConfig
s@FunctionUrlConfig' {} Text
a -> FunctionUrlConfig
s {$sel:functionArn:FunctionUrlConfig' :: Text
functionArn = Text
a} :: FunctionUrlConfig)

-- | When the function URL was created, in
-- <https://www.w3.org/TR/NOTE-datetime ISO-8601 format>
-- (YYYY-MM-DDThh:mm:ss.sTZD).
functionUrlConfig_creationTime :: Lens.Lens' FunctionUrlConfig Prelude.Text
functionUrlConfig_creationTime :: Lens' FunctionUrlConfig Text
functionUrlConfig_creationTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FunctionUrlConfig' {Text
creationTime :: Text
$sel:creationTime:FunctionUrlConfig' :: FunctionUrlConfig -> Text
creationTime} -> Text
creationTime) (\s :: FunctionUrlConfig
s@FunctionUrlConfig' {} Text
a -> FunctionUrlConfig
s {$sel:creationTime:FunctionUrlConfig' :: Text
creationTime = Text
a} :: FunctionUrlConfig)

-- | When the function URL configuration was last updated, in
-- <https://www.w3.org/TR/NOTE-datetime ISO-8601 format>
-- (YYYY-MM-DDThh:mm:ss.sTZD).
functionUrlConfig_lastModifiedTime :: Lens.Lens' FunctionUrlConfig Prelude.Text
functionUrlConfig_lastModifiedTime :: Lens' FunctionUrlConfig Text
functionUrlConfig_lastModifiedTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FunctionUrlConfig' {Text
lastModifiedTime :: Text
$sel:lastModifiedTime:FunctionUrlConfig' :: FunctionUrlConfig -> Text
lastModifiedTime} -> Text
lastModifiedTime) (\s :: FunctionUrlConfig
s@FunctionUrlConfig' {} Text
a -> FunctionUrlConfig
s {$sel:lastModifiedTime:FunctionUrlConfig' :: Text
lastModifiedTime = Text
a} :: FunctionUrlConfig)

-- | The type of authentication that your function URL uses. Set to @AWS_IAM@
-- if you want to restrict access to authenticated IAM users only. Set to
-- @NONE@ if you want to bypass IAM authentication to create a public
-- endpoint. For more information, see
-- <https://docs.aws.amazon.com/lambda/latest/dg/urls-auth.html Security and auth model for Lambda function URLs>.
functionUrlConfig_authType :: Lens.Lens' FunctionUrlConfig FunctionUrlAuthType
functionUrlConfig_authType :: Lens' FunctionUrlConfig FunctionUrlAuthType
functionUrlConfig_authType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FunctionUrlConfig' {FunctionUrlAuthType
authType :: FunctionUrlAuthType
$sel:authType:FunctionUrlConfig' :: FunctionUrlConfig -> FunctionUrlAuthType
authType} -> FunctionUrlAuthType
authType) (\s :: FunctionUrlConfig
s@FunctionUrlConfig' {} FunctionUrlAuthType
a -> FunctionUrlConfig
s {$sel:authType:FunctionUrlConfig' :: FunctionUrlAuthType
authType = FunctionUrlAuthType
a} :: FunctionUrlConfig)

instance Data.FromJSON FunctionUrlConfig where
  parseJSON :: Value -> Parser FunctionUrlConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FunctionUrlConfig"
      ( \Object
x ->
          Maybe Cors
-> Text
-> Text
-> Text
-> Text
-> FunctionUrlAuthType
-> FunctionUrlConfig
FunctionUrlConfig'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Cors")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"FunctionUrl")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"FunctionArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"CreationTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"LastModifiedTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"AuthType")
      )

instance Prelude.Hashable FunctionUrlConfig where
  hashWithSalt :: Int -> FunctionUrlConfig -> Int
hashWithSalt Int
_salt FunctionUrlConfig' {Maybe Cors
Text
FunctionUrlAuthType
authType :: FunctionUrlAuthType
lastModifiedTime :: Text
creationTime :: Text
functionArn :: Text
functionUrl :: Text
cors :: Maybe Cors
$sel:authType:FunctionUrlConfig' :: FunctionUrlConfig -> FunctionUrlAuthType
$sel:lastModifiedTime:FunctionUrlConfig' :: FunctionUrlConfig -> Text
$sel:creationTime:FunctionUrlConfig' :: FunctionUrlConfig -> Text
$sel:functionArn:FunctionUrlConfig' :: FunctionUrlConfig -> Text
$sel:functionUrl:FunctionUrlConfig' :: FunctionUrlConfig -> Text
$sel:cors:FunctionUrlConfig' :: FunctionUrlConfig -> Maybe Cors
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Cors
cors
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
functionUrl
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
functionArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
creationTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
lastModifiedTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` FunctionUrlAuthType
authType

instance Prelude.NFData FunctionUrlConfig where
  rnf :: FunctionUrlConfig -> ()
rnf FunctionUrlConfig' {Maybe Cors
Text
FunctionUrlAuthType
authType :: FunctionUrlAuthType
lastModifiedTime :: Text
creationTime :: Text
functionArn :: Text
functionUrl :: Text
cors :: Maybe Cors
$sel:authType:FunctionUrlConfig' :: FunctionUrlConfig -> FunctionUrlAuthType
$sel:lastModifiedTime:FunctionUrlConfig' :: FunctionUrlConfig -> Text
$sel:creationTime:FunctionUrlConfig' :: FunctionUrlConfig -> Text
$sel:functionArn:FunctionUrlConfig' :: FunctionUrlConfig -> Text
$sel:functionUrl:FunctionUrlConfig' :: FunctionUrlConfig -> Text
$sel:cors:FunctionUrlConfig' :: FunctionUrlConfig -> Maybe Cors
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Cors
cors
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
functionUrl
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
functionArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
creationTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
lastModifiedTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf FunctionUrlAuthType
authType