{-# 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.AppStream.Types.Session
-- 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.AppStream.Types.Session where

import Amazonka.AppStream.Types.AuthenticationType
import Amazonka.AppStream.Types.NetworkAccessConfiguration
import Amazonka.AppStream.Types.SessionConnectionState
import Amazonka.AppStream.Types.SessionState
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Describes a streaming session.
--
-- /See:/ 'newSession' smart constructor.
data Session = Session'
  { -- | The authentication method. The user is authenticated using a streaming
    -- URL (@API@) or SAML 2.0 federation (@SAML@).
    Session -> Maybe AuthenticationType
authenticationType :: Prelude.Maybe AuthenticationType,
    -- | Specifies whether a user is connected to the streaming session.
    Session -> Maybe SessionConnectionState
connectionState :: Prelude.Maybe SessionConnectionState,
    -- | The time when the streaming session is set to expire. This time is based
    -- on the @MaxUserDurationinSeconds@ value, which determines the maximum
    -- length of time that a streaming session can run. A streaming session
    -- might end earlier than the time specified in @SessionMaxExpirationTime@,
    -- when the @DisconnectTimeOutInSeconds@ elapses or the user chooses to end
    -- his or her session. If the @DisconnectTimeOutInSeconds@ elapses, or the
    -- user chooses to end his or her session, the streaming instance is
    -- terminated and the streaming session ends.
    Session -> Maybe POSIX
maxExpirationTime :: Prelude.Maybe Data.POSIX,
    -- | The network details for the streaming session.
    Session -> Maybe NetworkAccessConfiguration
networkAccessConfiguration :: Prelude.Maybe NetworkAccessConfiguration,
    -- | The time when a streaming instance is dedicated for the user.
    Session -> Maybe POSIX
startTime :: Prelude.Maybe Data.POSIX,
    -- | The identifier of the streaming session.
    Session -> Text
id :: Prelude.Text,
    -- | The identifier of the user for whom the session was created.
    Session -> Text
userId :: Prelude.Text,
    -- | The name of the stack for the streaming session.
    Session -> Text
stackName :: Prelude.Text,
    -- | The name of the fleet for the streaming session.
    Session -> Text
fleetName :: Prelude.Text,
    -- | The current state of the streaming session.
    Session -> SessionState
state :: SessionState
  }
  deriving (Session -> Session -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Session -> Session -> Bool
$c/= :: Session -> Session -> Bool
== :: Session -> Session -> Bool
$c== :: Session -> Session -> Bool
Prelude.Eq, ReadPrec [Session]
ReadPrec Session
Int -> ReadS Session
ReadS [Session]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Session]
$creadListPrec :: ReadPrec [Session]
readPrec :: ReadPrec Session
$creadPrec :: ReadPrec Session
readList :: ReadS [Session]
$creadList :: ReadS [Session]
readsPrec :: Int -> ReadS Session
$creadsPrec :: Int -> ReadS Session
Prelude.Read, Int -> Session -> ShowS
[Session] -> ShowS
Session -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Session] -> ShowS
$cshowList :: [Session] -> ShowS
show :: Session -> String
$cshow :: Session -> String
showsPrec :: Int -> Session -> ShowS
$cshowsPrec :: Int -> Session -> ShowS
Prelude.Show, forall x. Rep Session x -> Session
forall x. Session -> Rep Session x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Session x -> Session
$cfrom :: forall x. Session -> Rep Session x
Prelude.Generic)

