{-# 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.MonitorErrorDetails
-- 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.MonitorErrorDetails 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.MonitorErrorCode
import qualified Amazonka.Prelude as Prelude

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

-- |
-- Create a value of 'MonitorErrorDetails' 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', 'monitorErrorDetails_code' - The error code.
--
-- 'message', 'monitorErrorDetails_message' - The error message.
newMonitorErrorDetails ::
  MonitorErrorDetails
newMonitorErrorDetails :: MonitorErrorDetails
newMonitorErrorDetails =
  MonitorErrorDetails'
    { $sel:code:MonitorErrorDetails' :: Maybe MonitorErrorCode
code = forall a. Maybe a
Prelude.Nothing,
      $sel:message:MonitorErrorDetails' :: Maybe Text
message = forall a. Maybe a
Prelude.Nothing
    }

-- | The error code.
monitorErrorDetails_code :: Lens.Lens' MonitorErrorDetails (Prelude.Maybe MonitorErrorCode)
monitorErrorDetails_code :: Lens' MonitorErrorDetails (Maybe MonitorErrorCode)
monitorErrorDetails_code = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MonitorErrorDetails' {Maybe MonitorErrorCode
code :: Maybe MonitorErrorCode
$sel:code:MonitorErrorDetails' :: MonitorErrorDetails -> Maybe MonitorErrorCode
code} -> Maybe MonitorErrorCode
code) (\s :: MonitorErrorDetails
s@MonitorErrorDetails' {} Maybe MonitorErrorCode
a -> MonitorErrorDetails
s {$sel:code:MonitorErrorDetails' :: Maybe MonitorErrorCode
code = Maybe MonitorErrorCode
a} :: MonitorErrorDetails)

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

instance Data.FromJSON MonitorErrorDetails where
  parseJSON :: Value -> Parser MonitorErrorDetails
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"MonitorErrorDetails"
      ( \Object
x ->
          Maybe MonitorErrorCode -> Maybe Text -> MonitorErrorDetails
MonitorErrorDetails'
            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
"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")
      )

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

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