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

import qualified Amazonka.Core as Core
import Amazonka.IoTSiteWise.Types.MonitorErrorDetails
import Amazonka.IoTSiteWise.Types.PortalState
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about the current status of a portal.
--
-- /See:/ 'newPortalStatus' smart constructor.
data PortalStatus = PortalStatus'
  { -- | Contains associated error information, if any.
    PortalStatus -> Maybe MonitorErrorDetails
error :: Prelude.Maybe MonitorErrorDetails,
    -- | The current state of the portal.
    PortalStatus -> PortalState
state :: PortalState
  }
  deriving (PortalStatus -> PortalStatus -> Bool
(PortalStatus -> PortalStatus -> Bool)
-> (PortalStatus -> PortalStatus -> Bool) -> Eq PortalStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PortalStatus -> PortalStatus -> Bool
$c/= :: PortalStatus -> PortalStatus -> Bool
== :: PortalStatus -> PortalStatus -> Bool
$c== :: PortalStatus -> PortalStatus -> Bool
Prelude.Eq, ReadPrec [PortalStatus]
ReadPrec PortalStatus
Int -> ReadS PortalStatus
ReadS [PortalStatus]
(Int -> ReadS PortalStatus)
-> ReadS [PortalStatus]
-> ReadPrec PortalStatus
-> ReadPrec [PortalStatus]
-> Read PortalStatus
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PortalStatus]
$creadListPrec :: ReadPrec [PortalStatus]
readPrec :: ReadPrec PortalStatus
$creadPrec :: ReadPrec PortalStatus
readList :: ReadS [PortalStatus]
$creadList :: ReadS [PortalStatus]
readsPrec :: Int -> ReadS PortalStatus
$creadsPrec :: Int -> ReadS PortalStatus
Prelude.Read, Int -> PortalStatus -> ShowS
[PortalStatus] -> ShowS
PortalStatus -> String
(Int -> PortalStatus -> ShowS)
-> (PortalStatus -> String)
-> ([PortalStatus] -> ShowS)
-> Show PortalStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PortalStatus] -> ShowS
$cshowList :: [PortalStatus] -> ShowS
show :: PortalStatus -> String
$cshow :: PortalStatus -> String
showsPrec :: Int -> PortalStatus -> ShowS
$cshowsPrec :: Int -> PortalStatus -> ShowS
Prelude.Show, (forall x. PortalStatus -> Rep PortalStatus x)
-> (forall x. Rep PortalStatus x -> PortalStatus)
-> Generic PortalStatus
forall x. Rep PortalStatus x -> PortalStatus
forall x. PortalStatus -> Rep PortalStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PortalStatus x -> PortalStatus
$cfrom :: forall x. PortalStatus -> Rep PortalStatus x
Prelude.Generic)

-- |
-- Create a value of 'PortalStatus' 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:
--
-- 'error', 'portalStatus_error' - Contains associated error information, if any.
--
-- 'state', 'portalStatus_state' - The current state of the portal.
newPortalStatus ::
  -- | 'state'
  PortalState ->
  PortalStatus
newPortalStatus :: PortalState -> PortalStatus
newPortalStatus PortalState
pState_ =
  PortalStatus' :: Maybe MonitorErrorDetails -> PortalState -> PortalStatus
PortalStatus'
    { $sel:error:PortalStatus' :: Maybe MonitorErrorDetails
error = Maybe MonitorErrorDetails
forall a. Maybe a
Prelude.Nothing,
      $sel:state:PortalStatus' :: PortalState
state = PortalState
pState_
    }

-- | Contains associated error information, if any.
portalStatus_error :: Lens.Lens' PortalStatus (Prelude.Maybe MonitorErrorDetails)
portalStatus_error :: (Maybe MonitorErrorDetails -> f (Maybe MonitorErrorDetails))
-> PortalStatus -> f PortalStatus
portalStatus_error = (PortalStatus -> Maybe MonitorErrorDetails)
-> (PortalStatus -> Maybe MonitorErrorDetails -> PortalStatus)
-> Lens
     PortalStatus
     PortalStatus
     (Maybe MonitorErrorDetails)
     (Maybe MonitorErrorDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PortalStatus' {Maybe MonitorErrorDetails
error :: Maybe MonitorErrorDetails
$sel:error:PortalStatus' :: PortalStatus -> Maybe MonitorErrorDetails
error} -> Maybe MonitorErrorDetails
error) (\s :: PortalStatus
s@PortalStatus' {} Maybe MonitorErrorDetails
a -> PortalStatus
s {$sel:error:PortalStatus' :: Maybe MonitorErrorDetails
error = Maybe MonitorErrorDetails
a} :: PortalStatus)

-- | The current state of the portal.
portalStatus_state :: Lens.Lens' PortalStatus PortalState
portalStatus_state :: (PortalState -> f PortalState) -> PortalStatus -> f PortalStatus
portalStatus_state = (PortalStatus -> PortalState)
-> (PortalStatus -> PortalState -> PortalStatus)
-> Lens PortalStatus PortalStatus PortalState PortalState
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PortalStatus' {PortalState
state :: PortalState
$sel:state:PortalStatus' :: PortalStatus -> PortalState
state} -> PortalState
state) (\s :: PortalStatus
s@PortalStatus' {} PortalState
a -> PortalStatus
s {$sel:state:PortalStatus' :: PortalState
state = PortalState
a} :: PortalStatus)

instance Core.FromJSON PortalStatus where
  parseJSON :: Value -> Parser PortalStatus
parseJSON =
    String
-> (Object -> Parser PortalStatus) -> Value -> Parser PortalStatus
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PortalStatus"
      ( \Object
x ->
          Maybe MonitorErrorDetails -> PortalState -> PortalStatus
PortalStatus'
            (Maybe MonitorErrorDetails -> PortalState -> PortalStatus)
-> Parser (Maybe MonitorErrorDetails)
-> Parser (PortalState -> PortalStatus)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe MonitorErrorDetails)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"error") Parser (PortalState -> PortalStatus)
-> Parser PortalState -> Parser PortalStatus
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser PortalState
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"state")
      )

instance Prelude.Hashable PortalStatus

instance Prelude.NFData PortalStatus