{-# 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.StreamSummary
-- 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.StreamSummary 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

-- | Summary information about a stream.
--
-- /See:/ 'newStreamSummary' smart constructor.
data StreamSummary = StreamSummary'
  { -- | Channel ARN for the stream.
    StreamSummary -> Maybe Text
channelArn :: Prelude.Maybe Prelude.Text,
    -- | The stream’s health.
    StreamSummary -> Maybe StreamHealth
health :: Prelude.Maybe StreamHealth,
    -- | Time of the stream’s start. This is an ISO 8601 timestamp; /note that
    -- this is returned as a string/.
    StreamSummary -> Maybe ISO8601
startTime :: Prelude.Maybe Data.ISO8601,
    -- | The stream’s state.
    StreamSummary -> Maybe StreamState
state :: Prelude.Maybe StreamState,
    -- | Unique identifier for a live or previously live stream in the specified
    -- channel.
    StreamSummary -> 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.
    StreamSummary -> Maybe Integer
viewerCount :: Prelude.Maybe Prelude.Integer
  }
  deriving (StreamSummary -> StreamSummary -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StreamSummary -> StreamSummary -> Bool
$c/= :: StreamSummary -> StreamSummary -> Bool
== :: StreamSummary -> StreamSummary -> Bool
$c== :: StreamSummary -> StreamSummary -> Bool
Prelude.Eq, ReadPrec [StreamSummary]
ReadPrec StreamSummary
Int -> ReadS StreamSummary
ReadS [StreamSummary]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StreamSummary]
$creadListPrec :: ReadPrec [StreamSummary]
readPrec :: ReadPrec StreamSummary
$creadPrec :: ReadPrec StreamSummary
readList :: ReadS [StreamSummary]
$creadList :: ReadS [StreamSummary]
readsPrec :: Int -> ReadS StreamSummary
$creadsPrec :: Int -> ReadS StreamSummary
Prelude.Read, Int -> StreamSummary -> ShowS
[StreamSummary] -> ShowS
StreamSummary -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StreamSummary] -> ShowS
$cshowList :: [StreamSummary] -> ShowS
show :: StreamSummary -> String
$cshow :: StreamSummary -> String
showsPrec :: Int -> StreamSummary -> ShowS
$cshowsPrec :: Int -> StreamSummary -> ShowS
Prelude.Show, forall x. Rep StreamSummary x -> StreamSummary
forall x. StreamSummary -> Rep StreamSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StreamSummary x -> StreamSummary
$cfrom :: forall x. StreamSummary -> Rep StreamSummary x
Prelude.Generic)

-- |
-- Create a value of 'StreamSummary' 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', 'streamSummary_channelArn' - Channel ARN for the stream.
--
-- 'health', 'streamSummary_health' - The stream’s health.
--
-- 'startTime', 'streamSummary_startTime' - Time of the stream’s start. This is an ISO 8601 timestamp; /note that
-- this is returned as a string/.
--
-- 'state', 'streamSummary_state' - The stream’s state.
--
-- 'streamId', 'streamSummary_streamId' - Unique identifier for a live or previously live stream in the specified
-- channel.
--
-- 'viewerCount', 'streamSummary_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.
newStreamSummary ::
  StreamSummary
newStreamSummary :: StreamSummary
newStreamSummary =
  StreamSummary'
    { $sel:channelArn:StreamSummary' :: Maybe Text
channelArn = forall a. Maybe a
Prelude.Nothing,
      $sel:health:StreamSummary' :: Maybe StreamHealth
health = forall a. Maybe a
Prelude.Nothing,
      $sel:startTime:StreamSummary' :: Maybe ISO8601
startTime = forall a. Maybe a
Prelude.Nothing,
      $sel:state:StreamSummary' :: Maybe StreamState
state = forall a. Maybe a
Prelude.Nothing,
      $sel:streamId:StreamSummary' :: Maybe Text
streamId = forall a. Maybe a
Prelude.Nothing,
      $sel:viewerCount:StreamSummary' :: Maybe Integer
viewerCount = forall a. Maybe a
Prelude.Nothing
    }

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

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

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

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

-- | 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.
streamSummary_viewerCount :: Lens.Lens' StreamSummary (Prelude.Maybe Prelude.Integer)
streamSummary_viewerCount :: Lens' StreamSummary (Maybe Integer)
streamSummary_viewerCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StreamSummary' {Maybe Integer
viewerCount :: Maybe Integer
$sel:viewerCount:StreamSummary' :: StreamSummary -> Maybe Integer
viewerCount} -> Maybe Integer
viewerCount) (\s :: StreamSummary
s@StreamSummary' {} Maybe Integer
a -> StreamSummary
s {$sel:viewerCount:StreamSummary' :: Maybe Integer
viewerCount = Maybe Integer
a} :: StreamSummary)

instance Data.FromJSON StreamSummary where
  parseJSON :: Value -> Parser StreamSummary
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"StreamSummary"
      ( \Object
x ->
          Maybe Text
-> Maybe StreamHealth
-> Maybe ISO8601
-> Maybe StreamState
-> Maybe Text
-> Maybe Integer
-> StreamSummary
StreamSummary'
            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
"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 StreamSummary where
  hashWithSalt :: Int -> StreamSummary -> Int
hashWithSalt Int
_salt StreamSummary' {Maybe Integer
Maybe Text
Maybe ISO8601
Maybe StreamHealth
Maybe StreamState
viewerCount :: Maybe Integer
streamId :: Maybe Text
state :: Maybe StreamState
startTime :: Maybe ISO8601
health :: Maybe StreamHealth
channelArn :: Maybe Text
$sel:viewerCount:StreamSummary' :: StreamSummary -> Maybe Integer
$sel:streamId:StreamSummary' :: StreamSummary -> Maybe Text
$sel:state:StreamSummary' :: StreamSummary -> Maybe StreamState
$sel:startTime:StreamSummary' :: StreamSummary -> Maybe ISO8601
$sel:health:StreamSummary' :: StreamSummary -> Maybe StreamHealth
$sel:channelArn:StreamSummary' :: StreamSummary -> 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 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 StreamSummary where
  rnf :: StreamSummary -> ()
rnf StreamSummary' {Maybe Integer
Maybe Text
Maybe ISO8601
Maybe StreamHealth
Maybe StreamState
viewerCount :: Maybe Integer
streamId :: Maybe Text
state :: Maybe StreamState
startTime :: Maybe ISO8601
health :: Maybe StreamHealth
channelArn :: Maybe Text
$sel:viewerCount:StreamSummary' :: StreamSummary -> Maybe Integer
$sel:streamId:StreamSummary' :: StreamSummary -> Maybe Text
$sel:state:StreamSummary' :: StreamSummary -> Maybe StreamState
$sel:startTime:StreamSummary' :: StreamSummary -> Maybe ISO8601
$sel:health:StreamSummary' :: StreamSummary -> Maybe StreamHealth
$sel:channelArn:StreamSummary' :: StreamSummary -> 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 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