{-# 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.ChimeSDKMessaging.Types.LambdaConfiguration
-- 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.ChimeSDKMessaging.Types.LambdaConfiguration where

import Amazonka.ChimeSDKMessaging.Types.InvocationType
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

-- | Stores metadata about a Lambda processor.
--
-- /See:/ 'newLambdaConfiguration' smart constructor.
data LambdaConfiguration = LambdaConfiguration'
  { -- | The ARN of the Lambda message processing function.
    LambdaConfiguration -> Text
resourceArn :: Prelude.Text,
    -- | Controls how the Lambda function is invoked.
    LambdaConfiguration -> InvocationType
invocationType :: InvocationType
  }
  deriving (LambdaConfiguration -> LambdaConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LambdaConfiguration -> LambdaConfiguration -> Bool
$c/= :: LambdaConfiguration -> LambdaConfiguration -> Bool
== :: LambdaConfiguration -> LambdaConfiguration -> Bool
$c== :: LambdaConfiguration -> LambdaConfiguration -> Bool
Prelude.Eq, ReadPrec [LambdaConfiguration]
ReadPrec LambdaConfiguration
Int -> ReadS LambdaConfiguration
ReadS [LambdaConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LambdaConfiguration]
$creadListPrec :: ReadPrec [LambdaConfiguration]
readPrec :: ReadPrec LambdaConfiguration
$creadPrec :: ReadPrec LambdaConfiguration
readList :: ReadS [LambdaConfiguration]
$creadList :: ReadS [LambdaConfiguration]
readsPrec :: Int -> ReadS LambdaConfiguration
$creadsPrec :: Int -> ReadS LambdaConfiguration
Prelude.Read, Int -> LambdaConfiguration -> ShowS
[LambdaConfiguration] -> ShowS
LambdaConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LambdaConfiguration] -> ShowS
$cshowList :: [LambdaConfiguration] -> ShowS
show :: LambdaConfiguration -> String
$cshow :: LambdaConfiguration -> String
showsPrec :: Int -> LambdaConfiguration -> ShowS
$cshowsPrec :: Int -> LambdaConfiguration -> ShowS
Prelude.Show, forall x. Rep LambdaConfiguration x -> LambdaConfiguration
forall x. LambdaConfiguration -> Rep LambdaConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LambdaConfiguration x -> LambdaConfiguration
$cfrom :: forall x. LambdaConfiguration -> Rep LambdaConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'LambdaConfiguration' 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', 'lambdaConfiguration_resourceArn' - The ARN of the Lambda message processing function.
--
-- 'invocationType', 'lambdaConfiguration_invocationType' - Controls how the Lambda function is invoked.
newLambdaConfiguration ::
  -- | 'resourceArn'
  Prelude.Text ->
  -- | 'invocationType'
  InvocationType ->
  LambdaConfiguration
newLambdaConfiguration :: Text -> InvocationType -> LambdaConfiguration
newLambdaConfiguration Text
pResourceArn_ InvocationType
pInvocationType_ =
  LambdaConfiguration'
    { $sel:resourceArn:LambdaConfiguration' :: Text
resourceArn = Text
pResourceArn_,
      $sel:invocationType:LambdaConfiguration' :: InvocationType
invocationType = InvocationType
pInvocationType_
    }

-- | The ARN of the Lambda message processing function.
lambdaConfiguration_resourceArn :: Lens.Lens' LambdaConfiguration Prelude.Text
lambdaConfiguration_resourceArn :: Lens' LambdaConfiguration Text
lambdaConfiguration_resourceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaConfiguration' {Text
resourceArn :: Text
$sel:resourceArn:LambdaConfiguration' :: LambdaConfiguration -> Text
resourceArn} -> Text
resourceArn) (\s :: LambdaConfiguration
s@LambdaConfiguration' {} Text
a -> LambdaConfiguration
s {$sel:resourceArn:LambdaConfiguration' :: Text
resourceArn = Text
a} :: LambdaConfiguration)

-- | Controls how the Lambda function is invoked.
lambdaConfiguration_invocationType :: Lens.Lens' LambdaConfiguration InvocationType
lambdaConfiguration_invocationType :: Lens' LambdaConfiguration InvocationType
lambdaConfiguration_invocationType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaConfiguration' {InvocationType
invocationType :: InvocationType
$sel:invocationType:LambdaConfiguration' :: LambdaConfiguration -> InvocationType
invocationType} -> InvocationType
invocationType) (\s :: LambdaConfiguration
s@LambdaConfiguration' {} InvocationType
a -> LambdaConfiguration
s {$sel:invocationType:LambdaConfiguration' :: InvocationType
invocationType = InvocationType
a} :: LambdaConfiguration)

instance Data.FromJSON LambdaConfiguration where
  parseJSON :: Value -> Parser LambdaConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"LambdaConfiguration"
      ( \Object
x ->
          Text -> InvocationType -> LambdaConfiguration
LambdaConfiguration'
            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
"ResourceArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"InvocationType")
      )

instance Prelude.Hashable LambdaConfiguration where
  hashWithSalt :: Int -> LambdaConfiguration -> Int
hashWithSalt Int
_salt LambdaConfiguration' {Text
InvocationType
invocationType :: InvocationType
resourceArn :: Text
$sel:invocationType:LambdaConfiguration' :: LambdaConfiguration -> InvocationType
$sel:resourceArn:LambdaConfiguration' :: LambdaConfiguration -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` InvocationType
invocationType

instance Prelude.NFData LambdaConfiguration where
  rnf :: LambdaConfiguration -> ()
rnf LambdaConfiguration' {Text
InvocationType
invocationType :: InvocationType
resourceArn :: Text
$sel:invocationType:LambdaConfiguration' :: LambdaConfiguration -> InvocationType
$sel:resourceArn:LambdaConfiguration' :: LambdaConfiguration -> 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 InvocationType
invocationType

instance Data.ToJSON LambdaConfiguration where
  toJSON :: LambdaConfiguration -> Value
toJSON LambdaConfiguration' {Text
InvocationType
invocationType :: InvocationType
resourceArn :: Text
$sel:invocationType:LambdaConfiguration' :: LambdaConfiguration -> InvocationType
$sel:resourceArn:LambdaConfiguration' :: LambdaConfiguration -> 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
"InvocationType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= InvocationType
invocationType)
          ]
      )