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

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

-- | Contains the details of an IoT SiteWise configuration error.
--
-- /See:/ 'newConfigurationErrorDetails' smart constructor.
data ConfigurationErrorDetails = ConfigurationErrorDetails'
  { -- | The error code.
    ConfigurationErrorDetails -> ErrorCode
code :: ErrorCode,
    -- | The error message.
    ConfigurationErrorDetails -> Text
message :: Prelude.Text
  }
  deriving (ConfigurationErrorDetails -> ConfigurationErrorDetails -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConfigurationErrorDetails -> ConfigurationErrorDetails -> Bool
$c/= :: ConfigurationErrorDetails -> ConfigurationErrorDetails -> Bool
== :: ConfigurationErrorDetails -> ConfigurationErrorDetails -> Bool
$c== :: ConfigurationErrorDetails -> ConfigurationErrorDetails -> Bool
Prelude.Eq, ReadPrec [ConfigurationErrorDetails]
ReadPrec ConfigurationErrorDetails
Int -> ReadS ConfigurationErrorDetails
ReadS [ConfigurationErrorDetails]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConfigurationErrorDetails]
$creadListPrec :: ReadPrec [ConfigurationErrorDetails]
readPrec :: ReadPrec ConfigurationErrorDetails
$creadPrec :: ReadPrec ConfigurationErrorDetails
readList :: ReadS [ConfigurationErrorDetails]
$creadList :: ReadS [ConfigurationErrorDetails]
readsPrec :: Int -> ReadS ConfigurationErrorDetails
$creadsPrec :: Int -> ReadS ConfigurationErrorDetails
Prelude.Read, Int -> ConfigurationErrorDetails -> ShowS
[ConfigurationErrorDetails] -> ShowS
ConfigurationErrorDetails -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConfigurationErrorDetails] -> ShowS
$cshowList :: [ConfigurationErrorDetails] -> ShowS
show :: ConfigurationErrorDetails -> String
$cshow :: ConfigurationErrorDetails -> String
showsPrec :: Int -> ConfigurationErrorDetails -> ShowS
$cshowsPrec :: Int -> ConfigurationErrorDetails -> ShowS
Prelude.Show, forall x.
Rep ConfigurationErrorDetails x -> ConfigurationErrorDetails
forall x.
ConfigurationErrorDetails -> Rep ConfigurationErrorDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ConfigurationErrorDetails x -> ConfigurationErrorDetails
$cfrom :: forall x.
ConfigurationErrorDetails -> Rep ConfigurationErrorDetails x
Prelude.Generic)

-- |
-- Create a value of 'ConfigurationErrorDetails' 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', 'configurationErrorDetails_code' - The error code.
--
-- 'message', 'configurationErrorDetails_message' - The error message.
newConfigurationErrorDetails ::
  -- | 'code'
  ErrorCode ->
  -- | 'message'
  Prelude.Text ->
  ConfigurationErrorDetails
newConfigurationErrorDetails :: ErrorCode -> Text -> ConfigurationErrorDetails
newConfigurationErrorDetails ErrorCode
pCode_ Text
pMessage_ =
  ConfigurationErrorDetails'
    { $sel:code:ConfigurationErrorDetails' :: ErrorCode
code = ErrorCode
pCode_,
      $sel:message:ConfigurationErrorDetails' :: Text
message = Text
pMessage_
    }

-- | The error code.
configurationErrorDetails_code :: Lens.Lens' ConfigurationErrorDetails ErrorCode
configurationErrorDetails_code :: Lens' ConfigurationErrorDetails ErrorCode
configurationErrorDetails_code = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigurationErrorDetails' {ErrorCode
code :: ErrorCode
$sel:code:ConfigurationErrorDetails' :: ConfigurationErrorDetails -> ErrorCode
code} -> ErrorCode
code) (\s :: ConfigurationErrorDetails
s@ConfigurationErrorDetails' {} ErrorCode
a -> ConfigurationErrorDetails
s {$sel:code:ConfigurationErrorDetails' :: ErrorCode
code = ErrorCode
a} :: ConfigurationErrorDetails)

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

instance Data.FromJSON ConfigurationErrorDetails where
  parseJSON :: Value -> Parser ConfigurationErrorDetails
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ConfigurationErrorDetails"
      ( \Object
x ->
          ErrorCode -> Text -> ConfigurationErrorDetails
ConfigurationErrorDetails'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser 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 a
Data..: Key
"message")
      )

instance Prelude.Hashable ConfigurationErrorDetails where
  hashWithSalt :: Int -> ConfigurationErrorDetails -> Int
hashWithSalt Int
_salt ConfigurationErrorDetails' {Text
ErrorCode
message :: Text
code :: ErrorCode
$sel:message:ConfigurationErrorDetails' :: ConfigurationErrorDetails -> Text
$sel:code:ConfigurationErrorDetails' :: ConfigurationErrorDetails -> ErrorCode
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ErrorCode
code
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
message

instance Prelude.NFData ConfigurationErrorDetails where
  rnf :: ConfigurationErrorDetails -> ()
rnf ConfigurationErrorDetails' {Text
ErrorCode
message :: Text
code :: ErrorCode
$sel:message:ConfigurationErrorDetails' :: ConfigurationErrorDetails -> Text
$sel:code:ConfigurationErrorDetails' :: ConfigurationErrorDetails -> ErrorCode
..} =
    forall a. NFData a => a -> ()
Prelude.rnf ErrorCode
code seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
message