{-# 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.FunctionEventInvokeConfig
-- 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.FunctionEventInvokeConfig 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.DestinationConfig
import qualified Amazonka.Prelude as Prelude

-- | /See:/ 'newFunctionEventInvokeConfig' smart constructor.
data FunctionEventInvokeConfig = FunctionEventInvokeConfig'
  { -- | A destination for events after they have been sent to a function for
    -- processing.
    --
    -- __Destinations__
    --
    -- -   __Function__ - The Amazon Resource Name (ARN) of a Lambda function.
    --
    -- -   __Queue__ - The ARN of an SQS queue.
    --
    -- -   __Topic__ - The ARN of an SNS topic.
    --
    -- -   __Event Bus__ - The ARN of an Amazon EventBridge event bus.
    FunctionEventInvokeConfig -> Maybe DestinationConfig
destinationConfig :: Prelude.Maybe DestinationConfig,
    -- | The Amazon Resource Name (ARN) of the function.
    FunctionEventInvokeConfig -> Maybe Text
functionArn :: Prelude.Maybe Prelude.Text,
    -- | The date and time that the configuration was last updated.
    FunctionEventInvokeConfig -> Maybe POSIX
lastModified :: Prelude.Maybe Data.POSIX,
    -- | The maximum age of a request that Lambda sends to a function for
    -- processing.
    FunctionEventInvokeConfig -> Maybe Natural
maximumEventAgeInSeconds :: Prelude.Maybe Prelude.Natural,
    -- | The maximum number of times to retry when the function returns an error.
    FunctionEventInvokeConfig -> Maybe Natural
maximumRetryAttempts :: Prelude.Maybe Prelude.Natural
  }
  deriving (FunctionEventInvokeConfig -> FunctionEventInvokeConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FunctionEventInvokeConfig -> FunctionEventInvokeConfig -> Bool
$c/= :: FunctionEventInvokeConfig -> FunctionEventInvokeConfig -> Bool
== :: FunctionEventInvokeConfig -> FunctionEventInvokeConfig -> Bool
$c== :: FunctionEventInvokeConfig -> FunctionEventInvokeConfig -> Bool
Prelude.Eq, ReadPrec [FunctionEventInvokeConfig]
ReadPrec FunctionEventInvokeConfig
Int -> ReadS FunctionEventInvokeConfig
ReadS [FunctionEventInvokeConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FunctionEventInvokeConfig]
$creadListPrec :: ReadPrec [FunctionEventInvokeConfig]
readPrec :: ReadPrec FunctionEventInvokeConfig
$creadPrec :: ReadPrec FunctionEventInvokeConfig
readList :: ReadS [FunctionEventInvokeConfig]
$creadList :: ReadS [FunctionEventInvokeConfig]
readsPrec :: Int -> ReadS FunctionEventInvokeConfig
$creadsPrec :: Int -> ReadS FunctionEventInvokeConfig
Prelude.Read, Int -> FunctionEventInvokeConfig -> ShowS
[FunctionEventInvokeConfig] -> ShowS
FunctionEventInvokeConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FunctionEventInvokeConfig] -> ShowS
$cshowList :: [FunctionEventInvokeConfig] -> ShowS
show :: FunctionEventInvokeConfig -> String
$cshow :: FunctionEventInvokeConfig -> String
showsPrec :: Int -> FunctionEventInvokeConfig -> ShowS
$cshowsPrec :: Int -> FunctionEventInvokeConfig -> ShowS
Prelude.Show, forall x.
Rep FunctionEventInvokeConfig x -> FunctionEventInvokeConfig
forall x.
FunctionEventInvokeConfig -> Rep FunctionEventInvokeConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep FunctionEventInvokeConfig x -> FunctionEventInvokeConfig
$cfrom :: forall x.
FunctionEventInvokeConfig -> Rep FunctionEventInvokeConfig x
Prelude.Generic)

-- |
-- Create a value of 'FunctionEventInvokeConfig' 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:
--
-- 'destinationConfig', 'functionEventInvokeConfig_destinationConfig' - A destination for events after they have been sent to a function for
-- processing.
--
-- __Destinations__
--
-- -   __Function__ - The Amazon Resource Name (ARN) of a Lambda function.
--
-- -   __Queue__ - The ARN of an SQS queue.
--
-- -   __Topic__ - The ARN of an SNS topic.
--
-- -   __Event Bus__ - The ARN of an Amazon EventBridge event bus.
--
-- 'functionArn', 'functionEventInvokeConfig_functionArn' - The Amazon Resource Name (ARN) of the function.
--
-- 'lastModified', 'functionEventInvokeConfig_lastModified' - The date and time that the configuration was last updated.
--
-- 'maximumEventAgeInSeconds', 'functionEventInvokeConfig_maximumEventAgeInSeconds' - The maximum age of a request that Lambda sends to a function for
-- processing.
--
-- 'maximumRetryAttempts', 'functionEventInvokeConfig_maximumRetryAttempts' - The maximum number of times to retry when the function returns an error.
newFunctionEventInvokeConfig ::
  FunctionEventInvokeConfig
