{-# 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.SecurityHub.Types.AwsLambdaFunctionEnvironment
-- 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.SecurityHub.Types.AwsLambdaFunctionEnvironment where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SecurityHub.Types.AwsLambdaFunctionEnvironmentError

-- | A function\'s environment variable settings.
--
-- /See:/ 'newAwsLambdaFunctionEnvironment' smart constructor.
data AwsLambdaFunctionEnvironment = AwsLambdaFunctionEnvironment'
  { -- | Environment variable key-value pairs.
    AwsLambdaFunctionEnvironment -> Maybe (HashMap Text Text)
variables :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | An @AwsLambdaFunctionEnvironmentError@ object.
    AwsLambdaFunctionEnvironment
-> Maybe AwsLambdaFunctionEnvironmentError
error :: Prelude.Maybe AwsLambdaFunctionEnvironmentError
  }
  deriving (AwsLambdaFunctionEnvironment
-> AwsLambdaFunctionEnvironment -> Bool
(AwsLambdaFunctionEnvironment
 -> AwsLambdaFunctionEnvironment -> Bool)
-> (AwsLambdaFunctionEnvironment
    -> AwsLambdaFunctionEnvironment -> Bool)
-> Eq AwsLambdaFunctionEnvironment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsLambdaFunctionEnvironment
-> AwsLambdaFunctionEnvironment -> Bool
$c/= :: AwsLambdaFunctionEnvironment
-> AwsLambdaFunctionEnvironment -> Bool
== :: AwsLambdaFunctionEnvironment
-> AwsLambdaFunctionEnvironment -> Bool
$c== :: AwsLambdaFunctionEnvironment
-> AwsLambdaFunctionEnvironment -> Bool
Prelude.Eq, ReadPrec [AwsLambdaFunctionEnvironment]
ReadPrec AwsLambdaFunctionEnvironment
Int -> ReadS AwsLambdaFunctionEnvironment
ReadS [AwsLambdaFunctionEnvironment]
(Int -> ReadS AwsLambdaFunctionEnvironment)
-> ReadS [AwsLambdaFunctionEnvironment]
-> ReadPrec AwsLambdaFunctionEnvironment
-> ReadPrec [AwsLambdaFunctionEnvironment]
-> Read AwsLambdaFunctionEnvironment
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsLambdaFunctionEnvironment]
$creadListPrec :: ReadPrec [AwsLambdaFunctionEnvironment]
readPrec :: ReadPrec AwsLambdaFunctionEnvironment
$creadPrec :: ReadPrec AwsLambdaFunctionEnvironment
readList :: ReadS [AwsLambdaFunctionEnvironment]
$creadList :: ReadS [AwsLambdaFunctionEnvironment]
readsPrec :: Int -> ReadS AwsLambdaFunctionEnvironment
$creadsPrec :: Int -> ReadS AwsLambdaFunctionEnvironment
Prelude.Read, Int -> AwsLambdaFunctionEnvironment -> ShowS
[AwsLambdaFunctionEnvironment] -> ShowS
AwsLambdaFunctionEnvironment -> String
(Int -> AwsLambdaFunctionEnvironment -> ShowS)
-> (AwsLambdaFunctionEnvironment -> String)
-> ([AwsLambdaFunctionEnvironment] -> ShowS)
-> Show AwsLambdaFunctionEnvironment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsLambdaFunctionEnvironment] -> ShowS
$cshowList :: [AwsLambdaFunctionEnvironment] -> ShowS
show :: AwsLambdaFunctionEnvironment -> String
$cshow :: AwsLambdaFunctionEnvironment -> String
showsPrec :: Int -> AwsLambdaFunctionEnvironment -> ShowS
$cshowsPrec :: Int -> AwsLambdaFunctionEnvironment -> ShowS
Prelude.Show, (forall x.
 AwsLambdaFunctionEnvironment -> Rep AwsLambdaFunctionEnvironment x)
