{-# 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.Athena.Types.SessionStatus
-- 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.Athena.Types.SessionStatus where

import Amazonka.Athena.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

-- | Contains information about the status of a notebook session.
--
-- /See:/ 'newSessionStatus' smart constructor.
data SessionStatus = SessionStatus'
  { -- | The date and time that the session ended.
    SessionStatus -> Maybe POSIX
endDateTime :: Prelude.Maybe Data.POSIX,
    -- | The date and time starting at which the session became idle. Can be
    -- empty if the session is not currently idle.
    SessionStatus -> Maybe POSIX
idleSinceDateTime :: Prelude.Maybe Data.POSIX,
    -- | The most recent date and time that the session was modified.
    SessionStatus -> Maybe POSIX
lastModifiedDateTime :: Prelude.Maybe Data.POSIX,
    -- | The date and time that the session started.
    SessionStatus -> Maybe POSIX
startDateTime :: Prelude.Maybe Data.POSIX,
    -- | The state of the session. A description of each state follows.
    --
    -- @CREATING@ - The session is being started, including acquiring
    -- resources.
    --
    -- @CREATED@ - The session has been started.
    --
    -- @IDLE@ - The session is able to accept a calculation.
    --
    -- @BUSY@ - The session is processing another task and is unable to accept
    -- a calculation.
    --
    -- @TERMINATING@ - The session is in the process of shutting down.
    --
    -- @TERMINATED@ - The session and its resources are no longer running.
    --
    -- @DEGRADED@ - The session has no healthy coordinators.
    --
    -- @FAILED@ - Due to a failure, the session and its resources are no longer
    -- running.
    SessionStatus -> Maybe SessionState
state :: Prelude.Maybe SessionState,
    -- | The reason for the session state change (for example, canceled because
    -- the session was terminated).
    SessionStatus -> Maybe Text
stateChangeReason :: Prelude.Maybe Prelude.Text
  }
  deriving (SessionStatus -> SessionStatus -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SessionStatus -> SessionStatus -> Bool
$c/= :: SessionStatus -> SessionStatus -> Bool
== :: SessionStatus -> SessionStatus -> Bool
$c== :: SessionStatus -> SessionStatus -> Bool
Prelude.Eq, ReadPrec [SessionStatus]
ReadPrec SessionStatus
Int -> ReadS SessionStatus
ReadS [SessionStatus]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SessionStatus]
$creadListPrec :: ReadPrec [SessionStatus]
readPrec :: ReadPrec SessionStatus
$creadPrec :: ReadPrec SessionStatus
readList :: ReadS [SessionStatus]
$creadList :: ReadS [SessionStatus]
readsPrec :: Int -> ReadS SessionStatus
$creadsPrec :: Int -> ReadS SessionStatus
Prelude.Read, Int -> SessionStatus -> ShowS
[SessionStatus] -> ShowS
SessionStatus -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SessionStatus] -> ShowS
$cshowList :: [SessionStatus] -> ShowS
show :: SessionStatus -> String
$cshow :: SessionStatus -> String
showsPrec :: Int -> SessionStatus -> ShowS
$cshowsPrec :: Int -> SessionStatus -> ShowS
Prelude.Show, forall x. Rep SessionStatus x -> SessionStatus
forall x. SessionStatus -> Rep SessionStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SessionStatus x -> SessionStatus
$cfrom :: forall x. SessionStatus -> Rep SessionStatus x
Prelude.Generic)

-- |
-- Create a value of 'SessionStatus' 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:
--
-- 'endDateTime', 'sessionStatus_endDateTime' - The date and time that the session ended.
--
-- 'idleSinceDateTime', 'sessionStatus_idleSinceDateTime' - The date and time starting at which the session became idle. Can be
-- empty if the session is not currently idle.
--
-- 'lastModifiedDateTime', 'sessionStatus_lastModifiedDateTime' - The most recent date and time that the session was modified.
--
-- 'startDateTime', 'sessionStatus_startDateTime' - The date and time that the session started.
--
-- 'state', 'sessionStatus_state' - The state of the session. A description of each state follows.
--
-- @CREATING@ - The session is being started, including acquiring
-- resources.
--
-- @CREATED@ - The session has been started.
--
-- @IDLE@ - The session is able to accept a calculation.
--
-- @BUSY@ - The session is processing another task and is unable to accept
-- a calculation.
--
-- @TERMINATING@ - The session is in the process of shutting down.
--
-- @TERMINATED@ - The session and its resources are no longer running.
--
-- @DEGRADED@ - The session has no healthy coordinators.
--
-- @FAILED@ - Due to a failure, the session and its resources are no longer
-- running.
--
-- 'stateChangeReason', 'sessionStatus_stateChangeReason' - The reason for the session state change (for example, canceled because
-- the session was terminated).
newSessionStatus ::
  SessionStatus
