{-# 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.AppSync.Types.LambdaDataSourceConfig
-- 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.AppSync.Types.LambdaDataSourceConfig where

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

-- | Describes an Amazon Web Services Lambda data source configuration.
--
-- /See:/ 'newLambdaDataSourceConfig' smart constructor.
data LambdaDataSourceConfig = LambdaDataSourceConfig'
  { -- | The ARN for the Lambda function.
    LambdaDataSourceConfig -> Text
lambdaFunctionArn :: Prelude.Text
  }
  deriving (LambdaDataSourceConfig -> LambdaDataSourceConfig -> Bool
(LambdaDataSourceConfig -> LambdaDataSourceConfig -> Bool)
-> (LambdaDataSourceConfig -> LambdaDataSourceConfig -> Bool)
-> Eq LambdaDataSourceConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LambdaDataSourceConfig -> LambdaDataSourceConfig -> Bool
$c/= :: LambdaDataSourceConfig -> LambdaDataSourceConfig -> Bool
== :: LambdaDataSourceConfig -> LambdaDataSourceConfig -> Bool
$c== :: LambdaDataSourceConfig -> LambdaDataSourceConfig -> Bool
Prelude.Eq, ReadPrec [LambdaDataSourceConfig]
ReadPrec LambdaDataSourceConfig
Int -> ReadS LambdaDataSourceConfig
ReadS [LambdaDataSourceConfig]
(Int -> ReadS LambdaDataSourceConfig)
-> ReadS [LambdaDataSourceConfig]
-> ReadPrec LambdaDataSourceConfig
-> ReadPrec [LambdaDataSourceConfig]
-> Read LambdaDataSourceConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LambdaDataSourceConfig]
$creadListPrec :: ReadPrec [LambdaDataSourceConfig]
readPrec :: ReadPrec LambdaDataSourceConfig
$creadPrec :: ReadPrec LambdaDataSourceConfig
readList :: ReadS [LambdaDataSourceConfig]
$creadList :: ReadS [LambdaDataSourceConfig]
readsPrec :: Int -> ReadS LambdaDataSourceConfig
$creadsPrec :: Int -> ReadS LambdaDataSourceConfig
Prelude.Read, Int -> LambdaDataSourceConfig -> ShowS
[LambdaDataSourceConfig] -> ShowS
LambdaDataSourceConfig -> String
(Int -> LambdaDataSourceConfig -> ShowS)
-> (LambdaDataSourceConfig -> String)
-> ([LambdaDataSourceConfig] -> ShowS)
-> Show LambdaDataSourceConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LambdaDataSourceConfig] -> ShowS
$cshowList :: [LambdaDataSourceConfig] -> ShowS
show :: LambdaDataSourceConfig -> String
$cshow :: LambdaDataSourceConfig -> String
showsPrec :: Int -> LambdaDataSourceConfig -> ShowS
$cshowsPrec :: Int -> LambdaDataSourceConfig -> ShowS
Prelude.Show, (forall x. LambdaDataSourceConfig -> Rep LambdaDataSourceConfig x)
-> (forall x.
    Rep LambdaDataSourceConfig x -> LambdaDataSourceConfig)
-> Generic LambdaDataSourceConfig
forall x. Rep LambdaDataSourceConfig x -> LambdaDataSourceConfig
forall x. LambdaDataSourceConfig -> Rep LambdaDataSourceConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LambdaDataSourceConfig x -> LambdaDataSourceConfig
$cfrom :: forall x. LambdaDataSourceConfig -> Rep LambdaDataSourceConfig x
Prelude.Generic)

-- |
-- Create a value of 'LambdaDataSourceConfig' 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:
--
-- 'lambdaFunctionArn', 'lambdaDataSourceConfig_lambdaFunctionArn' - The ARN for the Lambda function.
newLambdaDataSourceConfig ::
  -- | 'lambdaFunctionArn'
  Prelude.Text ->
  LambdaDataSourceConfig
newLambdaDataSourceConfig :: Text -> LambdaDataSourceConfig
newLambdaDataSourceConfig Text
pLambdaFunctionArn_ =
  LambdaDataSourceConfig' :: Text -> LambdaDataSourceConfig
LambdaDataSourceConfig'
    { $sel:lambdaFunctionArn:LambdaDataSourceConfig' :: Text
lambdaFunctionArn =
        Text
pLambdaFunctionArn_
    }

-- | The ARN for the Lambda function.
lambdaDataSourceConfig_lambdaFunctionArn :: Lens.Lens' LambdaDataSourceConfig Prelude.Text
lambdaDataSourceConfig_lambdaFunctionArn :: (Text -> f Text)
-> LambdaDataSourceConfig -> f LambdaDataSourceConfig
lambdaDataSourceConfig_lambdaFunctionArn = (LambdaDataSourceConfig -> Text)
-> (LambdaDataSourceConfig -> Text -> LambdaDataSourceConfig)
-> Lens LambdaDataSourceConfig LambdaDataSourceConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaDataSourceConfig' {Text
lambdaFunctionArn :: Text
$sel:lambdaFunctionArn:LambdaDataSourceConfig' :: LambdaDataSourceConfig -> Text
lambdaFunctionArn} -> Text
lambdaFunctionArn) (\s :: LambdaDataSourceConfig
s@LambdaDataSourceConfig' {} Text
a -> LambdaDataSourceConfig
s {$sel:lambdaFunctionArn:LambdaDataSourceConfig' :: Text
lambdaFunctionArn = Text
a} :: LambdaDataSourceConfig)

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

instance Prelude.Hashable LambdaDataSourceConfig

instance Prelude.NFData LambdaDataSourceConfig

instance Core.ToJSON LambdaDataSourceConfig where
  toJSON :: LambdaDataSourceConfig -> Value
toJSON LambdaDataSourceConfig' {Text
lambdaFunctionArn :: Text
$sel:lambdaFunctionArn:LambdaDataSourceConfig' :: LambdaDataSourceConfig -> 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
"lambdaFunctionArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
lambdaFunctionArn)
          ]
      )