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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SSM.Types.SessionManagerOutputUrl
import Amazonka.SSM.Types.SessionStatus

-- | Information about a Session Manager connection to an instance.
--
-- /See:/ 'newSession' smart constructor.
data Session = Session'
  { -- | The status of the session. For example, \"Connected\" or \"Terminated\".
    Session -> Maybe SessionStatus
status :: Prelude.Maybe SessionStatus,
    -- | Reserved for future use.
    Session -> Maybe SessionManagerOutputUrl
outputUrl :: Prelude.Maybe SessionManagerOutputUrl,
    -- | 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 Core.POSIX,
    -- | The ID of the Amazon Web Services user account that started the session.
    Session -> Maybe Text
owner :: Prelude.Maybe Prelude.Text,
    -- | The date and time, in ISO-8601 Extended format, when the session began.
    Session -> Maybe POSIX
startDate :: Prelude.Maybe Core.POSIX,
    -- | Reserved for future use.
    Session -> Maybe Text
details :: Prelude.Maybe Prelude.Text,
    -- | The ID of the session.
    Session -> Maybe Text
sessionId :: Prelude.Maybe Prelude.Text,
    -- | The instance that the Session Manager session connected to.
    Session -> Maybe Text
target :: Prelude.Maybe Prelude.Text
  }
  deriving (Session -> Session -> Bool
(Session -> Session -> Bool)
-> (Session -> Session -> Bool) -> Eq Session
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]
(Int -> ReadS Session)
-> ReadS [Session]
-> ReadPrec Session
-> ReadPrec [Session]
-> Read 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
(Int -> Session -> ShowS)
-> (Session -> String) -> ([Session] -> ShowS) -> Show Session
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. Session -> Rep Session x)
-> (forall x. Rep Session x -> Session) -> Generic Session
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:
--
-- 'status', 'session_status' - The status of the session. For example, \"Connected\" or \"Terminated\".
--
-- 'outputUrl', 'session_outputUrl' - 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.
--
-- 'owner', 'session_owner' - The ID of the Amazon Web Services user account that started the session.
--
-- 'startDate', 'session_startDate' - The date and time, in ISO-8601 Extended format, when the session began.
--
-- 'details', 'session_details' - Reserved for future use.
--
-- 'sessionId', 'session_sessionId' - The ID of the session.
--
-- 'target', 'session_target' - The instance that the Session Manager session connected to.
newSession ::
  Session
newSession :: Session
newSession =
  Session' :: Maybe SessionStatus
-> Maybe SessionManagerOutputUrl
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Session
Session'
    { $sel:status:Session' :: Maybe SessionStatus
status = Maybe SessionStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:outputUrl:Session' :: Maybe SessionManagerOutputUrl
outputUrl = Maybe SessionManagerOutputUrl
forall a. Maybe a
Prelude.Nothing,
      $sel:documentName:Session' :: Maybe Text
documentName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:endDate:Session' :: Maybe POSIX
endDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:owner:Session' :: Maybe Text
owner = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:startDate:Session' :: Maybe POSIX
startDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:details:Session' :: Maybe Text
details = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sessionId:Session' :: Maybe Text
sessionId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:target:Session' :: Maybe Text
target = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The status of the session. For example, \"Connected\" or \"Terminated\".
session_status :: Lens.Lens' Session (Prelude.Maybe SessionStatus)
session_status :: (Maybe SessionStatus -> f (Maybe SessionStatus))
-> Session -> f Session
session_status = (Session -> Maybe SessionStatus)
-> (Session -> Maybe SessionStatus -> Session)
-> Lens Session Session (Maybe SessionStatus) (Maybe SessionStatus)
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)

-- | Reserved for future use.
session_outputUrl :: Lens.Lens' Session (Prelude.Maybe SessionManagerOutputUrl)
session_outputUrl :: (Maybe SessionManagerOutputUrl
 -> f (Maybe SessionManagerOutputUrl))