-- |
-- Create a value of 'Session' 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:
--
-- 'authenticationType', 'session_authenticationType' - The authentication method. The user is authenticated using a streaming
-- URL (@API@) or SAML 2.0 federation (@SAML@).
--
-- 'connectionState', 'session_connectionState' - Specifies whether a user is connected to the streaming session.
--
-- 'maxExpirationTime', 'session_maxExpirationTime' - The time when the streaming session is set to expire. This time is based
-- on the @MaxUserDurationinSeconds@ value, which determines the maximum
-- length of time that a streaming session can run. A streaming session
-- might end earlier than the time specified in @SessionMaxExpirationTime@,
-- when the @DisconnectTimeOutInSeconds@ elapses or the user chooses to end
-- his or her session. If the @DisconnectTimeOutInSeconds@ elapses, or the
-- user chooses to end his or her session, the streaming instance is
-- terminated and the streaming session ends.
--
-- 'networkAccessConfiguration', 'session_networkAccessConfiguration' - The network details for the streaming session.
--
-- 'startTime', 'session_startTime' - The time when a streaming instance is dedicated for the user.
--
-- 'id', 'session_id' - The identifier of the streaming session.
--
-- 'userId', 'session_userId' - The identifier of the user for whom the session was created.
--
-- 'stackName', 'session_stackName' - The name of the stack for the streaming session.
--
-- 'fleetName', 'session_fleetName' - The name of the fleet for the streaming session.
--
-- 'state', 'session_state' - The current state of the streaming session.
newSession ::
  -- | 'id'
  Prelude.Text ->
  -- | 'userId'
  Prelude.Text ->
  -- | 'stackName'
  Prelude.Text ->
  -- | 'fleetName'
  Prelude.Text ->
  -- | 'state'
  SessionState ->
  Session
newSession :: Text -> Text -> Text -> Text -> SessionState -> Session
newSession
  Text
pId_
  Text
pUserId_
  Text
pStackName_
  Text
pFleetName_
  SessionState
pState_ =
    Session'
      { $sel:authenticationType:Session' :: Maybe AuthenticationType
authenticationType = forall a. Maybe a
Prelude.Nothing,
        $sel:connectionState:Session' :: Maybe SessionConnectionState
connectionState = forall a. Maybe a
Prelude.Nothing,
        $sel:maxExpirationTime:Session' :: Maybe POSIX
maxExpirationTime = forall a. Maybe a
Prelude.Nothing,
        $sel:networkAccessConfiguration:Session' :: Maybe NetworkAccessConfiguration
networkAccessConfiguration = forall a. Maybe a
Prelude.Nothing,
        $sel:startTime:Session' :: Maybe POSIX
startTime = forall a. Maybe a
Prelude.Nothing,
        $sel:id:Session' :: Text
id = Text
pId_,
        $sel:userId:Session' :: Text
userId = Text
pUserId_,
        $sel:stackName:Session' :: Text
stackName = Text
pStackName_,
        $sel:fleetName:Session' :: Text
fleetName = Text
pFleetName_,
        $sel:state:Session' :: SessionState
state = SessionState
pState_
      }

-- | The authentication method. The user is authenticated using a streaming
-- URL (@API@) or SAML 2.0 federation (@SAML@).
session_authenticationType :: Lens.Lens' Session (Prelude.Maybe AuthenticationType)
session_authenticationType :: Lens' Session (Maybe AuthenticationType)
session_authenticationType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Session' {Maybe AuthenticationType
authenticationType :: Maybe AuthenticationType
$sel:authenticationType:Session' :: Session -> Maybe AuthenticationType
authenticationType} -> Maybe AuthenticationType
authenticationType) (\s :: Session
s@Session' {} Maybe AuthenticationType
a -> Session
s {$sel:authenticationType:Session' :: Maybe AuthenticationType
authenticationType = Maybe AuthenticationType
a} :: Session)

-- | Specifies whether a user is connected to the streaming session.
session_connectionState :: Lens.Lens' Session (Prelude.Maybe SessionConnectionState)
session_connectionState :: Lens' Session (Maybe SessionConnectionState)
session_connectionState = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Session' {Maybe SessionConnectionState
connectionState :: Maybe SessionConnectionState
$sel:connectionState:Session' :: Session -> Maybe SessionConnectionState
connectionState} -> Maybe SessionConnectionState
connectionState) (\s :: Session
s@Session' {} Maybe SessionConnectionState
a -> Session
s {$sel:connectionState:Session' :: Maybe SessionConnectionState
connectionState = Maybe SessionConnectionState
a} :: Session)

