{-# 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-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.PortalStatus 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.MonitorErrorDetails
import Amazonka.IoTSiteWise.Types.PortalState
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
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]
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
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. 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'
    { $sel:error:PortalStatus' :: Maybe MonitorErrorDetails
error = 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 :: Lens' PortalStatus (Maybe MonitorErrorDetails)
portalStatus_error = 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 :: Lens' PortalStatus PortalState
portalStatus_state = 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 Data.FromJSON PortalStatus where
  parseJSON :: Value -> Parser PortalStatus
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PortalStatus"
      ( \Object
x ->
          Maybe MonitorErrorDetails -> PortalState -> PortalStatus
PortalStatus'
            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
"error")
            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
"state")
      )

instance Prelude.Hashable PortalStatus where
  hashWithSalt :: Int -> PortalStatus -> Int
hashWithSalt Int
_salt PortalStatus' {Maybe MonitorErrorDetails
PortalState
state :: PortalState
error :: Maybe MonitorErrorDetails
$sel:state:PortalStatus' :: PortalStatus -> PortalState
$sel:error:PortalStatus' :: PortalStatus -> Maybe MonitorErrorDetails
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe MonitorErrorDetails
error
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` PortalState
state

instance Prelude.NFData PortalStatus where
  rnf :: PortalStatus -> ()
rnf PortalStatus' {Maybe MonitorErrorDetails
PortalState
state :: PortalState
error :: Maybe MonitorErrorDetails
$sel:state:PortalStatus' :: PortalStatus -> PortalState
$sel:error:PortalStatus' :: PortalStatus -> Maybe MonitorErrorDetails
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe MonitorErrorDetails
error seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf PortalState
state