{-# 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.MigrationHubReFactorSpaces.Types.ErrorResponse
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MigrationHubReFactorSpaces.Types.ErrorResponse where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MigrationHubReFactorSpaces.Types.ErrorCode
import Amazonka.MigrationHubReFactorSpaces.Types.ErrorResourceType
import qualified Amazonka.Prelude as Prelude

-- | Error associated with a resource returned for a Get or List resource
-- response.
--
-- /See:/ 'newErrorResponse' smart constructor.
data ErrorResponse = ErrorResponse'
  { -- | The Amazon Web Services account ID of the resource owner.
    ErrorResponse -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text,
    -- | Additional details about the error.
    ErrorResponse -> Maybe (HashMap Text Text)
additionalDetails :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The error code associated with the error.
    ErrorResponse -> Maybe ErrorCode
code :: Prelude.Maybe ErrorCode,
    -- | The message associated with the error.
    ErrorResponse -> Maybe Text
message :: Prelude.Maybe Prelude.Text,
    -- | The ID of the resource.
    ErrorResponse -> Maybe Text
resourceIdentifier :: Prelude.Maybe Prelude.Text,
    -- | The type of resource.
    ErrorResponse -> Maybe ErrorResourceType
resourceType :: Prelude.Maybe ErrorResourceType
  }
  deriving (ErrorResponse -> ErrorResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ErrorResponse -> ErrorResponse -> Bool
$c/= :: ErrorResponse -> ErrorResponse -> Bool
== :: ErrorResponse -> ErrorResponse -> Bool
$c== :: ErrorResponse -> ErrorResponse -> Bool
Prelude.Eq, ReadPrec [ErrorResponse]
ReadPrec ErrorResponse
Int -> ReadS ErrorResponse
ReadS [ErrorResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ErrorResponse]
$creadListPrec :: ReadPrec [ErrorResponse]
readPrec :: ReadPrec ErrorResponse
$creadPrec :: ReadPrec ErrorResponse
readList :: ReadS [ErrorResponse]
$creadList :: ReadS [ErrorResponse]
readsPrec :: Int -> ReadS ErrorResponse
$creadsPrec :: Int -> ReadS ErrorResponse
Prelude.Read, Int -> ErrorResponse -> ShowS
[ErrorResponse] -> ShowS
ErrorResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ErrorResponse] -> ShowS
$cshowList :: [ErrorResponse] -> ShowS
show :: ErrorResponse -> String
$cshow :: ErrorResponse -> String
showsPrec :: Int -> ErrorResponse -> ShowS
$cshowsPrec :: Int -> ErrorResponse -> ShowS
Prelude.Show, forall x. Rep ErrorResponse x -> ErrorResponse
forall x. ErrorResponse -> Rep ErrorResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ErrorResponse x -> ErrorResponse
$cfrom :: forall x. ErrorResponse -> Rep ErrorResponse x
Prelude.Generic)

-- |
-- Create a value of 'ErrorResponse' 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:
--
-- 'accountId', 'errorResponse_accountId' - The Amazon Web Services account ID of the resource owner.
--
-- 'additionalDetails', 'errorResponse_additionalDetails' - Additional details about the error.
--
-- 'code', 'errorResponse_code' - The error code associated with the error.
--
-- 'message', 'errorResponse_message' - The message associated with the error.
--
-- 'resourceIdentifier', 'errorResponse_resourceIdentifier' - The ID of the resource.
--
-- 'resourceType', 'errorResponse_resourceType' - The type of resource.
newErrorResponse ::
  ErrorResponse
