{-# 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.WorkSpaces.Types.WorkspaceConnectionStatus
-- 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.WorkSpaces.Types.WorkspaceConnectionStatus where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.WorkSpaces.Types.ConnectionState

-- | Describes the connection status of a WorkSpace.
--
-- /See:/ 'newWorkspaceConnectionStatus' smart constructor.
data WorkspaceConnectionStatus = WorkspaceConnectionStatus'
  { -- | The timestamp of the last known user connection.
    WorkspaceConnectionStatus -> Maybe POSIX
lastKnownUserConnectionTimestamp :: Prelude.Maybe Core.POSIX,
    -- | The timestamp of the connection status check.
    WorkspaceConnectionStatus -> Maybe POSIX
connectionStateCheckTimestamp :: Prelude.Maybe Core.POSIX,
    -- | The identifier of the WorkSpace.
    WorkspaceConnectionStatus -> Maybe Text
workspaceId :: Prelude.Maybe Prelude.Text,
    -- | The connection state of the WorkSpace. The connection state is unknown
    -- if the WorkSpace is stopped.
    WorkspaceConnectionStatus -> Maybe ConnectionState
connectionState :: Prelude.Maybe ConnectionState
  }
  deriving (WorkspaceConnectionStatus -> WorkspaceConnectionStatus -> Bool
(WorkspaceConnectionStatus -> WorkspaceConnectionStatus -> Bool)
-> (WorkspaceConnectionStatus -> WorkspaceConnectionStatus -> Bool)
-> Eq WorkspaceConnectionStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WorkspaceConnectionStatus -> WorkspaceConnectionStatus -> Bool
$c/= :: WorkspaceConnectionStatus -> WorkspaceConnectionStatus -> Bool
== :: WorkspaceConnectionStatus -> WorkspaceConnectionStatus -> Bool
$c== :: WorkspaceConnectionStatus -> WorkspaceConnectionStatus -> Bool
Prelude.Eq, ReadPrec [WorkspaceConnectionStatus]
ReadPrec WorkspaceConnectionStatus
Int -> ReadS WorkspaceConnectionStatus
ReadS [WorkspaceConnectionStatus]
(Int -> ReadS WorkspaceConnectionStatus)
-> ReadS [WorkspaceConnectionStatus]
-> ReadPrec WorkspaceConnectionStatus
-> ReadPrec [WorkspaceConnectionStatus]
-> Read WorkspaceConnectionStatus
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WorkspaceConnectionStatus]
$creadListPrec :: ReadPrec [WorkspaceConnectionStatus]
readPrec :: ReadPrec WorkspaceConnectionStatus
$creadPrec :: ReadPrec WorkspaceConnectionStatus
readList :: ReadS [WorkspaceConnectionStatus]
$creadList :: ReadS [WorkspaceConnectionStatus]
readsPrec :: Int -> ReadS WorkspaceConnectionStatus
$creadsPrec :: Int -> ReadS WorkspaceConnectionStatus
Prelude.Read, Int -> WorkspaceConnectionStatus -> ShowS
[WorkspaceConnectionStatus] -> ShowS
WorkspaceConnectionStatus -> String
(Int -> WorkspaceConnectionStatus -> ShowS)
-> (WorkspaceConnectionStatus -> String)
-> ([WorkspaceConnectionStatus] -> ShowS)
-> Show WorkspaceConnectionStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WorkspaceConnectionStatus] -> ShowS
$cshowList :: [WorkspaceConnectionStatus] -> ShowS
show :: WorkspaceConnectionStatus -> String
$cshow :: WorkspaceConnectionStatus -> String
showsPrec :: Int -> WorkspaceConnectionStatus -> ShowS
$cshowsPrec :: Int -> WorkspaceConnectionStatus -> ShowS
Prelude.Show, (forall x.
 WorkspaceConnectionStatus -> Rep WorkspaceConnectionStatus x)
-> (forall x.
    Rep WorkspaceConnectionStatus x -> WorkspaceConnectionStatus)
-> Generic WorkspaceConnectionStatus
forall x.
Rep WorkspaceConnectionStatus x -> WorkspaceConnectionStatus
forall x.
WorkspaceConnectionStatus -> Rep WorkspaceConnectionStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep WorkspaceConnectionStatus x -> WorkspaceConnectionStatus
$cfrom :: forall x.
WorkspaceConnectionStatus -> Rep WorkspaceConnectionStatus x
Prelude.Generic)

