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

-- | Contains information about a Lambda configuration.
--
-- /See:/ 'newLambdaConfiguration' smart constructor.
data LambdaConfiguration = LambdaConfiguration'
  { -- | The ARN of an IAM role that has permission to invoke the Lambda
    -- function.
    LambdaConfiguration -> Text
roleArn :: Prelude.Text,
    -- | The ARN of the Lambda function.
    LambdaConfiguration -> Text
lambdaArn :: Prelude.Text
  }
  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:
--
-- 'roleArn', 'lambdaConfiguration_roleArn' - The ARN of an IAM role that has permission to invoke the Lambda
-- function.
--
-- 'lambdaArn', 'lambdaConfiguration_lambdaArn' - The ARN of the Lambda function.
newLambdaConfiguration ::
  -- | 'roleArn'
  Prelude.Text ->
  -- | 'lambdaArn'
  Prelude.Text ->
  LambdaConfiguration
newLambdaConfiguration :: Text -> Text -> LambdaConfiguration
newLambdaConfiguration Text
pRoleArn_ Text
pLambdaArn_ =
  LambdaConfiguration'
    { $sel:roleArn:LambdaConfiguration' :: Text
roleArn = Text
pRoleArn_,
      $sel:lambdaArn:LambdaConfiguration' :: Text
lambdaArn = Text
pLambdaArn_
    }

-- | The ARN of an IAM role that has permission to invoke the Lambda
-- function.
lambdaConfiguration_roleArn :: Lens.Lens' LambdaConfiguration Prelude.Text
lambdaConfiguration_roleArn :: Lens' LambdaConfiguration Text
lambdaConfiguration_roleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaConfiguration' {Text
roleArn :: Text
$sel:roleArn:LambdaConfiguration' :: LambdaConfiguration -> Text
roleArn} -> Text
roleArn) (\s :: LambdaConfiguration
s@LambdaConfiguration' {} Text
a -> LambdaConfiguration
s {$sel:roleArn:LambdaConfiguration' :: Text
roleArn = Text
a} :: LambdaConfiguration)

-- | The ARN of the Lambda function.
lambdaConfiguration_lambdaArn :: Lens.Lens' LambdaConfiguration Prelude.Text
lambdaConfiguration_lambdaArn :: Lens' LambdaConfiguration Text
lambdaConfiguration_lambdaArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaConfiguration' {Text
lambdaArn :: Text
$sel:lambdaArn:LambdaConfiguration' :: LambdaConfiguration -> Text
lambdaArn} -> Text
lambdaArn) (\s :: LambdaConfiguration
s@LambdaConfiguration' {} Text
a -> LambdaConfiguration
s {$sel:lambdaArn:LambdaConfiguration' :: Text
lambdaArn = Text
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 -> Text -> 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
"RoleArn")
            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
"LambdaArn")
      )

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

instance Prelude.NFData LambdaConfiguration where
  rnf :: LambdaConfiguration -> ()
rnf LambdaConfiguration' {Text
lambdaArn :: Text
roleArn :: Text
$sel:lambdaArn:LambdaConfiguration' :: LambdaConfiguration -> Text
$sel:roleArn:LambdaConfiguration' :: LambdaConfiguration -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
roleArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
lambdaArn

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