{-# 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.IVS.Types.StreamSession
-- 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.IVS.Types.StreamSession where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IVS.Types.Channel
import Amazonka.IVS.Types.IngestConfiguration
import Amazonka.IVS.Types.RecordingConfiguration
import Amazonka.IVS.Types.StreamEvent
import qualified Amazonka.Prelude as Prelude

-- | Object that captures the Amazon IVS configuration that the customer
-- provisioned, the ingest configurations that the broadcaster used, and
-- the most recent Amazon IVS stream events it encountered.
--
-- /See:/ 'newStreamSession' smart constructor.
data StreamSession = StreamSession'
  { -- | The properties of the channel at the time of going live.
    StreamSession -> Maybe Channel
channel :: Prelude.Maybe Channel,
    -- | Time when the channel went offline. This is an ISO 8601 timestamp; /note
    -- that this is returned as a string/. For live streams, this is @NULL@.
    StreamSession -> Maybe ISO8601
endTime :: Prelude.Maybe Data.ISO8601,
    -- | The properties of the incoming RTMP stream for the stream.
    StreamSession -> Maybe IngestConfiguration
ingestConfiguration :: Prelude.Maybe IngestConfiguration,
    -- | The properties of recording the live stream.
    StreamSession -> Maybe RecordingConfiguration
recordingConfiguration :: Prelude.Maybe RecordingConfiguration,
    -- | Time when the channel went live. This is an ISO 8601 timestamp; /note
    -- that this is returned as a string/.
    StreamSession -> Maybe ISO8601
startTime :: Prelude.Maybe Data.ISO8601,
    -- | Unique identifier for a live or previously live stream in the specified
    -- channel.
    StreamSession -> Maybe Text
streamId :: Prelude.Maybe Prelude.Text,
    -- | List of Amazon IVS events that the stream encountered. The list is
    -- sorted by most recent events and contains up to 500 events. For Amazon
    -- IVS events, see
    -- <https://docs.aws.amazon.com/ivs/latest/userguide/eventbridge.html Using Amazon EventBridge with Amazon IVS>.
    StreamSession -> Maybe [StreamEvent]
truncatedEvents :: Prelude.Maybe [StreamEvent]
  }
  deriving (StreamSession -> StreamSession -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StreamSession -> StreamSession -> Bool
$c/= :: StreamSession -> StreamSession -> Bool
== :: StreamSession -> StreamSession -> Bool
$c== :: StreamSession -> StreamSession -> Bool
Prelude.Eq, ReadPrec [StreamSession]
ReadPrec StreamSession
Int -> ReadS StreamSession
ReadS [StreamSession]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StreamSession]
$creadListPrec :: ReadPrec [StreamSession]
readPrec :: ReadPrec StreamSession
$creadPrec :: ReadPrec StreamSession
readList :: ReadS [StreamSession]
$creadList :: ReadS [StreamSession]
readsPrec :: Int -> ReadS StreamSession
$creadsPrec :: Int -> ReadS StreamSession
Prelude.Read, Int -> StreamSession -> ShowS
[StreamSession] -> ShowS
StreamSession -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StreamSession] -> ShowS
$cshowList :: [StreamSession] -> ShowS
show :: StreamSession -> String
$cshow :: StreamSession -> String
showsPrec :: Int -> StreamSession -> ShowS
$cshowsPrec :: Int -> StreamSession -> ShowS
Prelude.Show, forall x. Rep StreamSession x -> StreamSession
forall x. StreamSession -> Rep StreamSession x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StreamSession x -> StreamSession
$cfrom :: forall x. StreamSession -> Rep StreamSession x
Prelude.Generic)

-- |
-- Create a value of 'StreamSession' 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:
--
-- 'channel', 'streamSession_channel' - The properties of the channel at the time of going live.
--
-- 'endTime', 'streamSession_endTime' - Time when the channel went offline. This is an ISO 8601 timestamp; /note
-- that this is returned as a string/. For live streams, this is @NULL@.
--
-- 'ingestConfiguration', 'streamSession_ingestConfiguration' - The properties of the incoming RTMP stream for the stream.
--
-- 'recordingConfiguration', 'streamSession_recordingConfiguration' - The properties of recording the live stream.
--
-- 'startTime', 'streamSession_startTime' - Time when the channel went live. This is an ISO 8601 timestamp; /note
-- that this is returned as a string/.
--
-- 'streamId', 'streamSession_streamId' - Unique identifier for a live or previously live stream in the specified
-- channel.
--
-- 'truncatedEvents', 'streamSession_truncatedEvents' - List of Amazon IVS events that the stream encountered. The list is
-- sorted by most recent events and contains up to 500 events. For Amazon
-- IVS events, see
-- <https://docs.aws.amazon.com/ivs/latest/userguide/eventbridge.html Using Amazon EventBridge with Amazon IVS>.
newStreamSession ::
  StreamSession
