{-# 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.StreamEvent
-- 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.StreamEvent where

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

-- | Object specifying a stream’s events. For a list of events, see
-- <https://docs.aws.amazon.com/ivs/latest/userguide/eventbridge.html Using Amazon EventBridge with Amazon IVS>.
--
-- /See:/ 'newStreamEvent' smart constructor.
data StreamEvent = StreamEvent'
  { -- | Time when the event occurred. This is an ISO 8601 timestamp; /note that
    -- this is returned as a string/.
    StreamEvent -> Maybe ISO8601
eventTime :: Prelude.Maybe Data.ISO8601,
    -- | Name that identifies the stream event within a @type@.
    StreamEvent -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | Logical group for certain events.
    StreamEvent -> Maybe Text
type' :: Prelude.Maybe Prelude.Text
  }
  deriving (StreamEvent -> StreamEvent -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StreamEvent -> StreamEvent -> Bool
$c/= :: StreamEvent -> StreamEvent -> Bool
== :: StreamEvent -> StreamEvent -> Bool
$c== :: StreamEvent -> StreamEvent -> Bool
Prelude.Eq, ReadPrec [StreamEvent]
ReadPrec StreamEvent
Int -> ReadS StreamEvent
ReadS [StreamEvent]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StreamEvent]
$creadListPrec :: ReadPrec [StreamEvent]
readPrec :: ReadPrec StreamEvent
$creadPrec :: ReadPrec StreamEvent
readList :: ReadS [StreamEvent]
$creadList :: ReadS [StreamEvent]
readsPrec :: Int -> ReadS StreamEvent
$creadsPrec :: Int -> ReadS StreamEvent
Prelude.Read, Int -> StreamEvent -> ShowS
[StreamEvent] -> ShowS
StreamEvent -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StreamEvent] -> ShowS
$cshowList :: [StreamEvent] -> ShowS
show :: StreamEvent -> String
$cshow :: StreamEvent -> String
showsPrec :: Int -> StreamEvent -> ShowS
$cshowsPrec :: Int -> StreamEvent -> ShowS
Prelude.Show, forall x. Rep StreamEvent x -> StreamEvent
forall x. StreamEvent -> Rep StreamEvent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StreamEvent x -> StreamEvent
$cfrom :: forall x. StreamEvent -> Rep StreamEvent x
Prelude.Generic)

-- |
-- Create a value of 'StreamEvent' 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:
--
-- 'eventTime', 'streamEvent_eventTime' - Time when the event occurred. This is an ISO 8601 timestamp; /note that
-- this is returned as a string/.
--
-- 'name', 'streamEvent_name' - Name that identifies the stream event within a @type@.
--
-- 'type'', 'streamEvent_type' - Logical group for certain events.
newStreamEvent ::
  StreamEvent
newStreamEvent :: StreamEvent
newStreamEvent =
  StreamEvent'
    { $sel:eventTime:StreamEvent' :: Maybe ISO8601
eventTime = forall a. Maybe a
Prelude.Nothing,
      $sel:name:StreamEvent' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:type':StreamEvent' :: Maybe Text
type' = forall a. Maybe a
Prelude.Nothing
    }

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

-- | Name that identifies the stream event within a @type@.
streamEvent_name :: Lens.Lens' StreamEvent (Prelude.Maybe Prelude.Text)
streamEvent_name :: Lens' StreamEvent (Maybe Text)
streamEvent_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StreamEvent' {Maybe Text
name :: Maybe Text
$sel:name:StreamEvent' :: StreamEvent -> Maybe Text
name} -> Maybe Text
name) (\s :: StreamEvent
s@StreamEvent' {} Maybe Text
a -> StreamEvent
s {$sel:name:StreamEvent' :: Maybe Text
name = Maybe Text
a} :: StreamEvent)

-- | Logical group for certain events.
streamEvent_type :: Lens.Lens' StreamEvent (Prelude.Maybe Prelude.Text)
streamEvent_type :: Lens' StreamEvent (Maybe Text)
streamEvent_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StreamEvent' {Maybe Text
type' :: Maybe Text
$sel:type':StreamEvent' :: StreamEvent -> Maybe Text
type'} -> Maybe Text
type') (\s :: StreamEvent
s@StreamEvent' {} Maybe Text
a -> StreamEvent
s {$sel:type':StreamEvent' :: Maybe Text
type' = Maybe Text
a} :: StreamEvent)

instance Data.FromJSON StreamEvent where
  parseJSON :: Value -> Parser StreamEvent
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"StreamEvent"
      ( \Object
x ->
          Maybe ISO8601 -> Maybe Text -> Maybe Text -> StreamEvent
StreamEvent'
            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
"eventTime")
            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
"name")
            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
"type")
      )

instance Prelude.Hashable StreamEvent where
  hashWithSalt :: Int -> StreamEvent -> Int
hashWithSalt Int
_salt StreamEvent' {Maybe Text
Maybe ISO8601
type' :: Maybe Text
name :: Maybe Text
eventTime :: Maybe ISO8601
$sel:type':StreamEvent' :: StreamEvent -> Maybe Text
$sel:name:StreamEvent' :: StreamEvent -> Maybe Text
$sel:eventTime:StreamEvent' :: StreamEvent -> Maybe ISO8601
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
eventTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
type'

instance Prelude.NFData StreamEvent where
  rnf :: StreamEvent -> ()
rnf StreamEvent' {Maybe Text
Maybe ISO8601
type' :: Maybe Text
name :: Maybe Text
eventTime :: Maybe ISO8601
$sel:type':StreamEvent' :: StreamEvent -> Maybe Text
$sel:name:StreamEvent' :: StreamEvent -> Maybe Text
$sel:eventTime:StreamEvent' :: StreamEvent -> Maybe ISO8601
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
eventTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
type'