{-# 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.Pipes.Types.PipeTargetLambdaFunctionParameters
-- 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.Pipes.Types.PipeTargetLambdaFunctionParameters where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Pipes.Types.PipeTargetInvocationType
import qualified Amazonka.Prelude as Prelude

-- | The parameters for using a Lambda function as a target.
--
-- /See:/ 'newPipeTargetLambdaFunctionParameters' smart constructor.
data PipeTargetLambdaFunctionParameters = PipeTargetLambdaFunctionParameters'
  { -- | Choose from the following options.
    --
    -- -   @RequestResponse@ (default) - Invoke the function synchronously.
    --     Keep the connection open until the function returns a response or
    --     times out. The API response includes the function response and
    --     additional data.
    --
    -- -   @Event@ - Invoke the function asynchronously. Send events that fail
    --     multiple times to the function\'s dead-letter queue (if it\'s
    --     configured). The API response only includes a status code.
    --
    -- -   @DryRun@ - Validate parameter values and verify that the user or
    --     role has permission to invoke the function.
    PipeTargetLambdaFunctionParameters
-> Maybe PipeTargetInvocationType
invocationType :: Prelude.Maybe PipeTargetInvocationType
  }
  deriving (PipeTargetLambdaFunctionParameters
-> PipeTargetLambdaFunctionParameters -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PipeTargetLambdaFunctionParameters
-> PipeTargetLambdaFunctionParameters -> Bool
$c/= :: PipeTargetLambdaFunctionParameters
-> PipeTargetLambdaFunctionParameters -> Bool
== :: PipeTargetLambdaFunctionParameters
-> PipeTargetLambdaFunctionParameters -> Bool
$c== :: PipeTargetLambdaFunctionParameters
-> PipeTargetLambdaFunctionParameters -> Bool
Prelude.Eq, ReadPrec [PipeTargetLambdaFunctionParameters]
ReadPrec PipeTargetLambdaFunctionParameters
Int -> ReadS PipeTargetLambdaFunctionParameters
ReadS [PipeTargetLambdaFunctionParameters]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PipeTargetLambdaFunctionParameters]
$creadListPrec :: ReadPrec [PipeTargetLambdaFunctionParameters]
readPrec :: ReadPrec PipeTargetLambdaFunctionParameters
$creadPrec :: ReadPrec PipeTargetLambdaFunctionParameters
readList :: ReadS [PipeTargetLambdaFunctionParameters]
$creadList :: ReadS [PipeTargetLambdaFunctionParameters]
readsPrec :: Int -> ReadS PipeTargetLambdaFunctionParameters
$creadsPrec :: Int -> ReadS PipeTargetLambdaFunctionParameters
Prelude.Read, Int -> PipeTargetLambdaFunctionParameters -> ShowS
[PipeTargetLambdaFunctionParameters] -> ShowS
PipeTargetLambdaFunctionParameters -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PipeTargetLambdaFunctionParameters] -> ShowS
$cshowList :: [PipeTargetLambdaFunctionParameters] -> ShowS
show :: PipeTargetLambdaFunctionParameters -> String
$cshow :: PipeTargetLambdaFunctionParameters -> String
showsPrec :: Int -> PipeTargetLambdaFunctionParameters -> ShowS
$cshowsPrec :: Int -> PipeTargetLambdaFunctionParameters -> ShowS
Prelude.Show, forall x.
Rep PipeTargetLambdaFunctionParameters x
-> PipeTargetLambdaFunctionParameters
forall x.
PipeTargetLambdaFunctionParameters
-> Rep PipeTargetLambdaFunctionParameters x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PipeTargetLambdaFunctionParameters x
-> PipeTargetLambdaFunctionParameters
$cfrom :: forall x.
PipeTargetLambdaFunctionParameters
-> Rep PipeTargetLambdaFunctionParameters x
Prelude.Generic)

-- |
-- Create a value of 'PipeTargetLambdaFunctionParameters' 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:
--
-- 'invocationType', 'pipeTargetLambdaFunctionParameters_invocationType' - Choose from the following options.
--
-- -   @RequestResponse@ (default) - Invoke the function synchronously.
--     Keep the connection open until the function returns a response or
--     times out. The API response includes the function response and
--     additional data.
--
-- -   @Event@ - Invoke the function asynchronously. Send events that fail
--     multiple times to the function\'s dead-letter queue (if it\'s
--     configured). The API response only includes a status code.
--
-- -   @DryRun@ - Validate parameter values and verify that the user or
--     role has permission to invoke the function.
newPipeTargetLambdaFunctionParameters ::
  PipeTargetLambdaFunctionParameters
