{-# 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.IoT.Types.LambdaAction
-- 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.IoT.Types.LambdaAction 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

-- | Describes an action to invoke a Lambda function.
--
-- /See:/ 'newLambdaAction' smart constructor.
data LambdaAction = LambdaAction'
  { -- | The ARN of the Lambda function.
    LambdaAction -> Text
functionArn :: Prelude.Text
  }
  deriving (LambdaAction -> LambdaAction -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LambdaAction -> LambdaAction -> Bool
$c/= :: LambdaAction -> LambdaAction -> Bool
== :: LambdaAction -> LambdaAction -> Bool
$c== :: LambdaAction -> LambdaAction -> Bool
Prelude.Eq, ReadPrec [LambdaAction]
ReadPrec LambdaAction
Int -> ReadS LambdaAction
ReadS [LambdaAction]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LambdaAction]
$creadListPrec :: ReadPrec [LambdaAction]
readPrec :: ReadPrec LambdaAction
$creadPrec :: ReadPrec LambdaAction
readList :: ReadS [LambdaAction]
$creadList :: ReadS [LambdaAction]
readsPrec :: Int -> ReadS LambdaAction
$creadsPrec :: Int -> ReadS LambdaAction
Prelude.Read, Int -> LambdaAction -> ShowS
[LambdaAction] -> ShowS
LambdaAction -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LambdaAction] -> ShowS
$cshowList :: [LambdaAction] -> ShowS
show :: LambdaAction -> String
$cshow :: LambdaAction -> String
showsPrec :: Int -> LambdaAction -> ShowS
$cshowsPrec :: Int -> LambdaAction -> ShowS
Prelude.Show, forall x. Rep LambdaAction x -> LambdaAction
forall x. LambdaAction -> Rep LambdaAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LambdaAction x -> LambdaAction
$cfrom :: forall x. LambdaAction -> Rep LambdaAction x
Prelude.Generic)

-- |
-- Create a value of 'LambdaAction' 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', 'lambdaAction_functionArn' - The ARN of the Lambda function.
newLambdaAction ::
  -- | 'functionArn'
  Prelude.Text ->
  LambdaAction
newLambdaAction :: Text -> LambdaAction
newLambdaAction Text
pFunctionArn_ =
  LambdaAction' {$sel:functionArn:LambdaAction' :: Text
functionArn = Text
pFunctionArn_}

-- | The ARN of the Lambda function.
lambdaAction_functionArn :: Lens.Lens' LambdaAction Prelude.Text
lambdaAction_functionArn :: Lens' LambdaAction Text
lambdaAction_functionArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaAction' {Text
functionArn :: Text
$sel:functionArn:LambdaAction' :: LambdaAction -> Text
functionArn} -> Text
functionArn) (\s :: LambdaAction
s@LambdaAction' {} Text
a -> LambdaAction
s {$sel:functionArn:LambdaAction' :: Text
functionArn = Text
a} :: LambdaAction)

instance Data.FromJSON LambdaAction where
  parseJSON :: Value -> Parser LambdaAction
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"LambdaAction"
      ( \Object
x ->
          Text -> LambdaAction
LambdaAction' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"functionArn")
      )

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

instance Prelude.NFData LambdaAction where
  rnf :: LambdaAction -> ()
rnf LambdaAction' {Text
functionArn :: Text
$sel:functionArn:LambdaAction' :: LambdaAction -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
functionArn

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