{-# 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.MwAA.Types.UpdateError
-- 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.MwAA.Types.UpdateError where

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

-- | An object containing the error encountered with the last update:
-- @ErrorCode@, @ErrorMessage@.
--
-- /See:/ 'newUpdateError' smart constructor.
data UpdateError = UpdateError'
  { -- | The error code that corresponds to the error with the last update.
    UpdateError -> Maybe Text
errorCode :: Prelude.Maybe Prelude.Text,
    -- | The error message that corresponds to the error code.
    UpdateError -> Maybe Text
errorMessage :: Prelude.Maybe Prelude.Text
  }
  deriving (UpdateError -> UpdateError -> Bool
(UpdateError -> UpdateError -> Bool)
-> (UpdateError -> UpdateError -> Bool) -> Eq UpdateError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateError -> UpdateError -> Bool
$c/= :: UpdateError -> UpdateError -> Bool
== :: UpdateError -> UpdateError -> Bool
$c== :: UpdateError -> UpdateError -> Bool
Prelude.Eq, ReadPrec [UpdateError]
ReadPrec UpdateError
Int -> ReadS UpdateError
ReadS [UpdateError]
(Int -> ReadS UpdateError)
-> ReadS [UpdateError]
-> ReadPrec UpdateError
-> ReadPrec [UpdateError]
-> Read UpdateError
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateError]
$creadListPrec :: ReadPrec [UpdateError]
readPrec :: ReadPrec UpdateError
$creadPrec :: ReadPrec UpdateError
readList :: ReadS [UpdateError]
$creadList :: ReadS [UpdateError]
readsPrec :: Int -> ReadS UpdateError
$creadsPrec :: Int -> ReadS UpdateError
Prelude.Read, Int -> UpdateError -> ShowS
[UpdateError] -> ShowS
UpdateError -> String
(Int -> UpdateError -> ShowS)
-> (UpdateError -> String)
-> ([UpdateError] -> ShowS)
-> Show UpdateError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateError] -> ShowS
$cshowList :: [UpdateError] -> ShowS
show :: UpdateError -> String
$cshow :: UpdateError -> String
showsPrec :: Int -> UpdateError -> ShowS
$cshowsPrec :: Int -> UpdateError -> ShowS
Prelude.Show, (forall x. UpdateError -> Rep UpdateError x)
-> (forall x. Rep UpdateError x -> UpdateError)
-> Generic UpdateError
forall x. Rep UpdateError x -> UpdateError
forall x. UpdateError -> Rep UpdateError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateError x -> UpdateError
$cfrom :: forall x. UpdateError -> Rep UpdateError x
Prelude.Generic)

-- |
-- Create a value of 'UpdateError' 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', 'updateError_errorCode' - The error code that corresponds to the error with the last update.
--
-- 'errorMessage', 'updateError_errorMessage' - The error message that corresponds to the error code.
newUpdateError ::
  UpdateError
newUpdateError :: UpdateError
newUpdateError =
  UpdateError' :: Maybe Text -> Maybe Text -> UpdateError
UpdateError'
    { $sel:errorCode:UpdateError' :: Maybe Text
errorCode = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:errorMessage:UpdateError' :: Maybe Text
errorMessage = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The error code that corresponds to the error with the last update.
updateError_errorCode :: Lens.Lens' UpdateError (Prelude.Maybe Prelude.Text)
updateError_errorCode :: (Maybe Text -> f (Maybe Text)) -> UpdateError -> f UpdateError
updateError_errorCode = (UpdateError -> Maybe Text)
-> (UpdateError -> Maybe Text -> UpdateError)
-> Lens UpdateError UpdateError (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateError' {Maybe Text
errorCode :: Maybe Text
$sel:errorCode:UpdateError' :: UpdateError -> Maybe Text
errorCode} -> Maybe Text
errorCode) (\s :: UpdateError
s@UpdateError' {} Maybe Text
a -> UpdateError
s {$sel:errorCode:UpdateError' :: Maybe Text
errorCode = Maybe Text
a} :: UpdateError)

-- | The error message that corresponds to the error code.
updateError_errorMessage :: Lens.Lens' UpdateError (Prelude.Maybe Prelude.Text)
updateError_errorMessage :: (Maybe Text -> f (Maybe Text)) -> UpdateError -> f UpdateError
updateError_errorMessage = (UpdateError -> Maybe Text)
-> (UpdateError -> Maybe Text -> UpdateError)
-> Lens UpdateError UpdateError (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateError' {Maybe Text
errorMessage :: Maybe Text
$sel:errorMessage:UpdateError' :: UpdateError -> Maybe Text
errorMessage} -> Maybe Text
errorMessage) (\s :: UpdateError
s@UpdateError' {} Maybe Text
a -> UpdateError
s {$sel:errorMessage:UpdateError' :: Maybe Text
errorMessage = Maybe Text
a} :: UpdateError)

instance Core.FromJSON UpdateError where
  parseJSON :: Value -> Parser UpdateError
parseJSON =
    String
-> (Object -> Parser UpdateError) -> Value -> Parser UpdateError
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"UpdateError"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> UpdateError
UpdateError'
            (Maybe Text -> Maybe Text -> UpdateError)
-> Parser (Maybe Text) -> Parser (Maybe Text -> UpdateError)
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 Text -> UpdateError)
-> Parser (Maybe Text) -> Parser UpdateError
forall (f :: * -> *) a b. Applicative f => 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
"ErrorMessage")
      )

instance Prelude.Hashable UpdateError

instance Prelude.NFData UpdateError