{-# 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.IoT.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.IoT.Types.Stream 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

-- | Describes a group of files that can be streamed.
--
-- /See:/ 'newStream' smart constructor.
data Stream = Stream'
  { -- | The ID of a file associated with a stream.
    Stream -> Maybe Natural
fileId :: Prelude.Maybe Prelude.Natural,
    -- | The stream ID.
    Stream -> Maybe Text
streamId :: Prelude.Maybe Prelude.Text
  }
  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:
--
-- 'fileId', 'stream_fileId' - The ID of a file associated with a stream.
--
-- 'streamId', 'stream_streamId' - The stream ID.
newStream ::
  Stream
newStream :: Stream
newStream =
  Stream'
    { $sel:fileId:Stream' :: Maybe Natural
fileId = forall a. Maybe a
Prelude.Nothing,
      $sel:streamId:Stream' :: Maybe Text
streamId = forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of a file associated with a stream.
stream_fileId :: Lens.Lens' Stream (Prelude.Maybe Prelude.Natural)
stream_fileId :: Lens' Stream (Maybe Natural)
stream_fileId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Stream' {Maybe Natural
fileId :: Maybe Natural
$sel:fileId:Stream' :: Stream -> Maybe Natural
fileId} -> Maybe Natural
fileId) (\s :: Stream
s@Stream' {} Maybe Natural
a -> Stream
s {$sel:fileId:Stream' :: Maybe Natural
fileId = Maybe Natural
a} :: Stream)

-- | The stream ID.
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)

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 Natural -> Maybe Text -> 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
"fileId")
            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")
      )

instance Prelude.Hashable Stream where
  hashWithSalt :: Int -> Stream -> Int
hashWithSalt Int
_salt Stream' {Maybe Natural
Maybe Text
streamId :: Maybe Text
fileId :: Maybe Natural
$sel:streamId:Stream' :: Stream -> Maybe Text
$sel:fileId:Stream' :: Stream -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
fileId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
streamId

instance Prelude.NFData Stream where
  rnf :: Stream -> ()
rnf Stream' {Maybe Natural
Maybe Text
streamId :: Maybe Text
fileId :: Maybe Natural
$sel:streamId:Stream' :: Stream -> Maybe Text
$sel:fileId:Stream' :: Stream -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
fileId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
streamId

instance Data.ToJSON Stream where
  toJSON :: Stream -> Value
toJSON Stream' {Maybe Natural
Maybe Text
streamId :: Maybe Text
fileId :: Maybe Natural
$sel:streamId:Stream' :: Stream -> Maybe Text
$sel:fileId:Stream' :: Stream -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"fileId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
fileId,
            (Key
"streamId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
streamId
          ]
      )