-> (forall x.
    Rep AwsLambdaFunctionEnvironment x -> AwsLambdaFunctionEnvironment)
-> Generic AwsLambdaFunctionEnvironment
forall x.
Rep AwsLambdaFunctionEnvironment x -> AwsLambdaFunctionEnvironment
forall x.
AwsLambdaFunctionEnvironment -> Rep AwsLambdaFunctionEnvironment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsLambdaFunctionEnvironment x -> AwsLambdaFunctionEnvironment
$cfrom :: forall x.
AwsLambdaFunctionEnvironment -> Rep AwsLambdaFunctionEnvironment x
Prelude.Generic)

-- |
-- Create a value of 'AwsLambdaFunctionEnvironment' 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:
--
-- 'variables', 'awsLambdaFunctionEnvironment_variables' - Environment variable key-value pairs.
--
-- 'error', 'awsLambdaFunctionEnvironment_error' - An @AwsLambdaFunctionEnvironmentError@ object.
newAwsLambdaFunctionEnvironment ::
  AwsLambdaFunctionEnvironment
newAwsLambdaFunctionEnvironment :: AwsLambdaFunctionEnvironment
newAwsLambdaFunctionEnvironment =
  AwsLambdaFunctionEnvironment' :: Maybe (HashMap Text Text)
-> Maybe AwsLambdaFunctionEnvironmentError
-> AwsLambdaFunctionEnvironment
AwsLambdaFunctionEnvironment'
    { $sel:variables:AwsLambdaFunctionEnvironment' :: Maybe (HashMap Text Text)
variables =
        Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:error:AwsLambdaFunctionEnvironment' :: Maybe AwsLambdaFunctionEnvironmentError
error = Maybe AwsLambdaFunctionEnvironmentError
forall a. Maybe a
Prelude.Nothing
    }

-- | Environment variable key-value pairs.
awsLambdaFunctionEnvironment_variables :: Lens.Lens' AwsLambdaFunctionEnvironment (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
awsLambdaFunctionEnvironment_variables :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> AwsLambdaFunctionEnvironment -> f AwsLambdaFunctionEnvironment
awsLambdaFunctionEnvironment_variables = (AwsLambdaFunctionEnvironment -> Maybe (HashMap Text Text))
-> (AwsLambdaFunctionEnvironment
    -> Maybe (HashMap Text Text) -> AwsLambdaFunctionEnvironment)
-> Lens
     AwsLambdaFunctionEnvironment
     AwsLambdaFunctionEnvironment
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsLambdaFunctionEnvironment' {Maybe (HashMap Text Text)
variables :: Maybe (HashMap Text Text)
$sel:variables:AwsLambdaFunctionEnvironment' :: AwsLambdaFunctionEnvironment -> Maybe (HashMap Text Text)
variables} -> Maybe (HashMap Text Text)
variables) (\s :: AwsLambdaFunctionEnvironment
s@AwsLambdaFunctionEnvironment' {} Maybe (HashMap Text Text)
a -> AwsLambdaFunctionEnvironment
s {$sel:variables:AwsLambdaFunctionEnvironment' :: Maybe (HashMap Text Text)
variables = Maybe (HashMap Text Text)
a} :: AwsLambdaFunctionEnvironment) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> AwsLambdaFunctionEnvironment -> f AwsLambdaFunctionEnvironment)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> AwsLambdaFunctionEnvironment
-> f AwsLambdaFunctionEnvironment
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An @AwsLambdaFunctionEnvironmentError@ object.
awsLambdaFunctionEnvironment_error :: Lens.Lens' AwsLambdaFunctionEnvironment (Prelude.Maybe AwsLambdaFunctionEnvironmentError)
awsLambdaFunctionEnvironment_error :: (Maybe AwsLambdaFunctionEnvironmentError
 -> f (Maybe AwsLambdaFunctionEnvironmentError))
