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

import qualified Amazonka.Core as Core
import Amazonka.IoTSiteWise.Types.ErrorCode
import qualified Amazonka.Lens as Lens
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
(ConfigurationErrorDetails -> ConfigurationErrorDetails -> Bool)
-> (ConfigurationErrorDetails -> ConfigurationErrorDetails -> Bool)
-> Eq ConfigurationErrorDetails
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]
(Int -> ReadS ConfigurationErrorDetails)
-> ReadS [ConfigurationErrorDetails]
-> ReadPrec ConfigurationErrorDetails
-> ReadPrec [ConfigurationErrorDetails]
-> Read 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
(Int -> ConfigurationErrorDetails -> ShowS)
-> (ConfigurationErrorDetails -> String)
-> ([ConfigurationErrorDetails] -> ShowS)
-> Show ConfigurationErrorDetails
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.
 ConfigurationErrorDetails -> Rep ConfigurationErrorDetails x)
-> (forall x.
    Rep ConfigurationErrorDetails x -> ConfigurationErrorDetails)
-> Generic ConfigurationErrorDetails
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' :: ErrorCode -> Text -> ConfigurationErrorDetails
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 :: (ErrorCode -> f ErrorCode)
-> ConfigurationErrorDetails -> f ConfigurationErrorDetails
configurationErrorDetails_code = (ConfigurationErrorDetails -> ErrorCode)
-> (ConfigurationErrorDetails
    -> ErrorCode -> ConfigurationErrorDetails)
-> Lens
     ConfigurationErrorDetails
     ConfigurationErrorDetails
     ErrorCode
     ErrorCode
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 :: (Text -> f Text)
-> ConfigurationErrorDetails -> f ConfigurationErrorDetails
configurationErrorDetails_message = (ConfigurationErrorDetails -> Text)
-> (ConfigurationErrorDetails -> Text -> ConfigurationErrorDetails)
-> Lens
     ConfigurationErrorDetails ConfigurationErrorDetails Text Text
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 Core.FromJSON ConfigurationErrorDetails where
  parseJSON :: Value -> Parser ConfigurationErrorDetails
parseJSON =
    String
-> (Object -> Parser ConfigurationErrorDetails)
-> Value
-> Parser ConfigurationErrorDetails
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ConfigurationErrorDetails"
      ( \Object
x ->
          ErrorCode -> Text -> ConfigurationErrorDetails
ConfigurationErrorDetails'
            (ErrorCode -> Text -> ConfigurationErrorDetails)
-> Parser ErrorCode -> Parser (Text -> ConfigurationErrorDetails)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser ErrorCode
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"code") Parser (Text -> ConfigurationErrorDetails)
-> Parser Text -> Parser ConfigurationErrorDetails
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 ConfigurationErrorDetails

instance Prelude.NFData ConfigurationErrorDetails