{-# 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-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.Lambda.Types.FunctionEventInvokeConfig where

import qualified Amazonka.Core as Core
import Amazonka.Lambda.Types.DestinationConfig
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | /See:/ 'newFunctionEventInvokeConfig' smart constructor.
data FunctionEventInvokeConfig = FunctionEventInvokeConfig'
  { -- | The Amazon Resource Name (ARN) of the function.
    FunctionEventInvokeConfig -> Maybe Text
functionArn :: Prelude.Maybe Prelude.Text,
    -- | 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,
    -- | The date and time that the configuration was last updated.
    FunctionEventInvokeConfig -> Maybe POSIX
lastModified :: Prelude.Maybe Core.POSIX,
    -- | 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
  }
  deriving (FunctionEventInvokeConfig -> FunctionEventInvokeConfig -> Bool
(FunctionEventInvokeConfig -> FunctionEventInvokeConfig -> Bool)
-> (FunctionEventInvokeConfig -> FunctionEventInvokeConfig -> Bool)
-> Eq FunctionEventInvokeConfig
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]
(Int -> ReadS FunctionEventInvokeConfig)
-> ReadS [FunctionEventInvokeConfig]
-> ReadPrec FunctionEventInvokeConfig
-> ReadPrec [FunctionEventInvokeConfig]
-> Read 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
(Int -> FunctionEventInvokeConfig -> ShowS)
-> (FunctionEventInvokeConfig -> String)
-> ([FunctionEventInvokeConfig] -> ShowS)
-> Show FunctionEventInvokeConfig
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.
 FunctionEventInvokeConfig -> Rep FunctionEventInvokeConfig x)
-> (forall x.
    Rep FunctionEventInvokeConfig x -> FunctionEventInvokeConfig)
-> Generic FunctionEventInvokeConfig
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:
--
-- 'functionArn', 'functionEventInvokeConfig_functionArn' - The Amazon Resource Name (ARN) of the function.
--
-- '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.
--
-- 'lastModified', 'functionEventInvokeConfig_lastModified' - The date and time that the configuration was last updated.
--
-- '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.
newFunctionEventInvokeConfig ::
  FunctionEventInvokeConfig
newFunctionEventInvokeConfig :: FunctionEventInvokeConfig
newFunctionEventInvokeConfig =
  FunctionEventInvokeConfig' :: Maybe Text
-> Maybe Natural
-> Maybe Natural
-> Maybe POSIX
-> Maybe DestinationConfig
-> FunctionEventInvokeConfig
FunctionEventInvokeConfig'
    { $sel:functionArn:FunctionEventInvokeConfig' :: Maybe Text
functionArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maximumEventAgeInSeconds:FunctionEventInvokeConfig' :: Maybe Natural
maximumEventAgeInSeconds = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:maximumRetryAttempts:FunctionEventInvokeConfig' :: Maybe Natural
maximumRetryAttempts = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:lastModified:FunctionEventInvokeConfig' :: Maybe POSIX
lastModified = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:destinationConfig:FunctionEventInvokeConfig' :: Maybe DestinationConfig
destinationConfig = Maybe DestinationConfig
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the function.
functionEventInvokeConfig_functionArn :: Lens.Lens' FunctionEventInvokeConfig (Prelude.Maybe Prelude.Text)
functionEventInvokeConfig_functionArn :: (Maybe Text -> f (Maybe Text))
-> FunctionEventInvokeConfig -> f FunctionEventInvokeConfig
functionEventInvokeConfig_functionArn = (FunctionEventInvokeConfig -> Maybe Text)
-> (FunctionEventInvokeConfig
    -> Maybe Text -> FunctionEventInvokeConfig)
-> Lens
     FunctionEventInvokeConfig
     FunctionEventInvokeConfig
     (Maybe Text)
     (Maybe Text)
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 maximum age of a request that Lambda sends to a function for
-- processing.
functionEventInvokeConfig_maximumEventAgeInSeconds :: Lens.Lens' FunctionEventInvokeConfig (Prelude.Maybe Prelude.Natural)
functionEventInvokeConfig_maximumEventAgeInSeconds :: (Maybe Natural -> f (Maybe Natural))
-> FunctionEventInvokeConfig -> f FunctionEventInvokeConfig
functionEventInvokeConfig_maximumEventAgeInSeconds = (FunctionEventInvokeConfig -> Maybe Natural)
-> (FunctionEventInvokeConfig
    -> Maybe Natural -> FunctionEventInvokeConfig)
-> Lens
     FunctionEventInvokeConfig
     FunctionEventInvokeConfig
     (Maybe Natural)
     (Maybe Natural)
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 :: (Maybe Natural -> f (Maybe Natural))
-> FunctionEventInvokeConfig -> f FunctionEventInvokeConfig
functionEventInvokeConfig_maximumRetryAttempts = (FunctionEventInvokeConfig -> Maybe Natural)
-> (FunctionEventInvokeConfig
    -> Maybe Natural -> FunctionEventInvokeConfig)
-> Lens
     FunctionEventInvokeConfig
     FunctionEventInvokeConfig
     (Maybe Natural)
     (Maybe Natural)
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)

-- | The date and time that the configuration was last updated.
functionEventInvokeConfig_lastModified :: Lens.Lens' FunctionEventInvokeConfig (Prelude.Maybe Prelude.UTCTime)
functionEventInvokeConfig_lastModified :: (Maybe UTCTime -> f (Maybe UTCTime))
-> FunctionEventInvokeConfig -> f FunctionEventInvokeConfig
functionEventInvokeConfig_lastModified = (FunctionEventInvokeConfig -> Maybe POSIX)
-> (FunctionEventInvokeConfig
    -> Maybe POSIX -> FunctionEventInvokeConfig)
-> Lens
     FunctionEventInvokeConfig
     FunctionEventInvokeConfig
     (Maybe POSIX)
     (Maybe POSIX)
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) ((Maybe POSIX -> f (Maybe POSIX))
 -> FunctionEventInvokeConfig -> f FunctionEventInvokeConfig)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> FunctionEventInvokeConfig
-> f FunctionEventInvokeConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | 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 :: (Maybe DestinationConfig -> f (Maybe DestinationConfig))
-> FunctionEventInvokeConfig -> f FunctionEventInvokeConfig
functionEventInvokeConfig_destinationConfig = (FunctionEventInvokeConfig -> Maybe DestinationConfig)
-> (FunctionEventInvokeConfig
    -> Maybe DestinationConfig -> FunctionEventInvokeConfig)
-> Lens
     FunctionEventInvokeConfig
     FunctionEventInvokeConfig
     (Maybe DestinationConfig)
     (Maybe 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)

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

instance Prelude.Hashable FunctionEventInvokeConfig

instance Prelude.NFData FunctionEventInvokeConfig