newErrorResponse :: ErrorResponse
newErrorResponse =
  ErrorResponse'
    { $sel:accountId:ErrorResponse' :: Maybe Text
accountId = forall a. Maybe a
Prelude.Nothing,
      $sel:additionalDetails:ErrorResponse' :: Maybe (HashMap Text Text)
additionalDetails = forall a. Maybe a
Prelude.Nothing,
      $sel:code:ErrorResponse' :: Maybe ErrorCode
code = forall a. Maybe a
Prelude.Nothing,
      $sel:message:ErrorResponse' :: Maybe Text
message = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceIdentifier:ErrorResponse' :: Maybe Text
resourceIdentifier = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceType:ErrorResponse' :: Maybe ErrorResourceType
resourceType = forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Web Services account ID of the resource owner.
errorResponse_accountId :: Lens.Lens' ErrorResponse (Prelude.Maybe Prelude.Text)
errorResponse_accountId :: Lens' ErrorResponse (Maybe Text)
errorResponse_accountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ErrorResponse' {Maybe Text
accountId :: Maybe Text
$sel:accountId:ErrorResponse' :: ErrorResponse -> Maybe Text
accountId} -> Maybe Text
accountId) (\s :: ErrorResponse
s@ErrorResponse' {} Maybe Text
a -> ErrorResponse
s {$sel:accountId:ErrorResponse' :: Maybe Text
accountId = Maybe Text
a} :: ErrorResponse)

-- | Additional details about the error.
errorResponse_additionalDetails :: Lens.Lens' ErrorResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
errorResponse_additionalDetails :: Lens' ErrorResponse (Maybe (HashMap Text Text))
errorResponse_additionalDetails = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ErrorResponse' {Maybe (HashMap Text Text)
additionalDetails :: Maybe (HashMap Text Text)
$sel:additionalDetails:ErrorResponse' :: ErrorResponse -> Maybe (HashMap Text Text)
additionalDetails} -> Maybe (HashMap Text Text)
additionalDetails) (\s :: ErrorResponse
s@ErrorResponse' {} Maybe (HashMap Text Text)
a -> ErrorResponse
s {$sel:additionalDetails:ErrorResponse' :: Maybe (HashMap Text Text)
additionalDetails = Maybe (HashMap Text Text)
a} :: ErrorResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The error code associated with the error.
errorResponse_code :: Lens.Lens' ErrorResponse (Prelude.Maybe ErrorCode)
errorResponse_code :: Lens' ErrorResponse (Maybe ErrorCode)
errorResponse_code = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ErrorResponse' {Maybe ErrorCode
code :: Maybe ErrorCode
$sel:code:ErrorResponse' :: ErrorResponse -> Maybe ErrorCode
code} -> Maybe ErrorCode
code) (\s :: ErrorResponse
s@ErrorResponse' {} Maybe ErrorCode
a -> ErrorResponse
s {$sel:code:ErrorResponse' :: Maybe ErrorCode
code = Maybe ErrorCode
a} :: ErrorResponse)

-- | The message associated with the error.
errorResponse_message :: Lens.Lens' ErrorResponse (Prelude.Maybe Prelude.Text)
errorResponse_message :: Lens' ErrorResponse (Maybe Text)
errorResponse_message = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ErrorResponse' {Maybe Text
message :: Maybe Text
$sel:message:ErrorResponse' :: ErrorResponse -> Maybe Text
message} -> Maybe Text
message) (\s :: ErrorResponse
s@ErrorResponse' {} Maybe Text
a -> ErrorResponse
s {$sel:message:ErrorResponse' :: Maybe Text
message = Maybe Text
a} :: ErrorResponse)

-- | The ID of the resource.
errorResponse_resourceIdentifier :: Lens.Lens' ErrorResponse (Prelude.Maybe Prelude.Text)
errorResponse_resourceIdentifier :: Lens' ErrorResponse (Maybe Text)
errorResponse_resourceIdentifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ErrorResponse' {Maybe Text
resourceIdentifier :: Maybe Text
$sel:resourceIdentifier:ErrorResponse' :: ErrorResponse -> Maybe Text
resourceIdentifier} -> Maybe Text
resourceIdentifier) (\s :: ErrorResponse
s@ErrorResponse' {} Maybe Text
a -> ErrorResponse
s {$sel:resourceIdentifier:ErrorResponse' :: Maybe Text
resourceIdentifier = Maybe Text
a} :: ErrorResponse)

