{-# 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.Stream
-- 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.Stream 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.StreamHealth
import Amazonka.IVS.Types.StreamState
import qualified Amazonka.Prelude as Prelude

-- | Specifies a live video stream that has been ingested and distributed.
--
-- /See:/ 'newStream' smart constructor.
data Stream = Stream'
  { -- | Channel ARN for the stream.
    Stream -> Maybe Text
channelArn :: Prelude.Maybe Prelude.Text,
    -- | The stream’s health.
    Stream -> Maybe StreamHealth
health :: Prelude.Maybe StreamHealth,
    -- | URL of the master playlist, required by the video player to play the HLS
    -- stream.
    Stream -> Maybe Text
playbackUrl :: Prelude.Maybe Prelude.Text,
    -- | Time of the stream’s start. This is an ISO 8601 timestamp; /note that
    -- this is returned as a string/.
    Stream -> Maybe ISO8601
startTime :: Prelude.Maybe Data.ISO8601,
    -- | The stream’s state.
    Stream -> Maybe StreamState
state :: Prelude.Maybe StreamState,
    -- | Unique identifier for a live or previously live stream in the specified
    -- channel.
    Stream -> Maybe Text
streamId :: Prelude.Maybe Prelude.Text,
    -- | A count of concurrent views of the stream. Typically, a new view appears
    -- in @viewerCount@ within 15 seconds of when video playback starts and a
    -- view is removed from @viewerCount@ within 1 minute of when video
    -- playback ends. A value of -1 indicates that the request timed out; in
    -- this case, retry.
    Stream -> Maybe Integer
viewerCount :: Prelude.Maybe Prelude.Integer
  }
  deriving (Stream -> Stream -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Stream -> Stream -> Bool
$c/= :: Stream -> Stream -> Bool
== :: Stream -> Stream -> Bool
$c== :: Stream -> Stream -> Bool
Prelude.Eq, ReadPrec [Stream]
ReadPrec Stream
Int -> ReadS Stream
ReadS [Stream]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Stream]
$creadListPrec :: ReadPrec [Stream]
readPrec :: ReadPrec Stream
$creadPrec :: ReadPrec Stream
readList :: ReadS [Stream]
$creadList :: ReadS [Stream]
readsPrec :: Int -> ReadS Stream
$creadsPrec :: Int -> ReadS Stream
Prelude.Read, Int -> Stream -> ShowS
[Stream] -> ShowS
Stream -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Stream] -> ShowS
$cshowList :: [Stream] -> ShowS
show :: Stream -> String
$cshow :: Stream -> String
showsPrec :: Int -> Stream -> ShowS
$cshowsPrec :: Int -> Stream -> ShowS
Prelude.Show, forall x. Rep Stream x -> Stream
forall x. Stream -> Rep Stream x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Stream x -> Stream
$cfrom :: forall x. Stream -> Rep Stream x
Prelude.Generic)

-- |
-- Create a value of 'Stream' 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:
--
-- 'channelArn', 'stream_channelArn' - Channel ARN for the stream.
--
-- 'health', 'stream_health' - The stream’s health.
--
-- 'playbackUrl', 'stream_playbackUrl' - URL of the master playlist, required by the video player to play the HLS
-- stream.
--
-- 'startTime', 'stream_startTime' - Time of the stream’s start. This is an ISO 8601 timestamp; /note that
-- this is returned as a string/.
--
-- 'state', 'stream_state' - The stream’s state.
--
-- 'streamId', 'stream_streamId' - Unique identifier for a live or previously live stream in the specified
-- channel.
--
-- 'viewerCount', 'stream_viewerCount' - A count of concurrent views of the stream. Typically, a new view appears
-- in @viewerCount@ within 15 seconds of when video playback starts and a
-- view is removed from @viewerCount@ within 1 minute of when video
-- playback ends. A value of -1 indicates that the request timed out; in
-- this case, retry.
newStream ::
  Stream
newStream :: Stream
newStream =
  Stream'
    { $sel:channelArn:Stream' :: Maybe Text
channelArn = forall a. Maybe a
Prelude.Nothing,
      $sel:health:Stream' :: Maybe StreamHealth
health = forall a. Maybe a
Prelude.Nothing,
      $sel:playbackUrl:Stream' :: Maybe Text
playbackUrl = forall a. Maybe a
Prelude.Nothing,
      $sel:startTime:Stream' :: Maybe ISO8601
startTime = forall a. Maybe a
Prelude.Nothing,
      $sel:state:Stream' :: Maybe StreamState
state = forall a. Maybe a
Prelude.Nothing,
      $sel:streamId:Stream' :: Maybe Text
streamId = forall a. Maybe a
Prelude.Nothing,
      $sel:viewerCount:Stream' :: Maybe Integer
viewerCount = forall a. Maybe a
Prelude.Nothing
    }

-- | Channel ARN for the stream.
stream_channelArn :: Lens.Lens' Stream (Prelude.Maybe Prelude.Text)
stream_channelArn :: Lens' Stream (Maybe Text)
stream_channelArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Stream' {Maybe Text
channelArn :: Maybe Text
$sel:channelArn:Stream' :: Stream -> Maybe Text
channelArn} -> Maybe Text
channelArn) (\s :: Stream
s@Stream' {} Maybe Text
a -> Stream
s {$sel:channelArn:Stream' :: Maybe Text
channelArn = Maybe Text
a} :: Stream)