newStreamSession :: StreamSession
newStreamSession =
  StreamSession'
    { $sel:channel:StreamSession' :: Maybe Channel
channel = forall a. Maybe a
Prelude.Nothing,
      $sel:endTime:StreamSession' :: Maybe ISO8601
endTime = forall a. Maybe a
Prelude.Nothing,
      $sel:ingestConfiguration:StreamSession' :: Maybe IngestConfiguration
ingestConfiguration = forall a. Maybe a
Prelude.Nothing,
      $sel:recordingConfiguration:StreamSession' :: Maybe RecordingConfiguration
recordingConfiguration = forall a. Maybe a
Prelude.Nothing,
      $sel:startTime:StreamSession' :: Maybe ISO8601
startTime = forall a. Maybe a
Prelude.Nothing,
      $sel:streamId:StreamSession' :: Maybe Text
streamId = forall a. Maybe a
Prelude.Nothing,
      $sel:truncatedEvents:StreamSession' :: Maybe [StreamEvent]
truncatedEvents = forall a. Maybe a
Prelude.Nothing
    }

-- | The properties of the channel at the time of going live.
streamSession_channel :: Lens.Lens' StreamSession (Prelude.Maybe Channel)
streamSession_channel :: Lens' StreamSession (Maybe Channel)
streamSession_channel = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StreamSession' {Maybe Channel
channel :: Maybe Channel
$sel:channel:StreamSession' :: StreamSession -> Maybe Channel
channel} -> Maybe Channel
channel) (\s :: StreamSession
s@StreamSession' {} Maybe Channel
a -> StreamSession
s {$sel:channel:StreamSession' :: Maybe Channel
channel = Maybe Channel
a} :: StreamSession)

-- | Time when the channel went offline. This is an ISO 8601 timestamp; /note
-- that this is returned as a string/. For live streams, this is @NULL@.
streamSession_endTime :: Lens.Lens' StreamSession (Prelude.Maybe Prelude.UTCTime)
streamSession_endTime :: Lens' StreamSession (Maybe UTCTime)
streamSession_endTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StreamSession' {Maybe ISO8601
endTime :: Maybe ISO8601
$sel:endTime:StreamSession' :: StreamSession -> Maybe ISO8601
endTime} -> Maybe ISO8601
endTime) (\s :: StreamSession
s@StreamSession' {} Maybe ISO8601
a -> StreamSession
s {$sel:endTime:StreamSession' :: Maybe ISO8601
endTime = Maybe ISO8601
a} :: StreamSession) 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 properties of the incoming RTMP stream for the stream.
streamSession_ingestConfiguration :: Lens.Lens' StreamSession (Prelude.Maybe IngestConfiguration)
streamSession_ingestConfiguration :: Lens' StreamSession (Maybe IngestConfiguration)
streamSession_ingestConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StreamSession' {Maybe IngestConfiguration
ingestConfiguration :: Maybe IngestConfiguration
$sel:ingestConfiguration:StreamSession' :: StreamSession -> Maybe IngestConfiguration
ingestConfiguration} -> Maybe IngestConfiguration
ingestConfiguration) (\s :: StreamSession
s@StreamSession' {} Maybe IngestConfiguration
a -> StreamSession
s {$sel:ingestConfiguration:StreamSession' :: Maybe IngestConfiguration
ingestConfiguration = Maybe IngestConfiguration
a} :: StreamSession)

-- | The properties of recording the live stream.
streamSession_recordingConfiguration :: Lens.Lens' StreamSession (Prelude.Maybe RecordingConfiguration)
streamSession_recordingConfiguration :: Lens' StreamSession (Maybe RecordingConfiguration)
streamSession_recordingConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StreamSession' {Maybe RecordingConfiguration
recordingConfiguration :: Maybe RecordingConfiguration
$sel:recordingConfiguration:StreamSession' :: StreamSession -> Maybe RecordingConfiguration
recordingConfiguration} -> Maybe RecordingConfiguration
recordingConfiguration) (\s :: StreamSession
s@StreamSession' {} Maybe RecordingConfiguration
a -> StreamSession
s {$sel:recordingConfiguration:StreamSession' :: Maybe RecordingConfiguration
recordingConfiguration = Maybe RecordingConfiguration
a} :: StreamSession)

-- | Time when the channel went live. This is an ISO 8601 timestamp; /note
-- that this is returned as a string/.
streamSession_startTime :: Lens.Lens' StreamSession (Prelude.Maybe Prelude.UTCTime)
streamSession_startTime :: Lens' StreamSession (Maybe UTCTime)
streamSession_startTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StreamSession' {Maybe ISO8601
startTime :: Maybe ISO8601
$sel:startTime:StreamSession' :: StreamSession -> Maybe ISO8601
startTime} -> Maybe ISO8601
startTime) (\s :: StreamSession
s@StreamSession' {} Maybe ISO8601
a -> StreamSession
s {$sel:startTime:StreamSession' :: Maybe ISO8601
startTime = Maybe ISO8601
a} :: StreamSession) 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