-- | The time when the streaming session is set to expire. This time is based
-- on the @MaxUserDurationinSeconds@ value, which determines the maximum
-- length of time that a streaming session can run. A streaming session
-- might end earlier than the time specified in @SessionMaxExpirationTime@,
-- when the @DisconnectTimeOutInSeconds@ elapses or the user chooses to end
-- his or her session. If the @DisconnectTimeOutInSeconds@ elapses, or the
-- user chooses to end his or her session, the streaming instance is
-- terminated and the streaming session ends.
session_maxExpirationTime :: Lens.Lens' Session (Prelude.Maybe Prelude.UTCTime)
session_maxExpirationTime :: Lens' Session (Maybe UTCTime)
session_maxExpirationTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Session' {Maybe POSIX
maxExpirationTime :: Maybe POSIX
$sel:maxExpirationTime:Session' :: Session -> Maybe POSIX
maxExpirationTime} -> Maybe POSIX
maxExpirationTime) (\s :: Session
s@Session' {} Maybe POSIX
a -> Session
s {$sel:maxExpirationTime:Session' :: Maybe POSIX
maxExpirationTime = Maybe POSIX
a} :: Session) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The network details for the streaming session.
session_networkAccessConfiguration :: Lens.Lens' Session (Prelude.Maybe NetworkAccessConfiguration)
session_networkAccessConfiguration :: Lens' Session (Maybe NetworkAccessConfiguration)
session_networkAccessConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Session' {Maybe NetworkAccessConfiguration
networkAccessConfiguration :: Maybe NetworkAccessConfiguration
$sel:networkAccessConfiguration:Session' :: Session -> Maybe NetworkAccessConfiguration
networkAccessConfiguration} -> Maybe NetworkAccessConfiguration
networkAccessConfiguration) (\s :: Session
s@Session' {} Maybe NetworkAccessConfiguration
a -> Session
s {$sel:networkAccessConfiguration:Session' :: Maybe NetworkAccessConfiguration
networkAccessConfiguration = Maybe NetworkAccessConfiguration
a} :: Session)

-- | The time when a streaming instance is dedicated for the user.
session_startTime :: Lens.Lens' Session (Prelude.Maybe Prelude.UTCTime)
session_startTime :: Lens' Session (Maybe UTCTime)
session_startTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Session' {Maybe POSIX
startTime :: Maybe POSIX
$sel:startTime:Session' :: Session -> Maybe POSIX
startTime} -> Maybe POSIX
startTime) (\s :: Session
s@Session' {} Maybe POSIX
a -> Session
s {$sel:startTime:Session' :: Maybe POSIX
startTime = Maybe POSIX
a} :: Session) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The identifier of the streaming session.
session_id :: Lens.Lens' Session Prelude.Text
session_id :: Lens' Session Text
session_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Session' {Text
id :: Text
$sel:id:Session' :: Session -> Text
id} -> Text
id) (\s :: Session
s@Session' {} Text
a -> Session
s {$sel:id:Session' :: Text
id = Text
a} :: Session)

-- | The identifier of the user for whom the session was created.
session_userId :: Lens.Lens' Session Prelude.Text
session_userId :: Lens' Session Text
session_userId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Session' {Text
userId :: Text
$sel:userId:Session' :: Session -> Text
userId} -> Text
userId) (\s :: Session
s@Session' {} Text
a -> Session
s {$sel:userId:Session' :: Text
userId = Text
a} :: Session)

-- | The name of the stack for the streaming session.
session_stackName :: Lens.Lens' Session Prelude.Text
session_stackName :: Lens' Session Text
session_stackName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Session' {Text
stackName :: Text
$sel:stackName:Session' :: Session -> Text
stackName} -> Text
stackName) (\s :: Session
s@Session' {} Text
a -> Session
s {$sel:stackName:Session' :: Text
stackName = Text
a} :: Session)

-- | The name of the fleet for the streaming session.
session_fleetName :: Lens.Lens' Session Prelude.Text
session_fleetName :: Lens' Session Text
session_fleetName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Session' {Text
fleetName :: Text
$sel:fleetName:Session' :: Session -> Text
fleetName} -> Text
fleetName) (\s :: Session
s@Session' {} Text
a -> Session
s {$sel:fleetName:Session' :: Text
fleetName = Text
a} :: Session)

