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

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

-- | Error messages for environment variables that couldn\'t be applied.
--
-- /See:/ 'newEnvironmentError' smart constructor.
data EnvironmentError = EnvironmentError'
  { -- | The error code.
    EnvironmentError -> Maybe Text
errorCode :: Prelude.Maybe Prelude.Text,
    -- | The error message.
    EnvironmentError -> Maybe (Sensitive Text)
message :: Prelude.Maybe (Core.Sensitive Prelude.Text)
  }
  deriving (EnvironmentError -> EnvironmentError -> Bool
(EnvironmentError -> EnvironmentError -> Bool)
-> (EnvironmentError -> EnvironmentError -> Bool)
-> Eq EnvironmentError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnvironmentError -> EnvironmentError -> Bool
$c/= :: EnvironmentError -> EnvironmentError -> Bool
== :: EnvironmentError -> EnvironmentError -> Bool
$c== :: EnvironmentError -> EnvironmentError -> Bool
Prelude.Eq, Int -> EnvironmentError -> ShowS
[EnvironmentError] -> ShowS
EnvironmentError -> String
(Int -> EnvironmentError -> ShowS)
-> (EnvironmentError -> String)
-> ([EnvironmentError] -> ShowS)
-> Show EnvironmentError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnvironmentError] -> ShowS
$cshowList :: [EnvironmentError] -> ShowS
show :: EnvironmentError -> String
$cshow :: EnvironmentError -> String
showsPrec :: Int -> EnvironmentError -> ShowS
$cshowsPrec :: Int -> EnvironmentError -> ShowS
Prelude.Show, (forall x. EnvironmentError -> Rep EnvironmentError x)
-> (forall x. Rep EnvironmentError x -> EnvironmentError)
-> Generic EnvironmentError
forall x. Rep EnvironmentError x -> EnvironmentError
forall x. EnvironmentError -> Rep EnvironmentError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EnvironmentError x -> EnvironmentError
$cfrom :: forall x. EnvironmentError -> Rep EnvironmentError x
Prelude.Generic)

-- |
-- Create a value of 'EnvironmentError' 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:
--
-- 'errorCode', 'environmentError_errorCode' - The error code.
--
-- 'message', 'environmentError_message' - The error message.
newEnvironmentError ::
  EnvironmentError
newEnvironmentError :: EnvironmentError
newEnvironmentError =
  EnvironmentError' :: Maybe Text -> Maybe (Sensitive Text) -> EnvironmentError
EnvironmentError'
    { $sel:errorCode:EnvironmentError' :: Maybe Text
errorCode = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:message:EnvironmentError' :: Maybe (Sensitive Text)
message = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing
    }

-- | The error code.
environmentError_errorCode :: Lens.Lens' EnvironmentError (Prelude.Maybe Prelude.Text)
environmentError_errorCode :: (Maybe Text -> f (Maybe Text))
-> EnvironmentError -> f EnvironmentError
environmentError_errorCode = (EnvironmentError -> Maybe Text)
-> (EnvironmentError -> Maybe Text -> EnvironmentError)
-> Lens EnvironmentError EnvironmentError (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnvironmentError' {Maybe Text
errorCode :: Maybe Text
$sel:errorCode:EnvironmentError' :: EnvironmentError -> Maybe Text
errorCode} -> Maybe Text
errorCode) (\s :: EnvironmentError
s@EnvironmentError' {} Maybe Text
a -> EnvironmentError
s {$sel:errorCode:EnvironmentError' :: Maybe Text
errorCode = Maybe Text
a} :: EnvironmentError)

-- | The error message.
environmentError_message :: Lens.Lens' EnvironmentError (Prelude.Maybe Prelude.Text)
environmentError_message :: (Maybe Text -> f (Maybe Text))
-> EnvironmentError -> f EnvironmentError
environmentError_message = (EnvironmentError -> Maybe (Sensitive Text))
-> (EnvironmentError -> Maybe (Sensitive Text) -> EnvironmentError)
-> Lens
     EnvironmentError
     EnvironmentError
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnvironmentError' {Maybe (Sensitive Text)
message :: Maybe (Sensitive Text)
$sel:message:EnvironmentError' :: EnvironmentError -> Maybe (Sensitive Text)
message} -> Maybe (Sensitive Text)
message) (\s :: EnvironmentError
s@EnvironmentError' {} Maybe (Sensitive Text)
a -> EnvironmentError
s {$sel:message:EnvironmentError' :: Maybe (Sensitive Text)
message = Maybe (Sensitive Text)
a} :: EnvironmentError) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> EnvironmentError -> f EnvironmentError)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> EnvironmentError
-> f EnvironmentError
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe 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 (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

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

instance Prelude.Hashable EnvironmentError

instance Prelude.NFData EnvironmentError