-- | Unique identifier for a live or previously live stream in the specified
-- channel.
streamSession_streamId :: Lens.Lens' StreamSession (Prelude.Maybe Prelude.Text)
streamSession_streamId :: Lens' StreamSession (Maybe Text)
streamSession_streamId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StreamSession' {Maybe Text
streamId :: Maybe Text
$sel:streamId:StreamSession' :: StreamSession -> Maybe Text
streamId} -> Maybe Text
streamId) (\s :: StreamSession
s@StreamSession' {} Maybe Text
a -> StreamSession
s {$sel:streamId:StreamSession' :: Maybe Text
streamId = Maybe Text
a} :: StreamSession)

-- | List of Amazon IVS events that the stream encountered. The list is
-- sorted by most recent events and contains up to 500 events. For Amazon
-- IVS events, see
-- <https://docs.aws.amazon.com/ivs/latest/userguide/eventbridge.html Using Amazon EventBridge with Amazon IVS>.
streamSession_truncatedEvents :: Lens.Lens' StreamSession (Prelude.Maybe [StreamEvent])
streamSession_truncatedEvents :: Lens' StreamSession (Maybe [StreamEvent])
streamSession_truncatedEvents = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StreamSession' {Maybe [StreamEvent]
truncatedEvents :: Maybe [StreamEvent]
$sel:truncatedEvents:StreamSession' :: StreamSession -> Maybe [StreamEvent]
truncatedEvents} -> Maybe [StreamEvent]
truncatedEvents) (\s :: StreamSession
s@StreamSession' {} Maybe [StreamEvent]
a -> StreamSession
s {$sel:truncatedEvents:StreamSession' :: Maybe [StreamEvent]
truncatedEvents = Maybe [StreamEvent]
a} :: StreamSession) 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 s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON StreamSession where
  parseJSON :: Value -> Parser StreamSession
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"StreamSession"
      ( \Object
x ->
          Maybe Channel
-> Maybe ISO8601
-> Maybe IngestConfiguration
-> Maybe RecordingConfiguration
-> Maybe ISO8601
-> Maybe Text
-> Maybe [StreamEvent]
-> StreamSession
StreamSession'
            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
"channel")
            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
"endTime")
            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
"ingestConfiguration")
            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
"recordingConfiguration")
            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 (Maybe a)
Data..:? Key
"streamId")
            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
"truncatedEvents"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable StreamSession where
  hashWithSalt :: Int -> StreamSession -> Int
hashWithSalt Int
_salt StreamSession' {Maybe [StreamEvent]
Maybe Text
Maybe ISO8601
Maybe Channel
Maybe RecordingConfiguration
Maybe IngestConfiguration
truncatedEvents :: Maybe [StreamEvent]
streamId :: Maybe Text
startTime :: Maybe ISO8601
recordingConfiguration :: Maybe RecordingConfiguration
ingestConfiguration :: Maybe IngestConfiguration
endTime :: Maybe ISO8601
channel :: Maybe Channel
$sel:truncatedEvents:StreamSession' :: StreamSession -> Maybe [StreamEvent]
$sel:streamId:StreamSession' :: StreamSession -> Maybe Text
$sel:startTime:StreamSession' :: StreamSession -> Maybe ISO8601
$sel:recordingConfiguration:StreamSession' :: StreamSession -> Maybe RecordingConfiguration
$sel:ingestConfiguration:StreamSession' :: StreamSession -> Maybe IngestConfiguration
$sel:endTime:StreamSession' :: StreamSession -> Maybe ISO8601
$sel:channel:StreamSession' :: StreamSession -> Maybe Channel
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Channel
channel
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
endTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe IngestConfiguration
ingestConfiguration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RecordingConfiguration
recordingConfiguration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
startTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
streamId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [StreamEvent]
truncatedEvents

instance Prelude.NFData StreamSession where
  rnf :: StreamSession -> ()
rnf StreamSession' {Maybe [StreamEvent]
Maybe Text
Maybe ISO8601
Maybe Channel
Maybe RecordingConfiguration
Maybe IngestConfiguration
truncatedEvents :: Maybe [StreamEvent]
streamId :: Maybe Text
startTime :: Maybe ISO8601
recordingConfiguration :: Maybe RecordingConfiguration
ingestConfiguration :: Maybe IngestConfiguration
endTime :: Maybe ISO8601
channel :: Maybe Channel
$sel:truncatedEvents:StreamSession' :: StreamSession -> Maybe [StreamEvent]
$sel:streamId:StreamSession' :: StreamSession -> Maybe Text
$sel:startTime:StreamSession' :: StreamSession -> Maybe ISO8601
$sel:recordingConfiguration:StreamSession' :: StreamSession -> Maybe RecordingConfiguration
$sel:ingestConfiguration:StreamSession' :: StreamSession -> Maybe IngestConfiguration
$sel:endTime:StreamSession' :: StreamSession -> Maybe ISO8601
$sel:channel:StreamSession' :: StreamSession -> Maybe Channel
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Channel
channel
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
endTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe IngestConfiguration
ingestConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RecordingConfiguration
recordingConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
startTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
streamId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [StreamEvent]
truncatedEvents