newPipeTargetLambdaFunctionParameters :: PipeTargetLambdaFunctionParameters
newPipeTargetLambdaFunctionParameters =
  PipeTargetLambdaFunctionParameters'
    { $sel:invocationType:PipeTargetLambdaFunctionParameters' :: Maybe PipeTargetInvocationType
invocationType =
        forall a. Maybe a
Prelude.Nothing
    }

-- | Choose from the following options.
--
-- -   @RequestResponse@ (default) - Invoke the function synchronously.
--     Keep the connection open until the function returns a response or
--     times out. The API response includes the function response and
--     additional data.
--
-- -   @Event@ - Invoke the function asynchronously. Send events that fail
--     multiple times to the function\'s dead-letter queue (if it\'s
--     configured). The API response only includes a status code.
--
-- -   @DryRun@ - Validate parameter values and verify that the user or
--     role has permission to invoke the function.
pipeTargetLambdaFunctionParameters_invocationType :: Lens.Lens' PipeTargetLambdaFunctionParameters (Prelude.Maybe PipeTargetInvocationType)
pipeTargetLambdaFunctionParameters_invocationType :: Lens'
  PipeTargetLambdaFunctionParameters (Maybe PipeTargetInvocationType)
pipeTargetLambdaFunctionParameters_invocationType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PipeTargetLambdaFunctionParameters' {Maybe PipeTargetInvocationType
invocationType :: Maybe PipeTargetInvocationType
$sel:invocationType:PipeTargetLambdaFunctionParameters' :: PipeTargetLambdaFunctionParameters
-> Maybe PipeTargetInvocationType
invocationType} -> Maybe PipeTargetInvocationType
invocationType) (\s :: PipeTargetLambdaFunctionParameters
s@PipeTargetLambdaFunctionParameters' {} Maybe PipeTargetInvocationType
a -> PipeTargetLambdaFunctionParameters
s {$sel:invocationType:PipeTargetLambdaFunctionParameters' :: Maybe PipeTargetInvocationType
invocationType = Maybe PipeTargetInvocationType
a} :: PipeTargetLambdaFunctionParameters)

instance
  Data.FromJSON
    PipeTargetLambdaFunctionParameters
  where
  parseJSON :: Value -> Parser PipeTargetLambdaFunctionParameters
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PipeTargetLambdaFunctionParameters"
      ( \Object
x ->
          Maybe PipeTargetInvocationType
-> PipeTargetLambdaFunctionParameters
PipeTargetLambdaFunctionParameters'
            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
"InvocationType")
      )

instance
  Prelude.Hashable
    PipeTargetLambdaFunctionParameters
  where
  hashWithSalt :: Int -> PipeTargetLambdaFunctionParameters -> Int
hashWithSalt
    Int
_salt
    PipeTargetLambdaFunctionParameters' {Maybe PipeTargetInvocationType
invocationType :: Maybe PipeTargetInvocationType
$sel:invocationType:PipeTargetLambdaFunctionParameters' :: PipeTargetLambdaFunctionParameters
-> Maybe PipeTargetInvocationType
..} =
      Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe PipeTargetInvocationType
invocationType

instance
  Prelude.NFData
    PipeTargetLambdaFunctionParameters
  where
  rnf :: PipeTargetLambdaFunctionParameters -> ()
rnf PipeTargetLambdaFunctionParameters' {Maybe PipeTargetInvocationType
invocationType :: Maybe PipeTargetInvocationType
$sel:invocationType:PipeTargetLambdaFunctionParameters' :: PipeTargetLambdaFunctionParameters
-> Maybe PipeTargetInvocationType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe PipeTargetInvocationType
invocationType

instance
  Data.ToJSON
    PipeTargetLambdaFunctionParameters
  where
  toJSON :: PipeTargetLambdaFunctionParameters -> Value
toJSON PipeTargetLambdaFunctionParameters' {Maybe PipeTargetInvocationType
invocationType :: Maybe PipeTargetInvocationType
$sel:invocationType:PipeTargetLambdaFunctionParameters' :: PipeTargetLambdaFunctionParameters
-> Maybe PipeTargetInvocationType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"InvocationType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe PipeTargetInvocationType
invocationType
          ]
      )