{-# 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.IAM.Types.ErrorDetails
-- 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.IAM.Types.ErrorDetails where

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

-- | Contains information about the reason that the operation failed.
--
-- This data type is used as a response element in the
-- GetOrganizationsAccessReport, GetServiceLastAccessedDetails, and
-- GetServiceLastAccessedDetailsWithEntities operations.
--
-- /See:/ 'newErrorDetails' smart constructor.
data ErrorDetails = ErrorDetails'
  { -- | Detailed information about the reason that the operation failed.
    ErrorDetails -> Text
message :: Prelude.Text,
    -- | The error code associated with the operation failure.
    ErrorDetails -> Text
code :: Prelude.Text
  }
  deriving (ErrorDetails -> ErrorDetails -> Bool
(ErrorDetails -> ErrorDetails -> Bool)
-> (ErrorDetails -> ErrorDetails -> Bool) -> Eq ErrorDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ErrorDetails -> ErrorDetails -> Bool
$c/= :: ErrorDetails -> ErrorDetails -> Bool
== :: ErrorDetails -> ErrorDetails -> Bool
$c== :: ErrorDetails -> ErrorDetails -> Bool
Prelude.Eq, ReadPrec [ErrorDetails]
ReadPrec ErrorDetails
Int -> ReadS ErrorDetails
ReadS [ErrorDetails]
(Int -> ReadS ErrorDetails)
-> ReadS [ErrorDetails]
-> ReadPrec ErrorDetails
-> ReadPrec [ErrorDetails]
-> Read ErrorDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ErrorDetails]
$creadListPrec :: ReadPrec [ErrorDetails]
readPrec :: ReadPrec ErrorDetails
$creadPrec :: ReadPrec ErrorDetails
readList :: ReadS [ErrorDetails]
$creadList :: ReadS [ErrorDetails]
readsPrec :: Int -> ReadS ErrorDetails
$creadsPrec :: Int -> ReadS ErrorDetails
Prelude.Read, Int -> ErrorDetails -> ShowS
[ErrorDetails] -> ShowS
ErrorDetails -> String
(Int -> ErrorDetails -> ShowS)
-> (ErrorDetails -> String)
-> ([ErrorDetails] -> ShowS)
-> Show ErrorDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ErrorDetails] -> ShowS
$cshowList :: [ErrorDetails] -> ShowS
show :: ErrorDetails -> String
$cshow :: ErrorDetails -> String
showsPrec :: Int -> ErrorDetails -> ShowS
$cshowsPrec :: Int -> ErrorDetails -> ShowS
Prelude.Show, (forall x. ErrorDetails -> Rep ErrorDetails x)
-> (forall x. Rep ErrorDetails x -> ErrorDetails)
-> Generic ErrorDetails
forall x. Rep ErrorDetails x -> ErrorDetails
forall x. ErrorDetails -> Rep ErrorDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ErrorDetails x -> ErrorDetails
$cfrom :: forall x. ErrorDetails -> Rep ErrorDetails x
Prelude.Generic)

-- |
-- Create a value of 'ErrorDetails' 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:
--
-- 'message', 'errorDetails_message' - Detailed information about the reason that the operation failed.
--
-- 'code', 'errorDetails_code' - The error code associated with the operation failure.
newErrorDetails ::
  -- | 'message'
  Prelude.Text ->
  -- | 'code'
  Prelude.Text ->
  ErrorDetails
newErrorDetails :: Text -> Text -> ErrorDetails
newErrorDetails Text
pMessage_ Text
pCode_ =
  ErrorDetails' :: Text -> Text -> ErrorDetails
ErrorDetails' {$sel:message:ErrorDetails' :: Text
message = Text
pMessage_, $sel:code:ErrorDetails' :: Text
code = Text
pCode_}

-- | Detailed information about the reason that the operation failed.
errorDetails_message :: Lens.Lens' ErrorDetails Prelude.Text
errorDetails_message :: (Text -> f Text) -> ErrorDetails -> f ErrorDetails
errorDetails_message = (ErrorDetails -> Text)
-> (ErrorDetails -> Text -> ErrorDetails)
-> Lens ErrorDetails ErrorDetails Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ErrorDetails' {Text
message :: Text
$sel:message:ErrorDetails' :: ErrorDetails -> Text
message} -> Text
message) (\s :: ErrorDetails
s@ErrorDetails' {} Text
a -> ErrorDetails
s {$sel:message:ErrorDetails' :: Text
message = Text
a} :: ErrorDetails)

-- | The error code associated with the operation failure.
errorDetails_code :: Lens.Lens' ErrorDetails Prelude.Text
errorDetails_code :: (Text -> f Text) -> ErrorDetails -> f ErrorDetails
errorDetails_code = (ErrorDetails -> Text)
-> (ErrorDetails -> Text -> ErrorDetails)
-> Lens ErrorDetails ErrorDetails Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ErrorDetails' {Text
code :: Text
$sel:code:ErrorDetails' :: ErrorDetails -> Text
code} -> Text
code) (\s :: ErrorDetails
s@ErrorDetails' {} Text
a -> ErrorDetails
s {$sel:code:ErrorDetails' :: Text
code = Text
a} :: ErrorDetails)

instance Core.FromXML ErrorDetails where
  parseXML :: [Node] -> Either String ErrorDetails
parseXML [Node]
x =
    Text -> Text -> ErrorDetails
ErrorDetails'
      (Text -> Text -> ErrorDetails)
-> Either String Text -> Either String (Text -> ErrorDetails)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Message") Either String (Text -> ErrorDetails)
-> Either String Text -> Either String ErrorDetails
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Code")

instance Prelude.Hashable ErrorDetails

instance Prelude.NFData ErrorDetails