newSessionStatus :: SessionStatus
newSessionStatus =
  SessionStatus'
    { $sel:endDateTime:SessionStatus' :: Maybe POSIX
endDateTime = forall a. Maybe a
Prelude.Nothing,
      $sel:idleSinceDateTime:SessionStatus' :: Maybe POSIX
idleSinceDateTime = forall a. Maybe a
Prelude.Nothing,
      $sel:lastModifiedDateTime:SessionStatus' :: Maybe POSIX
lastModifiedDateTime = forall a. Maybe a
Prelude.Nothing,
      $sel:startDateTime:SessionStatus' :: Maybe POSIX
startDateTime = forall a. Maybe a
Prelude.Nothing,
      $sel:state:SessionStatus' :: Maybe SessionState
state = forall a. Maybe a
Prelude.Nothing,
      $sel:stateChangeReason:SessionStatus' :: Maybe Text
stateChangeReason = forall a. Maybe a
Prelude.Nothing
    }

-- | The date and time that the session ended.
sessionStatus_endDateTime :: Lens.Lens' SessionStatus (Prelude.Maybe Prelude.UTCTime)
sessionStatus_endDateTime :: Lens' SessionStatus (Maybe UTCTime)
sessionStatus_endDateTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SessionStatus' {Maybe POSIX
endDateTime :: Maybe POSIX
$sel:endDateTime:SessionStatus' :: SessionStatus -> Maybe POSIX
endDateTime} -> Maybe POSIX
endDateTime) (\s :: SessionStatus
s@SessionStatus' {} Maybe POSIX
a -> SessionStatus
s {$sel:endDateTime:SessionStatus' :: Maybe POSIX
endDateTime = Maybe POSIX
a} :: SessionStatus) 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 date and time starting at which the session became idle. Can be
-- empty if the session is not currently idle.
sessionStatus_idleSinceDateTime :: Lens.Lens' SessionStatus (Prelude.Maybe Prelude.UTCTime)
sessionStatus_idleSinceDateTime :: Lens' SessionStatus (Maybe UTCTime)
sessionStatus_idleSinceDateTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SessionStatus' {Maybe POSIX
idleSinceDateTime :: Maybe POSIX
$sel:idleSinceDateTime:SessionStatus' :: SessionStatus -> Maybe POSIX
idleSinceDateTime} -> Maybe POSIX
idleSinceDateTime) (\s :: SessionStatus
s@SessionStatus' {} Maybe POSIX
a -> SessionStatus
s {$sel:idleSinceDateTime:SessionStatus' :: Maybe POSIX
idleSinceDateTime = Maybe POSIX
a} :: SessionStatus) 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 most recent date and time that the session was modified.
sessionStatus_lastModifiedDateTime :: Lens.Lens' SessionStatus (Prelude.Maybe Prelude.UTCTime)
sessionStatus_lastModifiedDateTime :: Lens' SessionStatus (Maybe UTCTime)
sessionStatus_lastModifiedDateTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SessionStatus' {Maybe POSIX
lastModifiedDateTime :: Maybe POSIX
$sel:lastModifiedDateTime:SessionStatus' :: SessionStatus -> Maybe POSIX
lastModifiedDateTime} -> Maybe POSIX
lastModifiedDateTime) (\s :: SessionStatus
s@SessionStatus' {} Maybe POSIX
a -> SessionStatus
s {$sel:lastModifiedDateTime:SessionStatus' :: Maybe POSIX
lastModifiedDateTime = Maybe POSIX
a} :: SessionStatus) 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 date and time that the session started.
sessionStatus_startDateTime :: Lens.Lens' SessionStatus (Prelude.Maybe Prelude.UTCTime)
sessionStatus_startDateTime :: Lens' SessionStatus (Maybe UTCTime)
sessionStatus_startDateTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SessionStatus' {Maybe POSIX
startDateTime :: Maybe POSIX
$sel:startDateTime:SessionStatus' :: SessionStatus -> Maybe POSIX
startDateTime} -> Maybe POSIX
startDateTime) (\s :: SessionStatus
s@SessionStatus' {} Maybe POSIX
a -> SessionStatus
s {$sel:startDateTime:SessionStatus' :: Maybe POSIX
startDateTime = Maybe POSIX
a} :: SessionStatus) 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 state of the session. A description of each state follows.
--
-- @CREATING@ - The session is being started, including acquiring
-- resources.
--
-- @CREATED@ - The session has been started.
--
-- @IDLE@ - The session is able to accept a calculation.
--
-- @BUSY@ - The session is processing another task and is unable to accept
-- a calculation.
--
-- @TERMINATING@ - The session is in the process of shutting down.
--
-- @TERMINATED@ - The session and its resources are no longer running.
--
-- @DEGRADED@ - The session has no healthy coordinators.
--
-- @FAILED@ - Due to a failure, the session and its resources are no longer
-- running.
sessionStatus_state :: Lens.Lens' SessionStatus (Prelude.Maybe SessionState)
sessionStatus_state :: Lens' SessionStatus (Maybe SessionState)
sessionStatus_state = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SessionStatus' {Maybe SessionState
state :: Maybe SessionState
$sel:state:SessionStatus' :: SessionStatus -> Maybe SessionState
state} -> Maybe SessionState
state) (\s :: SessionStatus
s@SessionStatus' {} Maybe SessionState
a -> SessionStatus
s {$sel:state:SessionStatus' :: Maybe SessionState
state = Maybe SessionState
a} :: SessionStatus)