-- | The stream’s health.
stream_health :: Lens.Lens' Stream (Prelude.Maybe StreamHealth)
stream_health :: Lens' Stream (Maybe StreamHealth)
stream_health = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Stream' {Maybe StreamHealth
health :: Maybe StreamHealth
$sel:health:Stream' :: Stream -> Maybe StreamHealth
health} -> Maybe StreamHealth
health) (\s :: Stream
s@Stream' {} Maybe StreamHealth
a -> Stream
s {$sel:health:Stream' :: Maybe StreamHealth
health = Maybe StreamHealth
a} :: Stream)

-- | URL of the master playlist, required by the video player to play the HLS
-- stream.
stream_playbackUrl :: Lens.Lens' Stream (Prelude.Maybe Prelude.Text)
stream_playbackUrl :: Lens' Stream (Maybe Text)
stream_playbackUrl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Stream' {Maybe Text
playbackUrl :: Maybe Text
$sel:playbackUrl:Stream' :: Stream -> Maybe Text
playbackUrl} -> Maybe Text
playbackUrl) (\s :: Stream
s@Stream' {} Maybe Text
a -> Stream
s {$sel:playbackUrl:Stream' :: Maybe Text
playbackUrl = Maybe Text
a} :: Stream)

-- | Time of the stream’s start. This is an ISO 8601 timestamp; /note that
-- this is returned as a string/.
stream_startTime :: Lens.Lens' Stream (Prelude.Maybe Prelude.UTCTime)
stream_startTime :: Lens' Stream (Maybe UTCTime)
stream_startTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Stream' {Maybe ISO8601
startTime :: Maybe ISO8601
$sel:startTime:Stream' :: Stream -> Maybe ISO8601
startTime} -> Maybe ISO8601
startTime) (\s :: Stream
s@Stream' {} Maybe ISO8601
a -> Stream
s {$sel:startTime:Stream' :: Maybe ISO8601
startTime = Maybe ISO8601
a} :: Stream) 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 stream’s state.
stream_state :: Lens.Lens' Stream (Prelude.Maybe StreamState)
stream_state :: Lens' Stream (Maybe StreamState)
stream_state = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Stream' {Maybe StreamState
state :: Maybe StreamState
$sel:state:Stream' :: Stream -> Maybe StreamState
state} -> Maybe StreamState
state) (\s :: Stream
s@Stream' {} Maybe StreamState
a -> Stream
s {$sel:state:Stream' :: Maybe StreamState
state = Maybe StreamState
a} :: Stream)

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

-- | A count of concurrent views of the stream. Typically, a new view appears
-- in @viewerCount@ within 15 seconds of when video playback starts and a
-- view is removed from @viewerCount@ within 1 minute of when video
-- playback ends. A value of -1 indicates that the request timed out; in
-- this case, retry.
stream_viewerCount :: Lens.Lens' Stream (Prelude.Maybe Prelude.Integer)
stream_viewerCount :: Lens' Stream (Maybe Integer)
stream_viewerCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Stream' {Maybe Integer
viewerCount :: Maybe Integer
$sel:viewerCount:Stream' :: Stream -> Maybe Integer
viewerCount} -> Maybe Integer
viewerCount) (\s :: Stream
s@Stream' {} Maybe Integer
a -> Stream
s {$sel:viewerCount:Stream' :: Maybe Integer
viewerCount = Maybe Integer
a} :: Stream)

instance Data.FromJSON Stream where
  parseJSON :: Value -> Parser Stream
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Stream"
      ( \Object
x ->
          Maybe Text
-> Maybe StreamHealth
-> Maybe Text
-> Maybe ISO8601
-> Maybe StreamState
-> Maybe Text
-> Maybe Integer
-> Stream
Stream'
            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
"channelArn")
            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
"health")
            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
"playbackUrl")
            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
"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
"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
"viewerCount")
      )

instance Prelude.Hashable Stream where
  hashWithSalt :: Int -> Stream -> Int
hashWithSalt Int
_salt Stream' {Maybe Integer
Maybe Text
Maybe ISO8601
Maybe StreamHealth
Maybe StreamState
viewerCount :: Maybe Integer
streamId :: Maybe Text
state :: Maybe StreamState
startTime :: Maybe ISO8601
playbackUrl :: Maybe Text
health :: Maybe StreamHealth
channelArn :: Maybe Text
$sel:viewerCount:Stream' :: Stream -> Maybe Integer
$sel:streamId:Stream' :: Stream -> Maybe Text
$sel:state:Stream' :: Stream -> Maybe StreamState
$sel:startTime:Stream' :: Stream -> Maybe ISO8601
$sel:playbackUrl:Stream' :: Stream -> Maybe Text
$sel:health:Stream' :: Stream -> Maybe StreamHealth
$sel:channelArn:Stream' :: Stream -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
channelArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe StreamHealth
health
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
playbackUrl
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
startTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe StreamState
state
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
streamId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
viewerCount

instance Prelude.NFData Stream where
  rnf :: Stream -> ()
rnf Stream' {Maybe Integer
Maybe Text
Maybe ISO8601
Maybe StreamHealth
Maybe StreamState
viewerCount :: Maybe Integer
streamId :: Maybe Text
state :: Maybe StreamState
startTime :: Maybe ISO8601
playbackUrl :: Maybe Text
health :: Maybe StreamHealth
channelArn :: Maybe Text
$sel:viewerCount:Stream' :: Stream -> Maybe Integer
$sel:streamId:Stream' :: Stream -> Maybe Text
$sel:state:Stream' :: Stream -> Maybe StreamState
$sel:startTime:Stream' :: Stream -> Maybe ISO8601
$sel:playbackUrl:Stream' :: Stream -> Maybe Text
$sel:health:Stream' :: Stream -> Maybe StreamHealth
$sel:channelArn:Stream' :: Stream -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
channelArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe StreamHealth
health
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
playbackUrl
      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 StreamState
state
      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 Integer
viewerCount