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

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
import Amazonka.SSM.Types.SessionManagerOutputUrl
import Amazonka.SSM.Types.SessionStatus

-- | Information about a Session Manager connection to a managed node.
--
-- /See:/ 'newSession' smart constructor.
data Session = Session'
  { -- | Reserved for future use.
    Session -> Maybe Text
details :: Prelude.Maybe Prelude.Text,
    -- | The name of the Session Manager SSM document used to define the
    -- parameters and plugin settings for the session. For example,
    -- @SSM-SessionManagerRunShell@.
    Session -> Maybe Text
documentName :: Prelude.Maybe Prelude.Text,
    -- | The date and time, in ISO-8601 Extended format, when the session was
    -- terminated.
    Session -> Maybe POSIX
endDate :: Prelude.Maybe Data.POSIX,
    -- | The maximum duration of a session before it terminates.
    Session -> Maybe Text
maxSessionDuration :: Prelude.Maybe Prelude.Text,
    -- | Reserved for future use.
    Session -> Maybe SessionManagerOutputUrl
outputUrl :: Prelude.Maybe SessionManagerOutputUrl,
    -- | The ID of the Amazon Web Services user account that started the session.
    Session -> Maybe Text
owner :: Prelude.Maybe Prelude.Text,
    -- | The reason for connecting to the instance.
    Session -> Maybe Text
reason :: Prelude.Maybe Prelude.Text,
    -- | The ID of the session.
    Session -> Maybe Text
sessionId :: Prelude.Maybe Prelude.Text,
    -- | The date and time, in ISO-8601 Extended format, when the session began.
    Session -> Maybe POSIX
startDate :: Prelude.Maybe Data.POSIX,
    -- | The status of the session. For example, \"Connected\" or \"Terminated\".
    Session -> Maybe SessionStatus
status :: Prelude.Maybe SessionStatus,
    -- | The managed node that the Session Manager session connected to.
    Session -> Maybe Text
target :: Prelude.Maybe Prelude.Text
  }
  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:
--
-- 'details', 'session_details' - Reserved for future use.
--
-- 'documentName', 'session_documentName' - The name of the Session Manager SSM document used to define the
-- parameters and plugin settings for the session. For example,
-- @SSM-SessionManagerRunShell@.
--
-- 'endDate', 'session_endDate' - The date and time, in ISO-8601 Extended format, when the session was
-- terminated.
--
-- 'maxSessionDuration', 'session_maxSessionDuration' - The maximum duration of a session before it terminates.
--
-- 'outputUrl', 'session_outputUrl' - Reserved for future use.
--
-- 'owner', 'session_owner' - The ID of the Amazon Web Services user account that started the session.
--
-- 'reason', 'session_reason' - The reason for connecting to the instance.
--
-- 'sessionId', 'session_sessionId' - The ID of the session.
--
-- 'startDate', 'session_startDate' - The date and time, in ISO-8601 Extended format, when the session began.
--
-- 'status', 'session_status' - The status of the session. For example, \"Connected\" or \"Terminated\".
--
-- 'target', 'session_target' - The managed node that the Session Manager session connected to.
newSession ::
  Session
newSession :: Session
newSession =
  Session'
    { $sel:details:Session' :: Maybe Text
details = forall a. Maybe a
Prelude.Nothing,
      $sel:documentName:Session' :: Maybe Text
documentName = forall a. Maybe a
Prelude.Nothing,
      $sel:endDate:Session' :: Maybe POSIX
endDate = forall a. Maybe a
Prelude.Nothing,
      $sel:maxSessionDuration:Session' :: Maybe Text
maxSessionDuration = forall a. Maybe a
Prelude.Nothing,
      $sel:outputUrl:Session' :: Maybe SessionManagerOutputUrl
outputUrl = forall a. Maybe a
Prelude.Nothing,
      $sel:owner:Session' :: Maybe Text
owner = forall a. Maybe a
Prelude.Nothing,
      $sel:reason:Session' :: Maybe Text
reason = forall a. Maybe a
Prelude.Nothing,
      $sel:sessionId:Session' :: Maybe Text
sessionId = forall a. Maybe a
Prelude.Nothing,
      $sel:startDate:Session' :: Maybe POSIX
startDate = forall a. Maybe a
Prelude.Nothing,
      $sel:status:Session' :: Maybe SessionStatus
status = forall a. Maybe a
Prelude.Nothing,
      $sel:target:Session' :: Maybe Text
target = forall a. Maybe a
Prelude.Nothing
    }

-- | Reserved for future use.
session_details :: Lens.Lens' Session (Prelude.Maybe Prelude.Text)
session_details :: Lens' Session (Maybe Text)
session_details = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Session' {Maybe Text
details :: Maybe Text
$sel:details:Session' :: Session -> Maybe Text
details} -> Maybe Text
details) (\s :: Session
s@Session' {} Maybe Text
a -> Session
s {$sel:details:Session' :: Maybe Text
details = Maybe Text
a} :: Session)

