{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Lambda.Types.Environment 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

-- | 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 (Data.Sensitive (Prelude.HashMap Prelude.Text (Data.Sensitive Prelude.Text)))
  }
  deriving (Environment -> Environment -> Bool
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
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. 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' {$sel:variables:Environment' :: Maybe (Sensitive (HashMap Text (Sensitive Text)))
variables = 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 :: Lens' Environment (Maybe (HashMap Text Text))
environment_variables = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 (forall a. Iso' (Sensitive a) a
Data._Sensitive forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced)

instance Prelude.Hashable Environment where
  hashWithSalt :: Int -> Environment -> Int
hashWithSalt Int
_salt Environment' {Maybe (Sensitive (HashMap Text (Sensitive Text)))
variables :: Maybe (Sensitive (HashMap Text (Sensitive Text)))
$sel:variables:Environment' :: Environment -> Maybe (Sensitive (HashMap Text (Sensitive Text)))
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive (HashMap Text (Sensitive Text)))
variables

instance Prelude.NFData Environment where
  rnf :: Environment -> ()
rnf Environment' {Maybe (Sensitive (HashMap Text (Sensitive Text)))
variables :: Maybe (Sensitive (HashMap Text (Sensitive Text)))
$sel:variables:Environment' :: Environment -> Maybe (Sensitive (HashMap Text (Sensitive Text)))
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive (HashMap Text (Sensitive Text)))
variables

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"Variables" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive (HashMap Text (Sensitive Text)))
variables]
      )