{-# 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.DynamoDBStreams.Types.Stream
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.DynamoDBStreams.Types.Stream where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents all of the data describing a particular stream.
--
-- /See:/ 'newStream' smart constructor.
data Stream = Stream'
  { -- | A timestamp, in ISO 8601 format, for this stream.
    --
    -- Note that @LatestStreamLabel@ is not a unique identifier for the stream,
    -- because it is possible that a stream from another table might have the
    -- same timestamp. However, the combination of the following three elements
    -- is guaranteed to be unique:
    --
    -- -   the AWS customer ID.
    --
    -- -   the table name
    --
    -- -   the @StreamLabel@
    Stream -> Maybe Text
streamLabel :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) for the stream.
    Stream -> Maybe Text
streamArn :: Prelude.Maybe Prelude.Text,
    -- | The DynamoDB table with which the stream is associated.
    Stream -> Maybe Text
tableName :: Prelude.Maybe Prelude.Text
  }
  deriving (Stream -> Stream -> Bool
(Stream -> Stream -> Bool)
-> (Stream -> Stream -> Bool) -> Eq Stream
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]
(Int -> ReadS Stream)
-> ReadS [Stream]
-> ReadPrec Stream
-> ReadPrec [Stream]
-> Read 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
(Int -> Stream -> ShowS)
-> (Stream -> String) -> ([Stream] -> ShowS) -> Show Stream
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. Stream -> Rep Stream x)
-> (forall x. Rep Stream x -> Stream) -> Generic Stream
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:
--
-- 'streamLabel', 'stream_streamLabel' - A timestamp, in ISO 8601 format, for this stream.
--
-- Note that @LatestStreamLabel@ is not a unique identifier for the stream,
-- because it is possible that a stream from another table might have the
-- same timestamp. However, the combination of the following three elements
-- is guaranteed to be unique:
--
-- -   the AWS customer ID.
--
-- -   the table name
--
-- -   the @StreamLabel@
--
-- 'streamArn', 'stream_streamArn' - The Amazon Resource Name (ARN) for the stream.
--
-- 'tableName', 'stream_tableName' - The DynamoDB table with which the stream is associated.
newStream ::
  Stream
newStream :: Stream
newStream =
  Stream' :: Maybe Text -> Maybe Text -> Maybe Text -> Stream
Stream'
    { $sel:streamLabel:Stream' :: Maybe Text
streamLabel = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:streamArn:Stream' :: Maybe Text
streamArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tableName:Stream' :: Maybe Text
tableName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A timestamp, in ISO 8601 format, for this stream.
--
-- Note that @LatestStreamLabel@ is not a unique identifier for the stream,
-- because it is possible that a stream from another table might have the
-- same timestamp. However, the combination of the following three elements
-- is guaranteed to be unique:
--
-- -   the AWS customer ID.
--
-- -   the table name
--
-- -   the @StreamLabel@
stream_streamLabel :: Lens.Lens' Stream (Prelude.Maybe Prelude.Text)
stream_streamLabel :: (Maybe Text -> f (Maybe Text)) -> Stream -> f Stream
stream_streamLabel = (Stream -> Maybe Text)
-> (Stream -> Maybe Text -> Stream)
-> Lens Stream Stream (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Stream' {Maybe Text
streamLabel :: Maybe Text
$sel:streamLabel:Stream' :: Stream -> Maybe Text
streamLabel} -> Maybe Text
streamLabel) (\s :: Stream
s@Stream' {} Maybe Text
a -> Stream
s {$sel:streamLabel:Stream' :: Maybe Text
streamLabel = Maybe Text
a} :: Stream)

-- | The Amazon Resource Name (ARN) for the stream.
stream_streamArn :: Lens.Lens' Stream (Prelude.Maybe Prelude.Text)
stream_streamArn :: (Maybe Text -> f (Maybe Text)) -> Stream -> f Stream
stream_streamArn = (Stream -> Maybe Text)
-> (Stream -> Maybe Text -> Stream)
-> Lens Stream Stream (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Stream' {Maybe Text
streamArn :: Maybe Text
$sel:streamArn:Stream' :: Stream -> Maybe Text
streamArn} -> Maybe Text
streamArn) (\s :: Stream
s@Stream' {} Maybe Text
a -> Stream
s {$sel:streamArn:Stream' :: Maybe Text
streamArn = Maybe Text
a} :: Stream)

-- | The DynamoDB table with which the stream is associated.
stream_tableName :: Lens.Lens' Stream (Prelude.Maybe Prelude.Text)
stream_tableName :: (Maybe Text -> f (Maybe Text)) -> Stream -> f Stream
stream_tableName = (Stream -> Maybe Text)
-> (Stream -> Maybe Text -> Stream)
-> Lens Stream Stream (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Stream' {Maybe Text
tableName :: Maybe Text
$sel:tableName:Stream' :: Stream -> Maybe Text
tableName} -> Maybe Text
tableName) (\s :: Stream
s@Stream' {} Maybe Text
a -> Stream
s {$sel:tableName:Stream' :: Maybe Text
tableName = Maybe Text
a} :: Stream)

instance Core.FromJSON Stream where
  parseJSON :: Value -> Parser Stream
parseJSON =
    String -> (Object -> Parser Stream) -> Value -> Parser Stream
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Stream"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> Stream
Stream'
            (Maybe Text -> Maybe Text -> Maybe Text -> Stream)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Stream)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StreamLabel")
            Parser (Maybe Text -> Maybe Text -> Stream)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Stream)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StreamArn")
            Parser (Maybe Text -> Stream)
-> Parser (Maybe Text) -> Parser Stream
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TableName")
      )

instance Prelude.Hashable Stream

instance Prelude.NFData Stream