-- | The name of the Session Manager SSM document used to define the
-- parameters and plugin settings for the session. For example,
-- @SSM-SessionManagerRunShell@.
session_documentName :: Lens.Lens' Session (Prelude.Maybe Prelude.Text)
session_documentName :: Lens' Session (Maybe Text)
session_documentName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Session' {Maybe Text
documentName :: Maybe Text
$sel:documentName:Session' :: Session -> Maybe Text
documentName} -> Maybe Text
documentName) (\s :: Session
s@Session' {} Maybe Text
a -> Session
s {$sel:documentName:Session' :: Maybe Text
documentName = Maybe Text
a} :: Session)

-- | The date and time, in ISO-8601 Extended format, when the session was
-- terminated.
session_endDate :: Lens.Lens' Session (Prelude.Maybe Prelude.UTCTime)
session_endDate :: Lens' Session (Maybe UTCTime)
session_endDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Session' {Maybe POSIX
endDate :: Maybe POSIX
$sel:endDate:Session' :: Session -> Maybe POSIX
endDate} -> Maybe POSIX
endDate) (\s :: Session
s@Session' {} Maybe POSIX
a -> Session
s {$sel:endDate:Session' :: Maybe POSIX
endDate = 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 maximum duration of a session before it terminates.
session_maxSessionDuration :: Lens.Lens' Session (Prelude.Maybe Prelude.Text)
session_maxSessionDuration :: Lens' Session (Maybe Text)
session_maxSessionDuration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Session' {Maybe Text
maxSessionDuration :: Maybe Text
$sel:maxSessionDuration:Session' :: Session -> Maybe Text
maxSessionDuration} -> Maybe Text
maxSessionDuration) (\s :: Session
s@Session' {} Maybe Text
a -> Session
s {$sel:maxSessionDuration:Session' :: Maybe Text
maxSessionDuration = Maybe Text
a} :: Session)

-- | Reserved for future use.
session_outputUrl :: Lens.Lens' Session (Prelude.Maybe SessionManagerOutputUrl)
session_outputUrl :: Lens' Session (Maybe SessionManagerOutputUrl)
session_outputUrl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Session' {Maybe SessionManagerOutputUrl
outputUrl :: Maybe SessionManagerOutputUrl
$sel:outputUrl:Session' :: Session -> Maybe SessionManagerOutputUrl
outputUrl} -> Maybe SessionManagerOutputUrl
outputUrl) (\s :: Session
s@Session' {} Maybe SessionManagerOutputUrl
a -> Session
s {$sel:outputUrl:Session' :: Maybe SessionManagerOutputUrl
outputUrl = Maybe SessionManagerOutputUrl
a} :: Session)

-- | The ID of the Amazon Web Services user account that started the session.
session_owner :: Lens.Lens' Session (Prelude.Maybe Prelude.Text)
session_owner :: Lens' Session (Maybe Text)
session_owner = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Session' {Maybe Text
owner :: Maybe Text
$sel:owner:Session' :: Session -> Maybe Text
owner} -> Maybe Text
owner) (\s :: Session
s@Session' {} Maybe Text
a -> Session
s {$sel:owner:Session' :: Maybe Text
owner = Maybe Text
a} :: Session)

-- | The reason for connecting to the instance.
session_reason :: Lens.Lens' Session (Prelude.Maybe Prelude.Text)
session_reason :: Lens' Session (Maybe Text)
session_reason = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Session' {Maybe Text
reason :: Maybe Text
$sel:reason:Session' :: Session -> Maybe Text
reason} -> Maybe Text
reason) (\s :: Session
s@Session' {} Maybe Text
a -> Session
s {$sel:reason:Session' :: Maybe Text
reason = Maybe Text
a} :: Session)

-- | The ID of the session.
session_sessionId :: Lens.Lens' Session (Prelude.Maybe Prelude.Text)
session_sessionId :: Lens' Session (Maybe Text)
session_sessionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Session' {Maybe Text
sessionId :: Maybe Text
$sel:sessionId:Session' :: Session -> Maybe Text
sessionId} -> Maybe Text
sessionId) (\s :: Session
s@Session' {} Maybe Text
a -> Session
s {$sel:sessionId:Session' :: Maybe Text
sessionId = Maybe Text
a} :: Session)

