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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoT.Types.S3Location
import qualified Amazonka.Prelude as Prelude

-- | Represents a file to stream.
--
-- /See:/ 'newStreamFile' smart constructor.
data StreamFile = StreamFile'
  { -- | The file ID.
    StreamFile -> Maybe Natural
fileId :: Prelude.Maybe Prelude.Natural,
    -- | The location of the file in S3.
    StreamFile -> Maybe S3Location
s3Location :: Prelude.Maybe S3Location
  }
  deriving (StreamFile -> StreamFile -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StreamFile -> StreamFile -> Bool
$c/= :: StreamFile -> StreamFile -> Bool
== :: StreamFile -> StreamFile -> Bool
$c== :: StreamFile -> StreamFile -> Bool
Prelude.Eq, ReadPrec [StreamFile]
ReadPrec StreamFile
Int -> ReadS StreamFile
ReadS [StreamFile]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StreamFile]
$creadListPrec :: ReadPrec [StreamFile]
readPrec :: ReadPrec StreamFile
$creadPrec :: ReadPrec StreamFile
readList :: ReadS [StreamFile]
$creadList :: ReadS [StreamFile]
readsPrec :: Int -> ReadS StreamFile
$creadsPrec :: Int -> ReadS StreamFile
Prelude.Read, Int -> StreamFile -> ShowS
[StreamFile] -> ShowS
StreamFile -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StreamFile] -> ShowS
$cshowList :: [StreamFile] -> ShowS
show :: StreamFile -> String
$cshow :: StreamFile -> String
showsPrec :: Int -> StreamFile -> ShowS
$cshowsPrec :: Int -> StreamFile -> ShowS
Prelude.Show, forall x. Rep StreamFile x -> StreamFile
forall x. StreamFile -> Rep StreamFile x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StreamFile x -> StreamFile
$cfrom :: forall x. StreamFile -> Rep StreamFile x
Prelude.Generic)

-- |
-- Create a value of 'StreamFile' 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', 'streamFile_fileId' - The file ID.
--
-- 's3Location', 'streamFile_s3Location' - The location of the file in S3.
newStreamFile ::
  StreamFile
newStreamFile :: StreamFile
newStreamFile =
  StreamFile'
    { $sel:fileId:StreamFile' :: Maybe Natural
fileId = forall a. Maybe a
Prelude.Nothing,
      $sel:s3Location:StreamFile' :: Maybe S3Location
s3Location = forall a. Maybe a
Prelude.Nothing
    }

-- | The file ID.
streamFile_fileId :: Lens.Lens' StreamFile (Prelude.Maybe Prelude.Natural)
streamFile_fileId :: Lens' StreamFile (Maybe Natural)
streamFile_fileId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StreamFile' {Maybe Natural
fileId :: Maybe Natural
$sel:fileId:StreamFile' :: StreamFile -> Maybe Natural
fileId} -> Maybe Natural
fileId) (\s :: StreamFile
s@StreamFile' {} Maybe Natural
a -> StreamFile
s {$sel:fileId:StreamFile' :: Maybe Natural
fileId = Maybe Natural
a} :: StreamFile)

-- | The location of the file in S3.
streamFile_s3Location :: Lens.Lens' StreamFile (Prelude.Maybe S3Location)
streamFile_s3Location :: Lens' StreamFile (Maybe S3Location)
streamFile_s3Location = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StreamFile' {Maybe S3Location
s3Location :: Maybe S3Location
$sel:s3Location:StreamFile' :: StreamFile -> Maybe S3Location
s3Location} -> Maybe S3Location
s3Location) (\s :: StreamFile
s@StreamFile' {} Maybe S3Location
a -> StreamFile
s {$sel:s3Location:StreamFile' :: Maybe S3Location
s3Location = Maybe S3Location
a} :: StreamFile)

instance Data.FromJSON StreamFile where
  parseJSON :: Value -> Parser StreamFile
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"StreamFile"
      ( \Object
x ->
          Maybe Natural -> Maybe S3Location -> StreamFile
StreamFile'
            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
"s3Location")
      )

instance Prelude.Hashable StreamFile where
  hashWithSalt :: Int -> StreamFile -> Int
hashWithSalt Int
_salt StreamFile' {Maybe Natural
Maybe S3Location
s3Location :: Maybe S3Location
fileId :: Maybe Natural
$sel:s3Location:StreamFile' :: StreamFile -> Maybe S3Location
$sel:fileId:StreamFile' :: StreamFile -> 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 S3Location
s3Location

instance Prelude.NFData StreamFile where
  rnf :: StreamFile -> ()
rnf StreamFile' {Maybe Natural
Maybe S3Location
s3Location :: Maybe S3Location
fileId :: Maybe Natural
$sel:s3Location:StreamFile' :: StreamFile -> Maybe S3Location
$sel:fileId:StreamFile' :: StreamFile -> 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 S3Location
s3Location

instance Data.ToJSON StreamFile where
  toJSON :: StreamFile -> Value
toJSON StreamFile' {Maybe Natural
Maybe S3Location
s3Location :: Maybe S3Location
fileId :: Maybe Natural
$sel:s3Location:StreamFile' :: StreamFile -> Maybe S3Location
$sel:fileId:StreamFile' :: StreamFile -> 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
"s3Location" 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 S3Location
s3Location
          ]
      )