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

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

-- | The results of an operation to update or read environment variables. If
-- the operation is successful, the response contains the environment
-- variables. If it failed, the response contains details about the error.
--
-- /See:/ 'newEnvironmentResponse' smart constructor.
data EnvironmentResponse = EnvironmentResponse'
  { -- | Environment variable key-value pairs.
    EnvironmentResponse
-> Maybe (Sensitive (HashMap Text (Sensitive Text)))
variables :: Prelude.Maybe (Core.Sensitive (Prelude.HashMap Prelude.Text (Core.Sensitive Prelude.Text))),
    -- | Error messages for environment variables that couldn\'t be applied.
    EnvironmentResponse -> Maybe EnvironmentError
error :: Prelude.Maybe EnvironmentError
  }
  deriving (EnvironmentResponse -> EnvironmentResponse -> Bool
(EnvironmentResponse -> EnvironmentResponse -> Bool)
-> (EnvironmentResponse -> EnvironmentResponse -> Bool)
-> Eq EnvironmentResponse
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
(Int -> EnvironmentResponse -> ShowS)
-> (EnvironmentResponse -> String)
-> ([EnvironmentResponse] -> ShowS)
-> Show EnvironmentResponse
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. EnvironmentResponse -> Rep EnvironmentResponse x)
-> (forall x. Rep EnvironmentResponse x -> EnvironmentResponse)
-> Generic EnvironmentResponse
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:
--
-- 'variables', 'environmentResponse_variables' - Environment variable key-value pairs.
--
-- 'error', 'environmentResponse_error' - Error messages for environment variables that couldn\'t be applied.
newEnvironmentResponse ::
  EnvironmentResponse
newEnvironmentResponse :: EnvironmentResponse
newEnvironmentResponse =
  EnvironmentResponse' :: Maybe (Sensitive (HashMap Text (Sensitive Text)))
-> Maybe EnvironmentError -> EnvironmentResponse
EnvironmentResponse'
    { $sel:variables:EnvironmentResponse' :: Maybe (Sensitive (HashMap Text (Sensitive Text)))
variables = Maybe (Sensitive (HashMap Text (Sensitive Text)))
forall a. Maybe a
Prelude.Nothing,
      $sel:error:EnvironmentResponse' :: Maybe EnvironmentError
error = Maybe EnvironmentError
forall a. Maybe a
Prelude.Nothing
    }

-- | Environment variable key-value pairs.
environmentResponse_variables :: Lens.Lens' EnvironmentResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
environmentResponse_variables :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> EnvironmentResponse -> f EnvironmentResponse
environmentResponse_variables = (EnvironmentResponse
 -> Maybe (Sensitive (HashMap Text (Sensitive Text))))
-> (EnvironmentResponse
    -> Maybe (Sensitive (HashMap Text (Sensitive Text)))
    -> EnvironmentResponse)
-> Lens
     EnvironmentResponse
     EnvironmentResponse
     (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 (\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) ((Maybe (Sensitive (HashMap Text (Sensitive Text)))
  -> f (Maybe (Sensitive (HashMap Text (Sensitive Text)))))
 -> EnvironmentResponse -> f EnvironmentResponse)
-> ((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)))
-> EnvironmentResponse
-> f EnvironmentResponse
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)

-- | Error messages for environment variables that couldn\'t be applied.
environmentResponse_error :: Lens.Lens' EnvironmentResponse (Prelude.Maybe EnvironmentError)
environmentResponse_error :: (Maybe EnvironmentError -> f (Maybe EnvironmentError))
-> EnvironmentResponse -> f EnvironmentResponse
environmentResponse_error = (EnvironmentResponse -> Maybe EnvironmentError)
-> (EnvironmentResponse
    -> Maybe EnvironmentError -> EnvironmentResponse)
-> Lens
     EnvironmentResponse
     EnvironmentResponse
     (Maybe EnvironmentError)
     (Maybe EnvironmentError)
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)

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

instance Prelude.Hashable EnvironmentResponse

instance Prelude.NFData EnvironmentResponse