newFunctionEventInvokeConfig :: FunctionEventInvokeConfig
newFunctionEventInvokeConfig =
  FunctionEventInvokeConfig'
    { $sel:destinationConfig:FunctionEventInvokeConfig' :: Maybe DestinationConfig
destinationConfig =
        forall a. Maybe a
Prelude.Nothing,
      $sel:functionArn:FunctionEventInvokeConfig' :: Maybe Text
functionArn = forall a. Maybe a
Prelude.Nothing,
      $sel:lastModified:FunctionEventInvokeConfig' :: Maybe POSIX
lastModified = forall a. Maybe a
Prelude.Nothing,
      $sel:maximumEventAgeInSeconds:FunctionEventInvokeConfig' :: Maybe Natural
maximumEventAgeInSeconds = forall a. Maybe a
Prelude.Nothing,
      $sel:maximumRetryAttempts:FunctionEventInvokeConfig' :: Maybe Natural
maximumRetryAttempts = forall a. Maybe a
Prelude.Nothing
    }

-- | A destination for events after they have been sent to a function for
-- processing.
--
-- __Destinations__
--
-- -   __Function__ - The Amazon Resource Name (ARN) of a Lambda function.
--
-- -   __Queue__ - The ARN of an SQS queue.
--
-- -   __Topic__ - The ARN of an SNS topic.
--
-- -   __Event Bus__ - The ARN of an Amazon EventBridge event bus.
functionEventInvokeConfig_destinationConfig :: Lens.Lens' FunctionEventInvokeConfig (Prelude.Maybe DestinationConfig)
functionEventInvokeConfig_destinationConfig :: Lens' FunctionEventInvokeConfig (Maybe DestinationConfig)
functionEventInvokeConfig_destinationConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FunctionEventInvokeConfig' {Maybe DestinationConfig
destinationConfig :: Maybe DestinationConfig
$sel:destinationConfig:FunctionEventInvokeConfig' :: FunctionEventInvokeConfig -> Maybe DestinationConfig
destinationConfig} -> Maybe DestinationConfig
destinationConfig) (\s :: FunctionEventInvokeConfig
s@FunctionEventInvokeConfig' {} Maybe DestinationConfig
a -> FunctionEventInvokeConfig
s {$sel:destinationConfig:FunctionEventInvokeConfig' :: Maybe DestinationConfig
destinationConfig = Maybe DestinationConfig
a} :: FunctionEventInvokeConfig)

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

-- | The date and time that the configuration was last updated.
functionEventInvokeConfig_lastModified :: Lens.Lens' FunctionEventInvokeConfig (Prelude.Maybe Prelude.UTCTime)
functionEventInvokeConfig_lastModified :: Lens' FunctionEventInvokeConfig (Maybe UTCTime)
functionEventInvokeConfig_lastModified = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FunctionEventInvokeConfig' {Maybe POSIX
lastModified :: Maybe POSIX
$sel:lastModified:FunctionEventInvokeConfig' :: FunctionEventInvokeConfig -> Maybe POSIX
lastModified} -> Maybe POSIX
lastModified) (\s :: FunctionEventInvokeConfig
s@FunctionEventInvokeConfig' {} Maybe POSIX
a -> FunctionEventInvokeConfig
s {$sel:lastModified:FunctionEventInvokeConfig' :: Maybe POSIX
lastModified = Maybe POSIX
a} :: FunctionEventInvokeConfig) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The maximum age of a request that Lambda sends to a function for
-- processing.
functionEventInvokeConfig_maximumEventAgeInSeconds :: Lens.Lens' FunctionEventInvokeConfig (Prelude.Maybe Prelude.Natural)
functionEventInvokeConfig_maximumEventAgeInSeconds :: Lens' FunctionEventInvokeConfig (Maybe Natural)
functionEventInvokeConfig_maximumEventAgeInSeconds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FunctionEventInvokeConfig' {Maybe Natural
maximumEventAgeInSeconds :: Maybe Natural
$sel:maximumEventAgeInSeconds:FunctionEventInvokeConfig' :: FunctionEventInvokeConfig -> Maybe Natural
maximumEventAgeInSeconds} -> Maybe Natural
maximumEventAgeInSeconds) (\s :: FunctionEventInvokeConfig
s@FunctionEventInvokeConfig' {} Maybe Natural
a -> FunctionEventInvokeConfig
s {$sel:maximumEventAgeInSeconds:FunctionEventInvokeConfig' :: Maybe Natural
maximumEventAgeInSeconds = Maybe Natural
a} :: FunctionEventInvokeConfig)