-- | The date and time, in ISO-8601 Extended format, when the session began.
session_startDate :: Lens.Lens' Session (Prelude.Maybe Prelude.UTCTime)
session_startDate :: Lens' Session (Maybe UTCTime)
session_startDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Session' {Maybe POSIX
startDate :: Maybe POSIX
$sel:startDate:Session' :: Session -> Maybe POSIX
startDate} -> Maybe POSIX
startDate) (\s :: Session
s@Session' {} Maybe POSIX
a -> Session
s {$sel:startDate:Session' :: Maybe POSIX
startDate = 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 status of the session. For example, \"Connected\" or \"Terminated\".
session_status :: Lens.Lens' Session (Prelude.Maybe SessionStatus)
session_status :: Lens' Session (Maybe SessionStatus)
session_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Session' {Maybe SessionStatus
status :: Maybe SessionStatus
$sel:status:Session' :: Session -> Maybe SessionStatus
status} -> Maybe SessionStatus
status) (\s :: Session
s@Session' {} Maybe SessionStatus
a -> Session
s {$sel:status:Session' :: Maybe SessionStatus
status = Maybe SessionStatus
a} :: Session)

-- | The managed node that the Session Manager session connected to.
session_target :: Lens.Lens' Session (Prelude.Maybe Prelude.Text)
session_target :: Lens' Session (Maybe Text)
session_target = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Session' {Maybe Text
target :: Maybe Text
$sel:target:Session' :: Session -> Maybe Text
target} -> Maybe Text
target) (\s :: Session
s@Session' {} Maybe Text
a -> Session
s {$sel:target:Session' :: Maybe Text
target = Maybe Text
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 Text
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe SessionManagerOutputUrl
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Maybe SessionStatus
-> Maybe Text
-> 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
"Details")
            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
"DocumentName")
            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
"EndDate")
            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
"MaxSessionDuration")
            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
"OutputUrl")
            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
"Owner")
            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
"Reason")
            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
"SessionId")
            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
"StartDate")
            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
"Status")
            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
"Target")
      )

instance Prelude.Hashable Session where
  hashWithSalt :: Int -> Session -> Int
hashWithSalt Int
_salt Session' {Maybe Text
Maybe POSIX
Maybe SessionManagerOutputUrl
Maybe SessionStatus
target :: Maybe Text
status :: Maybe SessionStatus
startDate :: Maybe POSIX
sessionId :: Maybe Text
reason :: Maybe Text
owner :: Maybe Text
outputUrl :: Maybe SessionManagerOutputUrl
maxSessionDuration :: Maybe Text
endDate :: Maybe POSIX
documentName :: Maybe Text
details :: Maybe Text
$sel:target:Session' :: Session -> Maybe Text
$sel:status:Session' :: Session -> Maybe SessionStatus
$sel:startDate:Session' :: Session -> Maybe POSIX
$sel:sessionId:Session' :: Session -> Maybe Text
$sel:reason:Session' :: Session -> Maybe Text
$sel:owner:Session' :: Session -> Maybe Text
$sel:outputUrl:Session' :: Session -> Maybe SessionManagerOutputUrl
$sel:maxSessionDuration:Session' :: Session -> Maybe Text
$sel:endDate:Session' :: Session -> Maybe POSIX
$sel:documentName:Session' :: Session -> Maybe Text
$sel:details:Session' :: Session -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
details
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
documentName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
endDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
maxSessionDuration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SessionManagerOutputUrl
outputUrl
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
owner
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
reason
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sessionId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
startDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SessionStatus
status
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
target

instance Prelude.NFData Session where
  rnf :: Session -> ()
rnf Session' {Maybe Text
Maybe POSIX
Maybe SessionManagerOutputUrl
Maybe SessionStatus
target :: Maybe Text
status :: Maybe SessionStatus
startDate :: Maybe POSIX
sessionId :: Maybe Text
reason :: Maybe Text
owner :: Maybe Text
outputUrl :: Maybe SessionManagerOutputUrl
maxSessionDuration :: Maybe Text
endDate :: Maybe POSIX
documentName :: Maybe Text
details :: Maybe Text
$sel:target:Session' :: Session -> Maybe Text
$sel:status:Session' :: Session -> Maybe SessionStatus
$sel:startDate:Session' :: Session -> Maybe POSIX
$sel:sessionId:Session' :: Session -> Maybe Text
$sel:reason:Session' :: Session -> Maybe Text
$sel:owner:Session' :: Session -> Maybe Text
$sel:outputUrl:Session' :: Session -> Maybe SessionManagerOutputUrl
$sel:maxSessionDuration:Session' :: Session -> Maybe Text
$sel:endDate:Session' :: Session -> Maybe POSIX
$sel:documentName:Session' :: Session -> Maybe Text
$sel:details:Session' :: Session -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
details
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
documentName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
endDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
maxSessionDuration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SessionManagerOutputUrl
outputUrl
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
owner
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
reason
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sessionId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
startDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SessionStatus
status
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
target