-- | The current state of the streaming session.
session_state :: Lens.Lens' Session SessionState
session_state :: Lens' Session SessionState
session_state = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Session' {SessionState
state :: SessionState
$sel:state:Session' :: Session -> SessionState
state} -> SessionState
state) (\s :: Session
s@Session' {} SessionState
a -> Session
s {$sel:state:Session' :: SessionState
state = SessionState
a} :: Session)

instance Data.FromJSON Session where
  parseJSON :: Value -> Parser Session
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Session"
      ( \Object
x ->
          Maybe AuthenticationType
-> Maybe SessionConnectionState
-> Maybe POSIX
-> Maybe NetworkAccessConfiguration
-> Maybe POSIX
-> Text
-> Text
-> Text
-> Text
-> SessionState
-> Session
Session'
            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
"AuthenticationType")
            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
"ConnectionState")
            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
"MaxExpirationTime")
            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
"NetworkAccessConfiguration")
            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
"StartTime")
            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
"Id")
            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
"UserId")
            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
"StackName")
            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
"FleetName")
            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 Session where
  hashWithSalt :: Int -> Session -> Int
hashWithSalt Int
_salt Session' {Maybe POSIX
Maybe AuthenticationType
Maybe NetworkAccessConfiguration
Maybe SessionConnectionState
Text
SessionState
state :: SessionState
fleetName :: Text
stackName :: Text
userId :: Text
id :: Text
startTime :: Maybe POSIX
networkAccessConfiguration :: Maybe NetworkAccessConfiguration
maxExpirationTime :: Maybe POSIX
connectionState :: Maybe SessionConnectionState
authenticationType :: Maybe AuthenticationType
$sel:state:Session' :: Session -> SessionState
$sel:fleetName:Session' :: Session -> Text
$sel:stackName:Session' :: Session -> Text
$sel:userId:Session' :: Session -> Text
$sel:id:Session' :: Session -> Text
$sel:startTime:Session' :: Session -> Maybe POSIX
$sel:networkAccessConfiguration:Session' :: Session -> Maybe NetworkAccessConfiguration
$sel:maxExpirationTime:Session' :: Session -> Maybe POSIX
$sel:connectionState:Session' :: Session -> Maybe SessionConnectionState
$sel:authenticationType:Session' :: Session -> Maybe AuthenticationType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AuthenticationType
authenticationType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SessionConnectionState
connectionState
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
maxExpirationTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe NetworkAccessConfiguration
networkAccessConfiguration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
startTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
userId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
stackName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
fleetName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` SessionState
state

instance Prelude.NFData Session where
  rnf :: Session -> ()
rnf Session' {Maybe POSIX
Maybe AuthenticationType
Maybe NetworkAccessConfiguration
Maybe SessionConnectionState
Text
SessionState
state :: SessionState
fleetName :: Text
stackName :: Text
userId :: Text
id :: Text
startTime :: Maybe POSIX
networkAccessConfiguration :: Maybe NetworkAccessConfiguration
maxExpirationTime :: Maybe POSIX
connectionState :: Maybe SessionConnectionState
authenticationType :: Maybe AuthenticationType
$sel:state:Session' :: Session -> SessionState
$sel:fleetName:Session' :: Session -> Text
$sel:stackName:Session' :: Session -> Text
$sel:userId:Session' :: Session -> Text
$sel:id:Session' :: Session -> Text
$sel:startTime:Session' :: Session -> Maybe POSIX
$sel:networkAccessConfiguration:Session' :: Session -> Maybe NetworkAccessConfiguration
$sel:maxExpirationTime:Session' :: Session -> Maybe POSIX
$sel:connectionState:Session' :: Session -> Maybe SessionConnectionState
$sel:authenticationType:Session' :: Session -> Maybe AuthenticationType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AuthenticationType
authenticationType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SessionConnectionState
connectionState
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
maxExpirationTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe NetworkAccessConfiguration
networkAccessConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
startTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
userId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
stackName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
fleetName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf SessionState
state