{-# 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.EnvironmentResponse
-- 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.EnvironmentResponse where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Lambda.Types.EnvironmentError
import qualified Amazonka.Prelude as Prelude

-- | The results of an operation to update or read environment variables. If
-- the operation succeeds, the response contains the environment variables.
-- If it fails, the response contains details about the error.
--
-- /See:/ 'newEnvironmentResponse' smart constructor.
data EnvironmentResponse = EnvironmentResponse'
  { -- | Error messages for environment variables that couldn\'t be applied.
    EnvironmentResponse -> Maybe EnvironmentError
error :: Prelude.Maybe EnvironmentError,
    -- | Environment variable key-value pairs. Omitted from CloudTrail logs.
    EnvironmentResponse
-> Maybe (Sensitive (HashMap Text (Sensitive Text)))
variables :: Prelude.Maybe (Data.Sensitive (Prelude.HashMap Prelude.Text (Data.Sensitive Prelude.Text)))
  }
  deriving (EnvironmentResponse -> EnvironmentResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnvironmentResponse -> EnvironmentResponse -> Bool
$c/= :: EnvironmentResponse -> EnvironmentResponse -> Bool
== :: EnvironmentResponse -> EnvironmentResponse -> Bool
$c== :: EnvironmentResponse -> EnvironmentResponse -> Bool
Prelude.Eq, Int -> EnvironmentResponse -> ShowS
[EnvironmentResponse] -> ShowS
EnvironmentResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnvironmentResponse] -> ShowS
$cshowList :: [EnvironmentResponse] -> ShowS
show :: EnvironmentResponse -> String
$cshow :: EnvironmentResponse -> String
showsPrec :: Int -> EnvironmentResponse -> ShowS
$cshowsPrec :: Int -> EnvironmentResponse -> ShowS
Prelude.Show, forall x. Rep EnvironmentResponse x -> EnvironmentResponse
forall x. EnvironmentResponse -> Rep EnvironmentResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EnvironmentResponse x -> EnvironmentResponse
$cfrom :: forall x. EnvironmentResponse -> Rep EnvironmentResponse x
Prelude.Generic)

-- |
-- Create a value of 'EnvironmentResponse' 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:
--
-- 'error', 'environmentResponse_error' - Error messages for environment variables that couldn\'t be applied.
--
-- 'variables', 'environmentResponse_variables' - Environment variable key-value pairs. Omitted from CloudTrail logs.
newEnvironmentResponse ::
  EnvironmentResponse
newEnvironmentResponse :: EnvironmentResponse
newEnvironmentResponse =
  EnvironmentResponse'
    { $sel:error:EnvironmentResponse' :: Maybe EnvironmentError
error = forall a. Maybe a
Prelude.Nothing,
      $sel:variables:EnvironmentResponse' :: Maybe (Sensitive (HashMap Text (Sensitive Text)))
variables = forall a. Maybe a
Prelude.Nothing
    }

-- | Error messages for environment variables that couldn\'t be applied.
environmentResponse_error :: Lens.Lens' EnvironmentResponse (Prelude.Maybe EnvironmentError)
environmentResponse_error :: Lens' EnvironmentResponse (Maybe EnvironmentError)
environmentResponse_error = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnvironmentResponse' {Maybe EnvironmentError
error :: Maybe EnvironmentError
$sel:error:EnvironmentResponse' :: EnvironmentResponse -> Maybe EnvironmentError
error} -> Maybe EnvironmentError
error) (\s :: EnvironmentResponse
s@EnvironmentResponse' {} Maybe EnvironmentError
a -> EnvironmentResponse
s {$sel:error:EnvironmentResponse' :: Maybe EnvironmentError
error = Maybe EnvironmentError
a} :: EnvironmentResponse)

-- | Environment variable key-value pairs. Omitted from CloudTrail logs.
environmentResponse_variables :: Lens.Lens' EnvironmentResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
environmentResponse_variables :: Lens' EnvironmentResponse (Maybe (HashMap Text Text))
environmentResponse_variables = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnvironmentResponse' {Maybe (Sensitive (HashMap Text (Sensitive Text)))
variables :: Maybe (Sensitive (HashMap Text (Sensitive Text)))
$sel:variables:EnvironmentResponse' :: EnvironmentResponse
-> Maybe (Sensitive (HashMap Text (Sensitive Text)))
variables} -> Maybe (Sensitive (HashMap Text (Sensitive Text)))
variables) (\s :: EnvironmentResponse
s@EnvironmentResponse' {} Maybe (Sensitive (HashMap Text (Sensitive Text)))
a -> EnvironmentResponse
s {$sel:variables:EnvironmentResponse' :: Maybe (Sensitive (HashMap Text (Sensitive Text)))
variables = Maybe (Sensitive (HashMap Text (Sensitive Text)))
a} :: EnvironmentResponse) 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 Data.FromJSON EnvironmentResponse where
  parseJSON :: Value -> Parser EnvironmentResponse
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EnvironmentResponse"
      ( \Object
x ->
          Maybe EnvironmentError
-> Maybe (Sensitive (HashMap Text (Sensitive Text)))
-> EnvironmentResponse
EnvironmentResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Error")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Variables" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

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

instance Prelude.NFData EnvironmentResponse where
  rnf :: EnvironmentResponse -> ()
rnf EnvironmentResponse' {Maybe (Sensitive (HashMap Text (Sensitive Text)))
Maybe EnvironmentError
variables :: Maybe (Sensitive (HashMap Text (Sensitive Text)))
error :: Maybe EnvironmentError
$sel:variables:EnvironmentResponse' :: EnvironmentResponse
-> Maybe (Sensitive (HashMap Text (Sensitive Text)))
$sel:error:EnvironmentResponse' :: EnvironmentResponse -> Maybe EnvironmentError
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe EnvironmentError
error
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive (HashMap Text (Sensitive Text)))
variables