-- | The reason for the session state change (for example, canceled because
-- the session was terminated).
sessionStatus_stateChangeReason :: Lens.Lens' SessionStatus (Prelude.Maybe Prelude.Text)
sessionStatus_stateChangeReason :: Lens' SessionStatus (Maybe Text)
sessionStatus_stateChangeReason = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SessionStatus' {Maybe Text
stateChangeReason :: Maybe Text
$sel:stateChangeReason:SessionStatus' :: SessionStatus -> Maybe Text
stateChangeReason} -> Maybe Text
stateChangeReason) (\s :: SessionStatus
s@SessionStatus' {} Maybe Text
a -> SessionStatus
s {$sel:stateChangeReason:SessionStatus' :: Maybe Text
stateChangeReason = Maybe Text
a} :: SessionStatus)

instance Data.FromJSON SessionStatus where
  parseJSON :: Value -> Parser SessionStatus
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SessionStatus"
      ( \Object
x ->
          Maybe POSIX
-> Maybe POSIX
-> Maybe POSIX
-> Maybe POSIX
-> Maybe SessionState
-> Maybe Text
-> SessionStatus
SessionStatus'
            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
"EndDateTime")
            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
"IdleSinceDateTime")
            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
"LastModifiedDateTime")
            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
"StartDateTime")
            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
"State")
            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
"StateChangeReason")
      )

instance Prelude.Hashable SessionStatus where
  hashWithSalt :: Int -> SessionStatus -> Int
hashWithSalt Int
_salt SessionStatus' {Maybe Text
Maybe POSIX
Maybe SessionState
stateChangeReason :: Maybe Text
state :: Maybe SessionState
startDateTime :: Maybe POSIX
lastModifiedDateTime :: Maybe POSIX
idleSinceDateTime :: Maybe POSIX
endDateTime :: Maybe POSIX
$sel:stateChangeReason:SessionStatus' :: SessionStatus -> Maybe Text
$sel:state:SessionStatus' :: SessionStatus -> Maybe SessionState
$sel:startDateTime:SessionStatus' :: SessionStatus -> Maybe POSIX
$sel:lastModifiedDateTime:SessionStatus' :: SessionStatus -> Maybe POSIX
$sel:idleSinceDateTime:SessionStatus' :: SessionStatus -> Maybe POSIX
$sel:endDateTime:SessionStatus' :: SessionStatus -> Maybe POSIX
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
endDateTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
idleSinceDateTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
lastModifiedDateTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
startDateTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SessionState
state
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
stateChangeReason

instance Prelude.NFData SessionStatus where
  rnf :: SessionStatus -> ()
rnf SessionStatus' {Maybe Text
Maybe POSIX
Maybe SessionState
stateChangeReason :: Maybe Text
state :: Maybe SessionState
startDateTime :: Maybe POSIX
lastModifiedDateTime :: Maybe POSIX
idleSinceDateTime :: Maybe POSIX
endDateTime :: Maybe POSIX
$sel:stateChangeReason:SessionStatus' :: SessionStatus -> Maybe Text
$sel:state:SessionStatus' :: SessionStatus -> Maybe SessionState
$sel:startDateTime:SessionStatus' :: SessionStatus -> Maybe POSIX
$sel:lastModifiedDateTime:SessionStatus' :: SessionStatus -> Maybe POSIX
$sel:idleSinceDateTime:SessionStatus' :: SessionStatus -> Maybe POSIX
$sel:endDateTime:SessionStatus' :: SessionStatus -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
endDateTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
idleSinceDateTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
lastModifiedDateTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
startDateTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SessionState
state
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
stateChangeReason