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

import qualified Amazonka.Core as Core
import Amazonka.IoTSiteWise.Types.MonitorErrorCode
import qualified Amazonka.Lens as Lens
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
(MonitorErrorDetails -> MonitorErrorDetails -> Bool)
-> (MonitorErrorDetails -> MonitorErrorDetails -> Bool)
-> Eq MonitorErrorDetails
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]
(Int -> ReadS MonitorErrorDetails)
-> ReadS [MonitorErrorDetails]
-> ReadPrec MonitorErrorDetails
-> ReadPrec [MonitorErrorDetails]
-> Read 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
(Int -> MonitorErrorDetails -> ShowS)
-> (MonitorErrorDetails -> String)
-> ([MonitorErrorDetails] -> ShowS)
-> Show MonitorErrorDetails
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. MonitorErrorDetails -> Rep MonitorErrorDetails x)
-> (forall x. Rep MonitorErrorDetails x -> MonitorErrorDetails)
-> Generic MonitorErrorDetails
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' :: Maybe MonitorErrorCode -> Maybe Text -> MonitorErrorDetails
MonitorErrorDetails'
    { $sel:code:MonitorErrorDetails' :: Maybe MonitorErrorCode
code = Maybe MonitorErrorCode
forall a. Maybe a
Prelude.Nothing,
      $sel:message:MonitorErrorDetails' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The error code.
monitorErrorDetails_code :: Lens.Lens' MonitorErrorDetails (Prelude.Maybe MonitorErrorCode)
monitorErrorDetails_code :: (Maybe MonitorErrorCode -> f (Maybe MonitorErrorCode))
-> MonitorErrorDetails -> f MonitorErrorDetails
monitorErrorDetails_code = (MonitorErrorDetails -> Maybe MonitorErrorCode)
-> (MonitorErrorDetails
    -> Maybe MonitorErrorCode -> MonitorErrorDetails)
-> Lens
     MonitorErrorDetails
     MonitorErrorDetails
     (Maybe MonitorErrorCode)
     (Maybe MonitorErrorCode)
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 :: (Maybe Text -> f (Maybe Text))
-> MonitorErrorDetails -> f MonitorErrorDetails
monitorErrorDetails_message = (MonitorErrorDetails -> Maybe Text)
-> (MonitorErrorDetails -> Maybe Text -> MonitorErrorDetails)
-> Lens
     MonitorErrorDetails MonitorErrorDetails (Maybe Text) (Maybe Text)
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 Core.FromJSON MonitorErrorDetails where
  parseJSON :: Value -> Parser MonitorErrorDetails
parseJSON =
    String
-> (Object -> Parser MonitorErrorDetails)
-> Value
-> Parser MonitorErrorDetails
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MonitorErrorDetails"
      ( \Object
x ->
          Maybe MonitorErrorCode -> Maybe Text -> MonitorErrorDetails
MonitorErrorDetails'
            (Maybe MonitorErrorCode -> Maybe Text -> MonitorErrorDetails)
-> Parser (Maybe MonitorErrorCode)
-> Parser (Maybe Text -> MonitorErrorDetails)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe MonitorErrorCode)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"code")
            Parser (Maybe Text -> MonitorErrorDetails)
-> Parser (Maybe Text) -> Parser MonitorErrorDetails
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"message")
      )

instance Prelude.Hashable MonitorErrorDetails

instance Prelude.NFData MonitorErrorDetails