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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(LambdaConfiguration -> LambdaConfiguration -> Bool)
-> (LambdaConfiguration -> LambdaConfiguration -> Bool)
-> Eq LambdaConfiguration
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]
(Int -> ReadS LambdaConfiguration)
-> ReadS [LambdaConfiguration]
-> ReadPrec LambdaConfiguration
-> ReadPrec [LambdaConfiguration]
-> Read 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
(Int -> LambdaConfiguration -> ShowS)
-> (LambdaConfiguration -> String)
-> ([LambdaConfiguration] -> ShowS)
-> Show LambdaConfiguration
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. LambdaConfiguration -> Rep LambdaConfiguration x)
-> (forall x. Rep LambdaConfiguration x -> LambdaConfiguration)
-> Generic LambdaConfiguration
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' :: Text -> Text -> LambdaConfiguration
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 :: (Text -> f Text) -> LambdaConfiguration -> f LambdaConfiguration
lambdaConfiguration_roleArn = (LambdaConfiguration -> Text)
-> (LambdaConfiguration -> Text -> LambdaConfiguration)
-> Lens LambdaConfiguration LambdaConfiguration Text Text
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 :: (Text -> f Text) -> LambdaConfiguration -> f LambdaConfiguration
lambdaConfiguration_lambdaArn = (LambdaConfiguration -> Text)
-> (LambdaConfiguration -> Text -> LambdaConfiguration)
-> Lens LambdaConfiguration LambdaConfiguration Text Text
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 Core.FromJSON LambdaConfiguration where
  parseJSON :: Value -> Parser LambdaConfiguration
parseJSON =
    String
-> (Object -> Parser LambdaConfiguration)
-> Value
-> Parser LambdaConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LambdaConfiguration"
      ( \Object
x ->
          Text -> Text -> LambdaConfiguration
LambdaConfiguration'
            (Text -> Text -> LambdaConfiguration)
-> Parser Text -> Parser (Text -> LambdaConfiguration)
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
"RoleArn")
            Parser (Text -> LambdaConfiguration)
-> Parser Text -> Parser LambdaConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"LambdaArn")
      )

instance Prelude.Hashable LambdaConfiguration

instance Prelude.NFData LambdaConfiguration

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"RoleArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
roleArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"LambdaArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
lambdaArn)
          ]
      )