{-# 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.IoTSiteWise.Types.AssetErrorDetails
-- 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.IoTSiteWise.Types.AssetErrorDetails where

import qualified Amazonka.Core as Core
import Amazonka.IoTSiteWise.Types.AssetErrorCode
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains error details for the requested associate project asset action.
--
-- /See:/ 'newAssetErrorDetails' smart constructor.
data AssetErrorDetails = AssetErrorDetails'
  { -- | The ID of the asset.
    AssetErrorDetails -> Text
assetId :: Prelude.Text,
    -- | The error code.
    AssetErrorDetails -> AssetErrorCode
code :: AssetErrorCode,
    -- | The error message.
    AssetErrorDetails -> Text
message :: Prelude.Text
  }
  deriving (AssetErrorDetails -> AssetErrorDetails -> Bool
(AssetErrorDetails -> AssetErrorDetails -> Bool)
-> (AssetErrorDetails -> AssetErrorDetails -> Bool)
-> Eq AssetErrorDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssetErrorDetails -> AssetErrorDetails -> Bool
$c/= :: AssetErrorDetails -> AssetErrorDetails -> Bool
== :: AssetErrorDetails -> AssetErrorDetails -> Bool
$c== :: AssetErrorDetails -> AssetErrorDetails -> Bool
Prelude.Eq, ReadPrec [AssetErrorDetails]
ReadPrec AssetErrorDetails
Int -> ReadS AssetErrorDetails
ReadS [AssetErrorDetails]
(Int -> ReadS AssetErrorDetails)
-> ReadS [AssetErrorDetails]
-> ReadPrec AssetErrorDetails
-> ReadPrec [AssetErrorDetails]
-> Read AssetErrorDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssetErrorDetails]
$creadListPrec :: ReadPrec [AssetErrorDetails]
readPrec :: ReadPrec AssetErrorDetails
$creadPrec :: ReadPrec AssetErrorDetails
readList :: ReadS [AssetErrorDetails]
$creadList :: ReadS [AssetErrorDetails]
readsPrec :: Int -> ReadS AssetErrorDetails
$creadsPrec :: Int -> ReadS AssetErrorDetails
Prelude.Read, Int -> AssetErrorDetails -> ShowS
[AssetErrorDetails] -> ShowS
AssetErrorDetails -> String
(Int -> AssetErrorDetails -> ShowS)
-> (AssetErrorDetails -> String)
-> ([AssetErrorDetails] -> ShowS)
-> Show AssetErrorDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssetErrorDetails] -> ShowS
$cshowList :: [AssetErrorDetails] -> ShowS
show :: AssetErrorDetails -> String
$cshow :: AssetErrorDetails -> String
showsPrec :: Int -> AssetErrorDetails -> ShowS
$cshowsPrec :: Int -> AssetErrorDetails -> ShowS
Prelude.Show, (forall x. AssetErrorDetails -> Rep AssetErrorDetails x)
-> (forall x. Rep AssetErrorDetails x -> AssetErrorDetails)
-> Generic AssetErrorDetails
forall x. Rep AssetErrorDetails x -> AssetErrorDetails
forall x. AssetErrorDetails -> Rep AssetErrorDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssetErrorDetails x -> AssetErrorDetails
$cfrom :: forall x. AssetErrorDetails -> Rep AssetErrorDetails x
Prelude.Generic)

-- |
-- Create a value of 'AssetErrorDetails' 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:
--
-- 'assetId', 'assetErrorDetails_assetId' - The ID of the asset.
--
-- 'code', 'assetErrorDetails_code' - The error code.
--
-- 'message', 'assetErrorDetails_message' - The error message.
newAssetErrorDetails ::
  -- | 'assetId'
  Prelude.Text ->
  -- | 'code'
  AssetErrorCode ->
  -- | 'message'
  Prelude.Text ->
  AssetErrorDetails
newAssetErrorDetails :: Text -> AssetErrorCode -> Text -> AssetErrorDetails
newAssetErrorDetails Text
pAssetId_ AssetErrorCode
pCode_ Text
pMessage_ =
  AssetErrorDetails' :: Text -> AssetErrorCode -> Text -> AssetErrorDetails