-- | The maximum number of times to retry when the function returns an error.
functionEventInvokeConfig_maximumRetryAttempts :: Lens.Lens' FunctionEventInvokeConfig (Prelude.Maybe Prelude.Natural)
functionEventInvokeConfig_maximumRetryAttempts :: Lens' FunctionEventInvokeConfig (Maybe Natural)
functionEventInvokeConfig_maximumRetryAttempts = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FunctionEventInvokeConfig' {Maybe Natural
maximumRetryAttempts :: Maybe Natural
$sel:maximumRetryAttempts:FunctionEventInvokeConfig' :: FunctionEventInvokeConfig -> Maybe Natural
maximumRetryAttempts} -> Maybe Natural
maximumRetryAttempts) (\s :: FunctionEventInvokeConfig
s@FunctionEventInvokeConfig' {} Maybe Natural
a -> FunctionEventInvokeConfig
s {$sel:maximumRetryAttempts:FunctionEventInvokeConfig' :: Maybe Natural
maximumRetryAttempts = Maybe Natural
a} :: FunctionEventInvokeConfig)

instance Data.FromJSON FunctionEventInvokeConfig where
  parseJSON :: Value -> Parser FunctionEventInvokeConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FunctionEventInvokeConfig"
      ( \Object
x ->
          Maybe DestinationConfig
-> Maybe Text
-> Maybe POSIX
-> Maybe Natural
-> Maybe Natural
-> FunctionEventInvokeConfig
FunctionEventInvokeConfig'
            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
"DestinationConfig")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe 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 (Maybe a)
Data..:? Key
"LastModified")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"MaximumEventAgeInSeconds")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"MaximumRetryAttempts")
      )

instance Prelude.Hashable FunctionEventInvokeConfig where
  hashWithSalt :: Int -> FunctionEventInvokeConfig -> Int
hashWithSalt Int
_salt FunctionEventInvokeConfig' {Maybe Natural
Maybe Text
Maybe POSIX
Maybe DestinationConfig
maximumRetryAttempts :: Maybe Natural
maximumEventAgeInSeconds :: Maybe Natural
lastModified :: Maybe POSIX
functionArn :: Maybe Text
destinationConfig :: Maybe DestinationConfig
$sel:maximumRetryAttempts:FunctionEventInvokeConfig' :: FunctionEventInvokeConfig -> Maybe Natural
$sel:maximumEventAgeInSeconds:FunctionEventInvokeConfig' :: FunctionEventInvokeConfig -> Maybe Natural
$sel:lastModified:FunctionEventInvokeConfig' :: FunctionEventInvokeConfig -> Maybe POSIX
$sel:functionArn:FunctionEventInvokeConfig' :: FunctionEventInvokeConfig -> Maybe Text
$sel:destinationConfig:FunctionEventInvokeConfig' :: FunctionEventInvokeConfig -> Maybe DestinationConfig
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DestinationConfig
destinationConfig
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
functionArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
lastModified
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maximumEventAgeInSeconds
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maximumRetryAttempts

instance Prelude.NFData FunctionEventInvokeConfig where
  rnf :: FunctionEventInvokeConfig -> ()
rnf FunctionEventInvokeConfig' {Maybe Natural
Maybe Text
Maybe POSIX
Maybe DestinationConfig
maximumRetryAttempts :: Maybe Natural
maximumEventAgeInSeconds :: Maybe Natural
lastModified :: Maybe POSIX
functionArn :: Maybe Text
destinationConfig :: Maybe DestinationConfig
$sel:maximumRetryAttempts:FunctionEventInvokeConfig' :: FunctionEventInvokeConfig -> Maybe Natural
$sel:maximumEventAgeInSeconds:FunctionEventInvokeConfig' :: FunctionEventInvokeConfig -> Maybe Natural
$sel:lastModified:FunctionEventInvokeConfig' :: FunctionEventInvokeConfig -> Maybe POSIX
$sel:functionArn:FunctionEventInvokeConfig' :: FunctionEventInvokeConfig -> Maybe Text
$sel:destinationConfig:FunctionEventInvokeConfig' :: FunctionEventInvokeConfig -> Maybe DestinationConfig
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe DestinationConfig
destinationConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
functionArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
lastModified
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maximumEventAgeInSeconds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maximumRetryAttempts