{-# 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.ServiceCatalog.Types.RecordError
-- 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.ServiceCatalog.Types.RecordError where

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

-- | The error code and description resulting from an operation.
--
-- /See:/ 'newRecordError' smart constructor.
data RecordError = RecordError'
  { -- | The numeric value of the error.
    RecordError -> Maybe Text
code :: Prelude.Maybe Prelude.Text,
    -- | The description of the error.
    RecordError -> Maybe Text
description :: Prelude.Maybe Prelude.Text
  }
  deriving (RecordError -> RecordError -> Bool
(RecordError -> RecordError -> Bool)
-> (RecordError -> RecordError -> Bool) -> Eq RecordError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RecordError -> RecordError -> Bool
$c/= :: RecordError -> RecordError -> Bool
== :: RecordError -> RecordError -> Bool
$c== :: RecordError -> RecordError -> Bool
Prelude.Eq, ReadPrec [RecordError]
ReadPrec RecordError
Int -> ReadS RecordError
ReadS [RecordError]
(Int -> ReadS RecordError)
-> ReadS [RecordError]
-> ReadPrec RecordError
-> ReadPrec [RecordError]
-> Read RecordError
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RecordError]
$creadListPrec :: ReadPrec [RecordError]
readPrec :: ReadPrec RecordError
$creadPrec :: ReadPrec RecordError
readList :: ReadS [RecordError]
$creadList :: ReadS [RecordError]
readsPrec :: Int -> ReadS RecordError
$creadsPrec :: Int -> ReadS RecordError
Prelude.Read, Int -> RecordError -> ShowS
[RecordError] -> ShowS
RecordError -> String
(Int -> RecordError -> ShowS)
-> (RecordError -> String)
-> ([RecordError] -> ShowS)
-> Show RecordError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RecordError] -> ShowS
$cshowList :: [RecordError] -> ShowS
show :: RecordError -> String
$cshow :: RecordError -> String
showsPrec :: Int -> RecordError -> ShowS
$cshowsPrec :: Int -> RecordError -> ShowS
Prelude.Show, (forall x. RecordError -> Rep RecordError x)
-> (forall x. Rep RecordError x -> RecordError)
-> Generic RecordError
forall x. Rep RecordError x -> RecordError
forall x. RecordError -> Rep RecordError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RecordError x -> RecordError
$cfrom :: forall x. RecordError -> Rep RecordError x
Prelude.Generic)

-- |
-- Create a value of 'RecordError' 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:
--
-- 'code', 'recordError_code' - The numeric value of the error.
--
-- 'description', 'recordError_description' - The description of the error.
newRecordError ::
  RecordError
newRecordError :: RecordError
newRecordError =
  RecordError' :: Maybe Text -> Maybe Text -> RecordError
RecordError'
    { $sel:code:RecordError' :: Maybe Text
code = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:description:RecordError' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The numeric value of the error.
recordError_code :: Lens.Lens' RecordError (Prelude.Maybe Prelude.Text)
recordError_code :: (Maybe Text -> f (Maybe Text)) -> RecordError -> f RecordError
recordError_code = (RecordError -> Maybe Text)
-> (RecordError -> Maybe Text -> RecordError)
-> Lens RecordError RecordError (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecordError' {Maybe Text
code :: Maybe Text
$sel:code:RecordError' :: RecordError -> Maybe Text
code} -> Maybe Text
code) (\s :: RecordError
s@RecordError' {} Maybe Text
a -> RecordError
s {$sel:code:RecordError' :: Maybe Text
code = Maybe Text
a} :: RecordError)

-- | The description of the error.
recordError_description :: Lens.Lens' RecordError (Prelude.Maybe Prelude.Text)
recordError_description :: (Maybe Text -> f (Maybe Text)) -> RecordError -> f RecordError
recordError_description = (RecordError -> Maybe Text)
-> (RecordError -> Maybe Text -> RecordError)
-> Lens RecordError RecordError (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecordError' {Maybe Text
description :: Maybe Text
$sel:description:RecordError' :: RecordError -> Maybe Text
description} -> Maybe Text
description) (\s :: RecordError
s@RecordError' {} Maybe Text
a -> RecordError
s {$sel:description:RecordError' :: Maybe Text
description = Maybe Text
a} :: RecordError)

instance Core.FromJSON RecordError where
  parseJSON :: Value -> Parser RecordError
parseJSON =
    String
-> (Object -> Parser RecordError) -> Value -> Parser RecordError
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RecordError"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> RecordError
RecordError'
            (Maybe Text -> Maybe Text -> RecordError)
-> Parser (Maybe Text) -> Parser (Maybe Text -> RecordError)
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
"Code")
            Parser (Maybe Text -> RecordError)
-> Parser (Maybe Text) -> Parser RecordError
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
"Description")
      )

instance Prelude.Hashable RecordError

instance Prelude.NFData RecordError