-> Session -> f Session
session_outputUrl = (Session -> Maybe SessionManagerOutputUrl)
-> (Session -> Maybe SessionManagerOutputUrl -> Session)
-> Lens
     Session
     Session
     (Maybe SessionManagerOutputUrl)
     (Maybe SessionManagerOutputUrl)
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 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 :: (Maybe Text -> f (Maybe Text)) -> Session -> f Session
session_documentName = (Session -> Maybe Text)
-> (Session -> Maybe Text -> Session)
-> Lens Session Session (Maybe Text) (Maybe Text)
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 :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Session -> f Session
session_endDate = (Session -> Maybe POSIX)
-> (Session -> Maybe POSIX -> Session)
-> Lens Session Session (Maybe POSIX) (Maybe POSIX)
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) ((Maybe POSIX -> f (Maybe POSIX)) -> Session -> f Session)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Session
-> f Session
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 ID of the Amazon Web Services user account that started the session.
session_owner :: Lens.Lens' Session (Prelude.Maybe Prelude.Text)
session_owner :: (Maybe Text -> f (Maybe Text)) -> Session -> f Session
session_owner = (Session -> Maybe Text)
-> (Session -> Maybe Text -> Session)
-> Lens Session Session (Maybe Text) (Maybe Text)
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 date and time, in ISO-8601 Extended format, when the session began.
session_startDate :: Lens.Lens' Session (Prelude.Maybe Prelude.UTCTime)
session_startDate :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Session -> f Session
session_startDate = (Session -> Maybe POSIX)
-> (Session -> Maybe POSIX -> Session)
-> Lens Session Session (Maybe POSIX) (Maybe POSIX)
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) ((Maybe POSIX -> f (Maybe POSIX)) -> Session -> f Session)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Session
-> f Session
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

-- | Reserved for future use.
session_details :: Lens.Lens' Session (Prelude.Maybe Prelude.Text)
session_details :: (Maybe Text -> f (Maybe Text)) -> Session -> f Session
session_details = (Session -> Maybe Text)
-> (Session -> Maybe Text -> Session)
-> Lens Session Session (Maybe Text) (Maybe Text)
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 ID of the session.
session_sessionId :: Lens.Lens' Session (Prelude.Maybe Prelude.Text)
session_sessionId :: (Maybe Text -> f (Maybe Text)) -> Session -> f Session
session_sessionId = (Session -> Maybe Text)
-> (Session -> Maybe Text -> Session)
-> Lens Session Session (Maybe Text) (Maybe Text)
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 instance that the Session Manager session connected to.
session_target :: Lens.Lens' Session (Prelude.Maybe Prelude.Text)
session_target :: (Maybe Text -> f (Maybe Text)) -> Session -> f Session
session_target = (Session -> Maybe Text)
-> (Session -> Maybe Text -> Session)
-> Lens Session Session (Maybe Text) (Maybe Text)
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 Core.FromJSON Session where
  parseJSON :: Value -> Parser Session
parseJSON =
    String -> (Object -> Parser Session) -> Value -> Parser Session
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Session"
      ( \Object
x ->
          Maybe SessionStatus
-> Maybe SessionManagerOutputUrl
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Session
Session'
            (Maybe SessionStatus
 -> Maybe SessionManagerOutputUrl
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Session)
-> Parser (Maybe SessionStatus)
-> Parser
     (Maybe SessionManagerOutputUrl
      -> Maybe Text
      -> Maybe POSIX
      -> Maybe Text
      -> Maybe POSIX
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Session)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe SessionStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Status")
            Parser
  (Maybe SessionManagerOutputUrl
   -> Maybe Text
   -> Maybe POSIX
   -> Maybe Text
   -> Maybe POSIX
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Session)
-> Parser (Maybe SessionManagerOutputUrl)
-> Parser
     (Maybe Text
      -> Maybe POSIX
      -> Maybe Text
      -> Maybe POSIX
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Session)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe SessionManagerOutputUrl)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"OutputUrl")
            Parser
  (Maybe Text
   -> Maybe POSIX
   -> Maybe Text
   -> Maybe POSIX
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Session)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX
      -> Maybe Text
      -> Maybe POSIX
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Session)
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
"DocumentName")
            Parser
  (Maybe POSIX
   -> Maybe Text
   -> Maybe POSIX
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Session)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Text
      -> Maybe POSIX
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Session)
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
"EndDate")
            Parser
  (Maybe Text
   -> Maybe POSIX
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Session)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX -> Maybe Text -> Maybe Text -> Maybe Text -> Session)
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
"Owner")
            Parser
  (Maybe POSIX -> Maybe Text -> Maybe Text -> Maybe Text -> Session)
-> Parser (Maybe POSIX)
-> Parser (Maybe Text -> Maybe Text -> Maybe Text -> Session)
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
"StartDate")
            Parser (Maybe Text -> Maybe Text -> Maybe Text -> Session)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Session)
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
"Details")
            Parser (Maybe Text -> Maybe Text -> Session)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Session)
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
"SessionId")
            Parser (Maybe Text -> Session)
-> Parser (Maybe Text) -> Parser Session
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
"Target")
      )

instance Prelude.Hashable Session

instance Prelude.NFData Session