-- | The type of resource.
errorResponse_resourceType :: Lens.Lens' ErrorResponse (Prelude.Maybe ErrorResourceType)
errorResponse_resourceType :: Lens' ErrorResponse (Maybe ErrorResourceType)
errorResponse_resourceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ErrorResponse' {Maybe ErrorResourceType
resourceType :: Maybe ErrorResourceType
$sel:resourceType:ErrorResponse' :: ErrorResponse -> Maybe ErrorResourceType
resourceType} -> Maybe ErrorResourceType
resourceType) (\s :: ErrorResponse
s@ErrorResponse' {} Maybe ErrorResourceType
a -> ErrorResponse
s {$sel:resourceType:ErrorResponse' :: Maybe ErrorResourceType
resourceType = Maybe ErrorResourceType
a} :: ErrorResponse)

instance Data.FromJSON ErrorResponse where
  parseJSON :: Value -> Parser ErrorResponse
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ErrorResponse"
      ( \Object
x ->
          Maybe Text
-> Maybe (HashMap Text Text)
-> Maybe ErrorCode
-> Maybe Text
-> Maybe Text
-> Maybe ErrorResourceType
-> ErrorResponse
ErrorResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"AccountId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"AdditionalDetails"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Code")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Message")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ResourceIdentifier")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ResourceType")
      )

instance Prelude.Hashable ErrorResponse where
  hashWithSalt :: Int -> ErrorResponse -> Int
hashWithSalt Int
_salt ErrorResponse' {Maybe Text
Maybe (HashMap Text Text)
Maybe ErrorCode
Maybe ErrorResourceType
resourceType :: Maybe ErrorResourceType
resourceIdentifier :: Maybe Text
message :: Maybe Text
code :: Maybe ErrorCode
additionalDetails :: Maybe (HashMap Text Text)
accountId :: Maybe Text
$sel:resourceType:ErrorResponse' :: ErrorResponse -> Maybe ErrorResourceType
$sel:resourceIdentifier:ErrorResponse' :: ErrorResponse -> Maybe Text
$sel:message:ErrorResponse' :: ErrorResponse -> Maybe Text
$sel:code:ErrorResponse' :: ErrorResponse -> Maybe ErrorCode
$sel:additionalDetails:ErrorResponse' :: ErrorResponse -> Maybe (HashMap Text Text)
$sel:accountId:ErrorResponse' :: ErrorResponse -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
accountId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
additionalDetails
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ErrorCode
code
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
message
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resourceIdentifier
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ErrorResourceType
resourceType

instance Prelude.NFData ErrorResponse where
  rnf :: ErrorResponse -> ()
rnf ErrorResponse' {Maybe Text
Maybe (HashMap Text Text)
Maybe ErrorCode
Maybe ErrorResourceType
resourceType :: Maybe ErrorResourceType
resourceIdentifier :: Maybe Text
message :: Maybe Text
code :: Maybe ErrorCode
additionalDetails :: Maybe (HashMap Text Text)
accountId :: Maybe Text
$sel:resourceType:ErrorResponse' :: ErrorResponse -> Maybe ErrorResourceType
$sel:resourceIdentifier:ErrorResponse' :: ErrorResponse -> Maybe Text
$sel:message:ErrorResponse' :: ErrorResponse -> Maybe Text
$sel:code:ErrorResponse' :: ErrorResponse -> Maybe ErrorCode
$sel:additionalDetails:ErrorResponse' :: ErrorResponse -> Maybe (HashMap Text Text)
$sel:accountId:ErrorResponse' :: ErrorResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
accountId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
additionalDetails
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ErrorCode
code
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
message
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceIdentifier
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ErrorResourceType
resourceType