-- |
-- Create a value of 'WorkspaceConnectionStatus' 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:
--
-- 'lastKnownUserConnectionTimestamp', 'workspaceConnectionStatus_lastKnownUserConnectionTimestamp' - The timestamp of the last known user connection.
--
-- 'connectionStateCheckTimestamp', 'workspaceConnectionStatus_connectionStateCheckTimestamp' - The timestamp of the connection status check.
--
-- 'workspaceId', 'workspaceConnectionStatus_workspaceId' - The identifier of the WorkSpace.
--
-- 'connectionState', 'workspaceConnectionStatus_connectionState' - The connection state of the WorkSpace. The connection state is unknown
-- if the WorkSpace is stopped.
newWorkspaceConnectionStatus ::
  WorkspaceConnectionStatus
newWorkspaceConnectionStatus :: WorkspaceConnectionStatus
newWorkspaceConnectionStatus =
  WorkspaceConnectionStatus' :: Maybe POSIX
-> Maybe POSIX
-> Maybe Text
-> Maybe ConnectionState
-> WorkspaceConnectionStatus
WorkspaceConnectionStatus'
    { $sel:lastKnownUserConnectionTimestamp:WorkspaceConnectionStatus' :: Maybe POSIX
lastKnownUserConnectionTimestamp =
        Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:connectionStateCheckTimestamp:WorkspaceConnectionStatus' :: Maybe POSIX
connectionStateCheckTimestamp = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:workspaceId:WorkspaceConnectionStatus' :: Maybe Text
workspaceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:connectionState:WorkspaceConnectionStatus' :: Maybe ConnectionState
connectionState = Maybe ConnectionState
forall a. Maybe a
Prelude.Nothing
    }

-- | The timestamp of the last known user connection.
workspaceConnectionStatus_lastKnownUserConnectionTimestamp :: Lens.Lens' WorkspaceConnectionStatus (Prelude.Maybe Prelude.UTCTime)
workspaceConnectionStatus_lastKnownUserConnectionTimestamp :: (Maybe UTCTime -> f (Maybe UTCTime))
-> WorkspaceConnectionStatus -> f WorkspaceConnectionStatus
workspaceConnectionStatus_lastKnownUserConnectionTimestamp = (WorkspaceConnectionStatus -> Maybe POSIX)
-> (WorkspaceConnectionStatus
    -> Maybe POSIX -> WorkspaceConnectionStatus)
-> Lens
     WorkspaceConnectionStatus
     WorkspaceConnectionStatus
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkspaceConnectionStatus' {Maybe POSIX
lastKnownUserConnectionTimestamp :: Maybe POSIX
$sel:lastKnownUserConnectionTimestamp:WorkspaceConnectionStatus' :: WorkspaceConnectionStatus -> Maybe POSIX
lastKnownUserConnectionTimestamp} -> Maybe POSIX
lastKnownUserConnectionTimestamp) (\s :: WorkspaceConnectionStatus
s@WorkspaceConnectionStatus' {} Maybe POSIX
a -> WorkspaceConnectionStatus
s {$sel:lastKnownUserConnectionTimestamp:WorkspaceConnectionStatus' :: Maybe POSIX
lastKnownUserConnectionTimestamp = Maybe POSIX
a} :: WorkspaceConnectionStatus) ((Maybe POSIX -> f (Maybe POSIX))
 -> WorkspaceConnectionStatus -> f WorkspaceConnectionStatus)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> WorkspaceConnectionStatus
-> f WorkspaceConnectionStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The timestamp of the connection status check.
workspaceConnectionStatus_connectionStateCheckTimestamp :: Lens.Lens' WorkspaceConnectionStatus (Prelude.Maybe Prelude.UTCTime)
workspaceConnectionStatus_connectionStateCheckTimestamp :: (Maybe UTCTime -> f (Maybe UTCTime))
-> WorkspaceConnectionStatus -> f WorkspaceConnectionStatus
workspaceConnectionStatus_connectionStateCheckTimestamp = (WorkspaceConnectionStatus -> Maybe POSIX)
-> (WorkspaceConnectionStatus
    -> Maybe POSIX -> WorkspaceConnectionStatus)
-> Lens
     WorkspaceConnectionStatus
     WorkspaceConnectionStatus
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkspaceConnectionStatus' {Maybe POSIX
connectionStateCheckTimestamp :: Maybe POSIX
$sel:connectionStateCheckTimestamp:WorkspaceConnectionStatus' :: WorkspaceConnectionStatus -> Maybe POSIX
connectionStateCheckTimestamp} -> Maybe POSIX
connectionStateCheckTimestamp) (\s :: WorkspaceConnectionStatus
s@WorkspaceConnectionStatus' {} Maybe POSIX
a -> WorkspaceConnectionStatus
s {$sel:connectionStateCheckTimestamp:WorkspaceConnectionStatus' :: Maybe POSIX
connectionStateCheckTimestamp = Maybe POSIX
a} :: WorkspaceConnectionStatus) ((Maybe POSIX -> f (Maybe POSIX))
 -> WorkspaceConnectionStatus -> f WorkspaceConnectionStatus)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> WorkspaceConnectionStatus