AssetErrorDetails'
    { $sel:assetId:AssetErrorDetails' :: Text
assetId = Text
pAssetId_,
      $sel:code:AssetErrorDetails' :: AssetErrorCode
code = AssetErrorCode
pCode_,
      $sel:message:AssetErrorDetails' :: Text
message = Text
pMessage_
    }

-- | The ID of the asset.
assetErrorDetails_assetId :: Lens.Lens' AssetErrorDetails Prelude.Text
assetErrorDetails_assetId :: (Text -> f Text) -> AssetErrorDetails -> f AssetErrorDetails
assetErrorDetails_assetId = (AssetErrorDetails -> Text)
-> (AssetErrorDetails -> Text -> AssetErrorDetails)
-> Lens AssetErrorDetails AssetErrorDetails Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetErrorDetails' {Text
assetId :: Text
$sel:assetId:AssetErrorDetails' :: AssetErrorDetails -> Text
assetId} -> Text
assetId) (\s :: AssetErrorDetails
s@AssetErrorDetails' {} Text
a -> AssetErrorDetails
s {$sel:assetId:AssetErrorDetails' :: Text
assetId = Text
a} :: AssetErrorDetails)

-- | The error code.
assetErrorDetails_code :: Lens.Lens' AssetErrorDetails AssetErrorCode
assetErrorDetails_code :: (AssetErrorCode -> f AssetErrorCode)
-> AssetErrorDetails -> f AssetErrorDetails
assetErrorDetails_code = (AssetErrorDetails -> AssetErrorCode)
-> (AssetErrorDetails -> AssetErrorCode -> AssetErrorDetails)
-> Lens
     AssetErrorDetails AssetErrorDetails AssetErrorCode AssetErrorCode
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetErrorDetails' {AssetErrorCode
code :: AssetErrorCode
$sel:code:AssetErrorDetails' :: AssetErrorDetails -> AssetErrorCode
code} -> AssetErrorCode
code) (\s :: AssetErrorDetails
s@AssetErrorDetails' {} AssetErrorCode
a -> AssetErrorDetails
s {$sel:code:AssetErrorDetails' :: AssetErrorCode
code = AssetErrorCode
a} :: AssetErrorDetails)

-- | The error message.
assetErrorDetails_message :: Lens.Lens' AssetErrorDetails Prelude.Text
assetErrorDetails_message :: (Text -> f Text) -> AssetErrorDetails -> f AssetErrorDetails
assetErrorDetails_message = (AssetErrorDetails -> Text)
-> (AssetErrorDetails -> Text -> AssetErrorDetails)
-> Lens AssetErrorDetails AssetErrorDetails Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetErrorDetails' {Text
message :: Text
$sel:message:AssetErrorDetails' :: AssetErrorDetails -> Text
message} -> Text
message) (\s :: AssetErrorDetails
s@AssetErrorDetails' {} Text
a -> AssetErrorDetails
s {$sel:message:AssetErrorDetails' :: Text
message = Text
a} :: AssetErrorDetails)

instance Core.FromJSON AssetErrorDetails where
  parseJSON :: Value -> Parser AssetErrorDetails
parseJSON =
    String
-> (Object -> Parser AssetErrorDetails)
-> Value
-> Parser AssetErrorDetails
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AssetErrorDetails"
      ( \Object
x ->
          Text -> AssetErrorCode -> Text -> AssetErrorDetails
AssetErrorDetails'
            (Text -> AssetErrorCode -> Text -> AssetErrorDetails)
-> Parser Text
-> Parser (AssetErrorCode -> Text -> AssetErrorDetails)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"assetId")
            Parser (AssetErrorCode -> Text -> AssetErrorDetails)
-> Parser AssetErrorCode -> Parser (Text -> AssetErrorDetails)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser AssetErrorCode
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"code")
            Parser (Text -> AssetErrorDetails)
-> Parser Text -> Parser AssetErrorDetails
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"message")
      )

instance Prelude.Hashable AssetErrorDetails

instance Prelude.NFData AssetErrorDetails