{-# 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.KinesisAnalytics.Types.LambdaOutput
-- 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.KinesisAnalytics.Types.LambdaOutput where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | When configuring application output, identifies an AWS Lambda function
-- as the destination. You provide the function Amazon Resource Name (ARN)
-- and also an IAM role ARN that Amazon Kinesis Analytics can use to write
-- to the function on your behalf.
--
-- /See:/ 'newLambdaOutput' smart constructor.
data LambdaOutput = LambdaOutput'
  { -- | Amazon Resource Name (ARN) of the destination Lambda function to write
    -- to.
    --
    -- To specify an earlier version of the Lambda function than the latest,
    -- include the Lambda function version in the Lambda function ARN. For more
    -- information about Lambda ARNs, see
    -- </general/latest/gr/aws-arns-and-namespaces.html#arn-syntax-lambda Example ARNs: AWS Lambda>
    LambdaOutput -> Text
resourceARN :: Prelude.Text,
    -- | ARN of the IAM role that Amazon Kinesis Analytics can assume to write to
    -- the destination function on your behalf. You need to grant the necessary
    -- permissions to this role.
    LambdaOutput -> Text
roleARN :: Prelude.Text
  }
  deriving (LambdaOutput -> LambdaOutput -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LambdaOutput -> LambdaOutput -> Bool
$c/= :: LambdaOutput -> LambdaOutput -> Bool
== :: LambdaOutput -> LambdaOutput -> Bool
$c== :: LambdaOutput -> LambdaOutput -> Bool
Prelude.Eq, ReadPrec [LambdaOutput]
ReadPrec LambdaOutput
Int -> ReadS LambdaOutput
ReadS [LambdaOutput]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LambdaOutput]
$creadListPrec :: ReadPrec [LambdaOutput]
readPrec :: ReadPrec LambdaOutput
$creadPrec :: ReadPrec LambdaOutput
readList :: ReadS [LambdaOutput]
$creadList :: ReadS [LambdaOutput]
readsPrec :: Int -> ReadS LambdaOutput
$creadsPrec :: Int -> ReadS LambdaOutput
Prelude.Read, Int -> LambdaOutput -> ShowS
[LambdaOutput] -> ShowS
LambdaOutput -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LambdaOutput] -> ShowS
$cshowList :: [LambdaOutput] -> ShowS
show :: LambdaOutput -> String
$cshow :: LambdaOutput -> String
showsPrec :: Int -> LambdaOutput -> ShowS
$cshowsPrec :: Int -> LambdaOutput -> ShowS
Prelude.Show, forall x. Rep LambdaOutput x -> LambdaOutput
forall x. LambdaOutput -> Rep LambdaOutput x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LambdaOutput x -> LambdaOutput
$cfrom :: forall x. LambdaOutput -> Rep LambdaOutput x
Prelude.Generic)

-- |
-- Create a value of 'LambdaOutput' 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:
--
-- 'resourceARN', 'lambdaOutput_resourceARN' - Amazon Resource Name (ARN) of the destination Lambda function to write
-- to.
--
-- To specify an earlier version of the Lambda function than the latest,
-- include the Lambda function version in the Lambda function ARN. For more
-- information about Lambda ARNs, see
-- </general/latest/gr/aws-arns-and-namespaces.html#arn-syntax-lambda Example ARNs: AWS Lambda>
--
-- 'roleARN', 'lambdaOutput_roleARN' - ARN of the IAM role that Amazon Kinesis Analytics can assume to write to
-- the destination function on your behalf. You need to grant the necessary
-- permissions to this role.
newLambdaOutput ::
  -- | 'resourceARN'
  Prelude.Text ->
  -- | 'roleARN'
  Prelude.Text ->
  LambdaOutput
newLambdaOutput :: Text -> Text -> LambdaOutput
newLambdaOutput Text
pResourceARN_ Text
pRoleARN_ =
  LambdaOutput'
    { $sel:resourceARN:LambdaOutput' :: Text
resourceARN = Text
pResourceARN_,
      $sel:roleARN:LambdaOutput' :: Text
roleARN = Text
pRoleARN_
    }

-- | Amazon Resource Name (ARN) of the destination Lambda function to write
-- to.
--
-- To specify an earlier version of the Lambda function than the latest,
-- include the Lambda function version in the Lambda function ARN. For more
-- information about Lambda ARNs, see
-- </general/latest/gr/aws-arns-and-namespaces.html#arn-syntax-lambda Example ARNs: AWS Lambda>
lambdaOutput_resourceARN :: Lens.Lens' LambdaOutput Prelude.Text
lambdaOutput_resourceARN :: Lens' LambdaOutput Text
lambdaOutput_resourceARN = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaOutput' {Text
resourceARN :: Text
$sel:resourceARN:LambdaOutput' :: LambdaOutput -> Text
resourceARN} -> Text
resourceARN) (\s :: LambdaOutput
s@LambdaOutput' {} Text
a -> LambdaOutput
s {$sel:resourceARN:LambdaOutput' :: Text
resourceARN = Text
a} :: LambdaOutput)

-- | ARN of the IAM role that Amazon Kinesis Analytics can assume to write to
-- the destination function on your behalf. You need to grant the necessary
-- permissions to this role.
lambdaOutput_roleARN :: Lens.Lens' LambdaOutput Prelude.Text
lambdaOutput_roleARN :: Lens' LambdaOutput Text
lambdaOutput_roleARN = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaOutput' {Text
roleARN :: Text
$sel:roleARN:LambdaOutput' :: LambdaOutput -> Text
roleARN} -> Text
roleARN) (\s :: LambdaOutput
s@LambdaOutput' {} Text
a -> LambdaOutput
s {$sel:roleARN:LambdaOutput' :: Text
roleARN = Text
a} :: LambdaOutput)

instance Prelude.Hashable LambdaOutput where
  hashWithSalt :: Int -> LambdaOutput -> Int
hashWithSalt Int
_salt LambdaOutput' {Text
roleARN :: Text
resourceARN :: Text
$sel:roleARN:LambdaOutput' :: LambdaOutput -> Text
$sel:resourceARN:LambdaOutput' :: LambdaOutput -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceARN
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
roleARN

instance Prelude.NFData LambdaOutput where
  rnf :: LambdaOutput -> ()
rnf LambdaOutput' {Text
roleARN :: Text
resourceARN :: Text
$sel:roleARN:LambdaOutput' :: LambdaOutput -> Text
$sel:resourceARN:LambdaOutput' :: LambdaOutput -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
resourceARN
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
roleARN

instance Data.ToJSON LambdaOutput where
  toJSON :: LambdaOutput -> Value
toJSON LambdaOutput' {Text
roleARN :: Text
resourceARN :: Text
$sel:roleARN:LambdaOutput' :: LambdaOutput -> Text
$sel:resourceARN:LambdaOutput' :: LambdaOutput -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"ResourceARN" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
resourceARN),
            forall a. a -> Maybe a
Prelude.Just (Key
"RoleARN" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
roleARN)
          ]
      )