-> f WorkspaceConnectionStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The identifier of the WorkSpace.
workspaceConnectionStatus_workspaceId :: Lens.Lens' WorkspaceConnectionStatus (Prelude.Maybe Prelude.Text)
workspaceConnectionStatus_workspaceId :: (Maybe Text -> f (Maybe Text))
-> WorkspaceConnectionStatus -> f WorkspaceConnectionStatus
workspaceConnectionStatus_workspaceId = (WorkspaceConnectionStatus -> Maybe Text)
-> (WorkspaceConnectionStatus
    -> Maybe Text -> WorkspaceConnectionStatus)
-> Lens
     WorkspaceConnectionStatus
     WorkspaceConnectionStatus
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkspaceConnectionStatus' {Maybe Text
workspaceId :: Maybe Text
$sel:workspaceId:WorkspaceConnectionStatus' :: WorkspaceConnectionStatus -> Maybe Text
workspaceId} -> Maybe Text
workspaceId) (\s :: WorkspaceConnectionStatus
s@WorkspaceConnectionStatus' {} Maybe Text
a -> WorkspaceConnectionStatus
s {$sel:workspaceId:WorkspaceConnectionStatus' :: Maybe Text
workspaceId = Maybe Text
a} :: WorkspaceConnectionStatus)

-- | The connection state of the WorkSpace. The connection state is unknown
-- if the WorkSpace is stopped.
workspaceConnectionStatus_connectionState :: Lens.Lens' WorkspaceConnectionStatus (Prelude.Maybe ConnectionState)
workspaceConnectionStatus_connectionState :: (Maybe ConnectionState -> f (Maybe ConnectionState))
-> WorkspaceConnectionStatus -> f WorkspaceConnectionStatus
workspaceConnectionStatus_connectionState = (WorkspaceConnectionStatus -> Maybe ConnectionState)
-> (WorkspaceConnectionStatus
    -> Maybe ConnectionState -> WorkspaceConnectionStatus)
-> Lens
     WorkspaceConnectionStatus
     WorkspaceConnectionStatus
     (Maybe ConnectionState)
     (Maybe ConnectionState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkspaceConnectionStatus' {Maybe ConnectionState
connectionState :: Maybe ConnectionState
$sel:connectionState:WorkspaceConnectionStatus' :: WorkspaceConnectionStatus -> Maybe ConnectionState
connectionState} -> Maybe ConnectionState
connectionState) (\s :: WorkspaceConnectionStatus
s@WorkspaceConnectionStatus' {} Maybe ConnectionState
a -> WorkspaceConnectionStatus
s {$sel:connectionState:WorkspaceConnectionStatus' :: Maybe ConnectionState
connectionState = Maybe ConnectionState
a} :: WorkspaceConnectionStatus)

instance Core.FromJSON WorkspaceConnectionStatus where
  parseJSON :: Value -> Parser WorkspaceConnectionStatus
parseJSON =
    String
-> (Object -> Parser WorkspaceConnectionStatus)
-> Value
-> Parser WorkspaceConnectionStatus
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"WorkspaceConnectionStatus"
      ( \Object
x ->
          Maybe POSIX
-> Maybe POSIX
-> Maybe Text
-> Maybe ConnectionState
-> WorkspaceConnectionStatus
WorkspaceConnectionStatus'
            (Maybe POSIX
 -> Maybe POSIX
 -> Maybe Text
 -> Maybe ConnectionState
 -> WorkspaceConnectionStatus)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe POSIX
      -> Maybe Text
      -> Maybe ConnectionState
      -> WorkspaceConnectionStatus)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LastKnownUserConnectionTimestamp")
            Parser
  (Maybe POSIX
   -> Maybe Text
   -> Maybe ConnectionState
   -> WorkspaceConnectionStatus)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Text -> Maybe ConnectionState -> WorkspaceConnectionStatus)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ConnectionStateCheckTimestamp")
            Parser
  (Maybe Text -> Maybe ConnectionState -> WorkspaceConnectionStatus)
-> Parser (Maybe Text)
-> Parser (Maybe ConnectionState -> WorkspaceConnectionStatus)
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
"WorkspaceId")
            Parser (Maybe ConnectionState -> WorkspaceConnectionStatus)
-> Parser (Maybe ConnectionState)
-> Parser WorkspaceConnectionStatus
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ConnectionState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ConnectionState")
      )

instance Prelude.Hashable WorkspaceConnectionStatus

instance Prelude.NFData WorkspaceConnectionStatus