{-# 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.Lambda.Types.Environment
-- 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.Lambda.Types.Environment where

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

-- | A function\'s environment variable settings. You can use environment
-- variables to adjust your function\'s behavior without updating code. An
-- environment variable is a pair of strings that are stored in a
-- function\'s version-specific configuration.
--
-- /See:/ 'newEnvironment' smart constructor.
data Environment = Environment'
  { -- | Environment variable key-value pairs. For more information, see
    -- <https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html Using Lambda environment variables>.
    Environment -> Maybe (Sensitive (HashMap Text (Sensitive Text)))
variables :: Prelude.Maybe (Core.Sensitive (Prelude.HashMap Prelude.Text (Core.Sensitive Prelude.Text)))
  }
  deriving (Environment -> Environment -> Bool
(Environment -> Environment -> Bool)
-> (Environment -> Environment -> Bool) -> Eq Environment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Environment -> Environment -> Bool
$c/= :: Environment -> Environment -> Bool
== :: Environment -> Environment -> Bool
$c== :: Environment -> Environment -> Bool
Prelude.Eq, Int -> Environment -> ShowS
[Environment] -> ShowS
Environment -> String
(Int -> Environment -> ShowS)
-> (Environment -> String)
-> ([Environment] -> ShowS)
-> Show Environment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Environment] -> ShowS
$cshowList :: [Environment] -> ShowS
show :: Environment -> String
$cshow :: Environment -> String
showsPrec :: Int -> Environment -> ShowS
$cshowsPrec :: Int -> Environment -> ShowS
Prelude.Show, (forall x. Environment -> Rep Environment x)
-> (forall x. Rep Environment x -> Environment)
-> Generic Environment
forall x. Rep Environment x -> Environment
forall x. Environment -> Rep Environment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Environment x -> Environment
$cfrom :: forall x. Environment -> Rep Environment x
Prelude.Generic)

-- |
-- Create a value of 'Environment' 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', 'environment_variables' - Environment variable key-value pairs. For more information, see
-- <https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html Using Lambda environment variables>.
newEnvironment ::
  Environment
newEnvironment :: Environment
newEnvironment =
  Environment' :: Maybe (Sensitive (HashMap Text (Sensitive Text))) -> Environment
Environment' {$sel:variables:Environment' :: Maybe (Sensitive (HashMap Text (Sensitive Text)))
variables = Maybe (Sensitive (HashMap Text (Sensitive Text)))
forall a. Maybe a
Prelude.Nothing}

-- | Environment variable key-value pairs. For more information, see
-- <https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html Using Lambda environment variables>.
environment_variables :: Lens.Lens' Environment (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
environment_variables :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Environment -> f Environment
environment_variables = (Environment -> Maybe (Sensitive (HashMap Text (Sensitive Text))))
-> (Environment
    -> Maybe (Sensitive (HashMap Text (Sensitive Text)))
    -> Environment)
-> Lens
     Environment
     Environment
     (Maybe (Sensitive (HashMap Text (Sensitive Text))))
     (Maybe (Sensitive (HashMap Text (Sensitive Text))))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Environment' {Maybe (Sensitive (HashMap Text (Sensitive Text)))
variables :: Maybe (Sensitive (HashMap Text (Sensitive Text)))
$sel:variables:Environment' :: Environment -> Maybe (Sensitive (HashMap Text (Sensitive Text)))
variables} -> Maybe (Sensitive (HashMap Text (Sensitive Text)))
variables) (\s :: Environment
s@Environment' {} Maybe (Sensitive (HashMap Text (Sensitive Text)))
a -> Environment
s {$sel:variables:Environment' :: Maybe (Sensitive (HashMap Text (Sensitive Text)))
variables = Maybe (Sensitive (HashMap Text (Sensitive Text)))
a} :: Environment) ((Maybe (Sensitive (HashMap Text (Sensitive Text)))
  -> f (Maybe (Sensitive (HashMap Text (Sensitive Text)))))
 -> Environment -> f Environment)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (Sensitive (HashMap Text (Sensitive Text)))
    -> f (Maybe (Sensitive (HashMap Text (Sensitive Text)))))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Environment
-> f Environment
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (Sensitive (HashMap Text (Sensitive Text)))
  (Sensitive (HashMap Text (Sensitive Text)))
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (Sensitive (HashMap Text (Sensitive Text))))
     (Maybe (Sensitive (HashMap Text (Sensitive 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 (Exchange
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text (Sensitive Text))
  (Identity (HashMap Text (Sensitive Text)))
-> Exchange
     (HashMap Text Text)
     (HashMap Text Text)
     (Sensitive (HashMap Text (Sensitive Text)))
     (Identity (Sensitive (HashMap Text (Sensitive Text))))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Exchange
   (HashMap Text Text)
   (HashMap Text Text)
   (HashMap Text (Sensitive Text))
   (Identity (HashMap Text (Sensitive Text)))
 -> Exchange
      (HashMap Text Text)
      (HashMap Text Text)
      (Sensitive (HashMap Text (Sensitive Text)))
      (Identity (Sensitive (HashMap Text (Sensitive Text)))))
-> (Exchange
      (HashMap Text Text)
      (HashMap Text Text)
      (HashMap Text Text)
      (Identity (HashMap Text Text))
    -> Exchange
         (HashMap Text Text)
         (HashMap Text Text)
         (HashMap Text (Sensitive Text))
         (Identity (HashMap Text (Sensitive Text))))
-> AnIso
     (Sensitive (HashMap Text (Sensitive Text)))
     (Sensitive (HashMap Text (Sensitive Text)))
     (HashMap Text Text)
     (HashMap Text Text)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Exchange
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (Identity (HashMap Text Text))
-> Exchange
     (HashMap Text Text)
     (HashMap Text Text)
     (HashMap Text (Sensitive Text))
     (Identity (HashMap Text (Sensitive Text)))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced)

instance Prelude.Hashable Environment

instance Prelude.NFData Environment

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