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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(LambdaOutput -> LambdaOutput -> Bool)
-> (LambdaOutput -> LambdaOutput -> Bool) -> Eq LambdaOutput
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]
(Int -> ReadS LambdaOutput)
-> ReadS [LambdaOutput]
-> ReadPrec LambdaOutput
-> ReadPrec [LambdaOutput]
-> Read 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
(Int -> LambdaOutput -> ShowS)
-> (LambdaOutput -> String)
-> ([LambdaOutput] -> ShowS)
-> Show LambdaOutput
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. LambdaOutput -> Rep LambdaOutput x)
-> (forall x. Rep LambdaOutput x -> LambdaOutput)
-> Generic LambdaOutput
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' :: Text -> Text -> LambdaOutput
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 :: (Text -> f Text) -> LambdaOutput -> f LambdaOutput
lambdaOutput_resourceARN = (LambdaOutput -> Text)
-> (LambdaOutput -> Text -> LambdaOutput)
-> Lens LambdaOutput LambdaOutput Text Text
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 :: (Text -> f Text) -> LambdaOutput -> f LambdaOutput
lambdaOutput_roleARN = (LambdaOutput -> Text)
-> (LambdaOutput -> Text -> LambdaOutput)
-> Lens LambdaOutput LambdaOutput Text Text
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

instance Prelude.NFData LambdaOutput

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ResourceARN" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
resourceARN),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"RoleARN" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
roleARN)
          ]
      )