{-# 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.LexV2Models.Types.LambdaCodeHook
-- 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.LexV2Models.Types.LambdaCodeHook 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

-- | Specifies a Lambda function that verifies requests to a bot or fulfills
-- the user\'s request to a bot.
--
-- /See:/ 'newLambdaCodeHook' smart constructor.
data LambdaCodeHook = LambdaCodeHook'
  { -- | The Amazon Resource Name (ARN) of the Lambda function.
    LambdaCodeHook -> Text
lambdaARN :: Prelude.Text,
    -- | The version of the request-response that you want Amazon Lex to use to
    -- invoke your Lambda function.
    LambdaCodeHook -> Text
codeHookInterfaceVersion :: Prelude.Text
  }
  deriving (LambdaCodeHook -> LambdaCodeHook -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LambdaCodeHook -> LambdaCodeHook -> Bool
$c/= :: LambdaCodeHook -> LambdaCodeHook -> Bool
== :: LambdaCodeHook -> LambdaCodeHook -> Bool
$c== :: LambdaCodeHook -> LambdaCodeHook -> Bool
Prelude.Eq, ReadPrec [LambdaCodeHook]
ReadPrec LambdaCodeHook
Int -> ReadS LambdaCodeHook
ReadS [LambdaCodeHook]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LambdaCodeHook]
$creadListPrec :: ReadPrec [LambdaCodeHook]
readPrec :: ReadPrec LambdaCodeHook
$creadPrec :: ReadPrec LambdaCodeHook
readList :: ReadS [LambdaCodeHook]
$creadList :: ReadS [LambdaCodeHook]
readsPrec :: Int -> ReadS LambdaCodeHook
$creadsPrec :: Int -> ReadS LambdaCodeHook
Prelude.Read, Int -> LambdaCodeHook -> ShowS
[LambdaCodeHook] -> ShowS
LambdaCodeHook -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LambdaCodeHook] -> ShowS
$cshowList :: [LambdaCodeHook] -> ShowS
show :: LambdaCodeHook -> String
$cshow :: LambdaCodeHook -> String
showsPrec :: Int -> LambdaCodeHook -> ShowS
$cshowsPrec :: Int -> LambdaCodeHook -> ShowS
Prelude.Show, forall x. Rep LambdaCodeHook x -> LambdaCodeHook
forall x. LambdaCodeHook -> Rep LambdaCodeHook x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LambdaCodeHook x -> LambdaCodeHook
$cfrom :: forall x. LambdaCodeHook -> Rep LambdaCodeHook x
Prelude.Generic)

-- |
-- Create a value of 'LambdaCodeHook' 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:
--
-- 'lambdaARN', 'lambdaCodeHook_lambdaARN' - The Amazon Resource Name (ARN) of the Lambda function.
--
-- 'codeHookInterfaceVersion', 'lambdaCodeHook_codeHookInterfaceVersion' - The version of the request-response that you want Amazon Lex to use to
-- invoke your Lambda function.
newLambdaCodeHook ::
  -- | 'lambdaARN'
  Prelude.Text ->
  -- | 'codeHookInterfaceVersion'
  Prelude.Text ->
  LambdaCodeHook
newLambdaCodeHook :: Text -> Text -> LambdaCodeHook
newLambdaCodeHook
  Text
pLambdaARN_
  Text
pCodeHookInterfaceVersion_ =
    LambdaCodeHook'
      { $sel:lambdaARN:LambdaCodeHook' :: Text
lambdaARN = Text
pLambdaARN_,
        $sel:codeHookInterfaceVersion:LambdaCodeHook' :: Text
codeHookInterfaceVersion =
          Text
pCodeHookInterfaceVersion_
      }

-- | The Amazon Resource Name (ARN) of the Lambda function.
lambdaCodeHook_lambdaARN :: Lens.Lens' LambdaCodeHook Prelude.Text
lambdaCodeHook_lambdaARN :: Lens' LambdaCodeHook Text
lambdaCodeHook_lambdaARN = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaCodeHook' {Text
lambdaARN :: Text
$sel:lambdaARN:LambdaCodeHook' :: LambdaCodeHook -> Text
lambdaARN} -> Text
lambdaARN) (\s :: LambdaCodeHook
s@LambdaCodeHook' {} Text
a -> LambdaCodeHook
s {$sel:lambdaARN:LambdaCodeHook' :: Text
lambdaARN = Text
a} :: LambdaCodeHook)

-- | The version of the request-response that you want Amazon Lex to use to
-- invoke your Lambda function.
lambdaCodeHook_codeHookInterfaceVersion :: Lens.Lens' LambdaCodeHook Prelude.Text
lambdaCodeHook_codeHookInterfaceVersion :: Lens' LambdaCodeHook Text
lambdaCodeHook_codeHookInterfaceVersion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaCodeHook' {Text
codeHookInterfaceVersion :: Text
$sel:codeHookInterfaceVersion:LambdaCodeHook' :: LambdaCodeHook -> Text
codeHookInterfaceVersion} -> Text
codeHookInterfaceVersion) (\s :: LambdaCodeHook
s@LambdaCodeHook' {} Text
a -> LambdaCodeHook
s {$sel:codeHookInterfaceVersion:LambdaCodeHook' :: Text
codeHookInterfaceVersion = Text
a} :: LambdaCodeHook)

instance Data.FromJSON LambdaCodeHook where
  parseJSON :: Value -> Parser LambdaCodeHook
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"LambdaCodeHook"
      ( \Object
x ->
          Text -> Text -> LambdaCodeHook
LambdaCodeHook'
            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
"lambdaARN")
            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
"codeHookInterfaceVersion")
      )

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

instance Prelude.NFData LambdaCodeHook where
  rnf :: LambdaCodeHook -> ()
rnf LambdaCodeHook' {Text
codeHookInterfaceVersion :: Text
lambdaARN :: Text
$sel:codeHookInterfaceVersion:LambdaCodeHook' :: LambdaCodeHook -> Text
$sel:lambdaARN:LambdaCodeHook' :: LambdaCodeHook -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
lambdaARN
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
codeHookInterfaceVersion

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