-> AwsLambdaFunctionEnvironment -> f AwsLambdaFunctionEnvironment
awsLambdaFunctionEnvironment_error = (AwsLambdaFunctionEnvironment
 -> Maybe AwsLambdaFunctionEnvironmentError)
-> (AwsLambdaFunctionEnvironment
    -> Maybe AwsLambdaFunctionEnvironmentError
    -> AwsLambdaFunctionEnvironment)
-> Lens
     AwsLambdaFunctionEnvironment
     AwsLambdaFunctionEnvironment
     (Maybe AwsLambdaFunctionEnvironmentError)
     (Maybe AwsLambdaFunctionEnvironmentError)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsLambdaFunctionEnvironment' {Maybe AwsLambdaFunctionEnvironmentError
error :: Maybe AwsLambdaFunctionEnvironmentError
$sel:error:AwsLambdaFunctionEnvironment' :: AwsLambdaFunctionEnvironment
-> Maybe AwsLambdaFunctionEnvironmentError
error} -> Maybe AwsLambdaFunctionEnvironmentError
error) (\s :: AwsLambdaFunctionEnvironment
s@AwsLambdaFunctionEnvironment' {} Maybe AwsLambdaFunctionEnvironmentError
a -> AwsLambdaFunctionEnvironment
s {$sel:error:AwsLambdaFunctionEnvironment' :: Maybe AwsLambdaFunctionEnvironmentError
error = Maybe AwsLambdaFunctionEnvironmentError
a} :: AwsLambdaFunctionEnvironment)

instance Core.FromJSON AwsLambdaFunctionEnvironment where
  parseJSON :: Value -> Parser AwsLambdaFunctionEnvironment
parseJSON =
    String
-> (Object -> Parser AwsLambdaFunctionEnvironment)
-> Value
-> Parser AwsLambdaFunctionEnvironment
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsLambdaFunctionEnvironment"
      ( \Object
x ->
          Maybe (HashMap Text Text)
-> Maybe AwsLambdaFunctionEnvironmentError
-> AwsLambdaFunctionEnvironment
AwsLambdaFunctionEnvironment'
            (Maybe (HashMap Text Text)
 -> Maybe AwsLambdaFunctionEnvironmentError
 -> AwsLambdaFunctionEnvironment)
-> Parser (Maybe (HashMap Text Text))
-> Parser
     (Maybe AwsLambdaFunctionEnvironmentError
      -> AwsLambdaFunctionEnvironment)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Variables" Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe AwsLambdaFunctionEnvironmentError
   -> AwsLambdaFunctionEnvironment)
-> Parser (Maybe AwsLambdaFunctionEnvironmentError)
-> Parser AwsLambdaFunctionEnvironment
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe AwsLambdaFunctionEnvironmentError)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Error")
      )

instance
  Prelude.Hashable
    AwsLambdaFunctionEnvironment

instance Prelude.NFData AwsLambdaFunctionEnvironment

instance Core.ToJSON AwsLambdaFunctionEnvironment where
  toJSON :: AwsLambdaFunctionEnvironment -> Value
toJSON AwsLambdaFunctionEnvironment' {Maybe (HashMap Text Text)
Maybe AwsLambdaFunctionEnvironmentError
error :: Maybe AwsLambdaFunctionEnvironmentError
variables :: Maybe (HashMap Text Text)
$sel:error:AwsLambdaFunctionEnvironment' :: AwsLambdaFunctionEnvironment
-> Maybe AwsLambdaFunctionEnvironmentError
$sel:variables:AwsLambdaFunctionEnvironment' :: AwsLambdaFunctionEnvironment -> Maybe (HashMap Text Text)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Variables" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
variables,
            (Text
"Error" Text -> AwsLambdaFunctionEnvironmentError -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (AwsLambdaFunctionEnvironmentError -> Pair)
-> Maybe AwsLambdaFunctionEnvironmentError -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AwsLambdaFunctionEnvironmentError
error
          ]
      )