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

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

-- | The beginning and ending sequence numbers for the stream records
-- contained within a shard.
--
-- /See:/ 'newSequenceNumberRange' smart constructor.
data SequenceNumberRange = SequenceNumberRange'
  { -- | The first sequence number for the stream records contained within a
    -- shard. String contains numeric characters only.
    SequenceNumberRange -> Maybe Text
startingSequenceNumber :: Prelude.Maybe Prelude.Text,
    -- | The last sequence number for the stream records contained within a
    -- shard. String contains numeric characters only.
    SequenceNumberRange -> Maybe Text
endingSequenceNumber :: Prelude.Maybe Prelude.Text
  }
  deriving (SequenceNumberRange -> SequenceNumberRange -> Bool
(SequenceNumberRange -> SequenceNumberRange -> Bool)
-> (SequenceNumberRange -> SequenceNumberRange -> Bool)
-> Eq SequenceNumberRange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SequenceNumberRange -> SequenceNumberRange -> Bool
$c/= :: SequenceNumberRange -> SequenceNumberRange -> Bool
== :: SequenceNumberRange -> SequenceNumberRange -> Bool
$c== :: SequenceNumberRange -> SequenceNumberRange -> Bool
Prelude.Eq, ReadPrec [SequenceNumberRange]
ReadPrec SequenceNumberRange
Int -> ReadS SequenceNumberRange
ReadS [SequenceNumberRange]
(Int -> ReadS SequenceNumberRange)
-> ReadS [SequenceNumberRange]
-> ReadPrec SequenceNumberRange
-> ReadPrec [SequenceNumberRange]
-> Read SequenceNumberRange
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SequenceNumberRange]
$creadListPrec :: ReadPrec [SequenceNumberRange]
readPrec :: ReadPrec SequenceNumberRange
$creadPrec :: ReadPrec SequenceNumberRange
readList :: ReadS [SequenceNumberRange]
$creadList :: ReadS [SequenceNumberRange]
readsPrec :: Int -> ReadS SequenceNumberRange
$creadsPrec :: Int -> ReadS SequenceNumberRange
Prelude.Read, Int -> SequenceNumberRange -> ShowS
[SequenceNumberRange] -> ShowS
SequenceNumberRange -> String
(Int -> SequenceNumberRange -> ShowS)
-> (SequenceNumberRange -> String)
-> ([SequenceNumberRange] -> ShowS)
-> Show SequenceNumberRange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SequenceNumberRange] -> ShowS
$cshowList :: [SequenceNumberRange] -> ShowS
show :: SequenceNumberRange -> String
$cshow :: SequenceNumberRange -> String
showsPrec :: Int -> SequenceNumberRange -> ShowS
$cshowsPrec :: Int -> SequenceNumberRange -> ShowS
Prelude.Show, (forall x. SequenceNumberRange -> Rep SequenceNumberRange x)
-> (forall x. Rep SequenceNumberRange x -> SequenceNumberRange)
-> Generic SequenceNumberRange
forall x. Rep SequenceNumberRange x -> SequenceNumberRange
forall x. SequenceNumberRange -> Rep SequenceNumberRange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SequenceNumberRange x -> SequenceNumberRange
$cfrom :: forall x. SequenceNumberRange -> Rep SequenceNumberRange x
Prelude.Generic)

-- |
-- Create a value of 'SequenceNumberRange' 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:
--
-- 'startingSequenceNumber', 'sequenceNumberRange_startingSequenceNumber' - The first sequence number for the stream records contained within a
-- shard. String contains numeric characters only.
--
-- 'endingSequenceNumber', 'sequenceNumberRange_endingSequenceNumber' - The last sequence number for the stream records contained within a
-- shard. String contains numeric characters only.
newSequenceNumberRange ::
  SequenceNumberRange
newSequenceNumberRange :: SequenceNumberRange
newSequenceNumberRange =
  SequenceNumberRange' :: Maybe Text -> Maybe Text -> SequenceNumberRange
SequenceNumberRange'
    { $sel:startingSequenceNumber:SequenceNumberRange' :: Maybe Text
startingSequenceNumber =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:endingSequenceNumber:SequenceNumberRange' :: Maybe Text
endingSequenceNumber = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The first sequence number for the stream records contained within a
-- shard. String contains numeric characters only.
sequenceNumberRange_startingSequenceNumber :: Lens.Lens' SequenceNumberRange (Prelude.Maybe Prelude.Text)
sequenceNumberRange_startingSequenceNumber :: (Maybe Text -> f (Maybe Text))
-> SequenceNumberRange -> f SequenceNumberRange
sequenceNumberRange_startingSequenceNumber = (SequenceNumberRange -> Maybe Text)
-> (SequenceNumberRange -> Maybe Text -> SequenceNumberRange)
-> Lens
     SequenceNumberRange SequenceNumberRange (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SequenceNumberRange' {Maybe Text
startingSequenceNumber :: Maybe Text
$sel:startingSequenceNumber:SequenceNumberRange' :: SequenceNumberRange -> Maybe Text
startingSequenceNumber} -> Maybe Text
startingSequenceNumber) (\s :: SequenceNumberRange
s@SequenceNumberRange' {} Maybe Text
a -> SequenceNumberRange
s {$sel:startingSequenceNumber:SequenceNumberRange' :: Maybe Text
startingSequenceNumber = Maybe Text
a} :: SequenceNumberRange)

-- | The last sequence number for the stream records contained within a
-- shard. String contains numeric characters only.
sequenceNumberRange_endingSequenceNumber :: Lens.Lens' SequenceNumberRange (Prelude.Maybe Prelude.Text)
sequenceNumberRange_endingSequenceNumber :: (Maybe Text -> f (Maybe Text))
-> SequenceNumberRange -> f SequenceNumberRange
sequenceNumberRange_endingSequenceNumber = (SequenceNumberRange -> Maybe Text)
-> (SequenceNumberRange -> Maybe Text -> SequenceNumberRange)
-> Lens
     SequenceNumberRange SequenceNumberRange (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SequenceNumberRange' {Maybe Text
endingSequenceNumber :: Maybe Text
$sel:endingSequenceNumber:SequenceNumberRange' :: SequenceNumberRange -> Maybe Text
endingSequenceNumber} -> Maybe Text
endingSequenceNumber) (\s :: SequenceNumberRange
s@SequenceNumberRange' {} Maybe Text
a -> SequenceNumberRange
s {$sel:endingSequenceNumber:SequenceNumberRange' :: Maybe Text
endingSequenceNumber = Maybe Text
a} :: SequenceNumberRange)

instance Core.FromJSON SequenceNumberRange where
  parseJSON :: Value -> Parser SequenceNumberRange
parseJSON =
    String
-> (Object -> Parser SequenceNumberRange)
-> Value
-> Parser SequenceNumberRange
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SequenceNumberRange"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> SequenceNumberRange
SequenceNumberRange'
            (Maybe Text -> Maybe Text -> SequenceNumberRange)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> SequenceNumberRange)
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
"StartingSequenceNumber")
            Parser (Maybe Text -> SequenceNumberRange)
-> Parser (Maybe Text) -> Parser SequenceNumberRange
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
"EndingSequenceNumber")
      )

instance Prelude.Hashable SequenceNumberRange

instance Prelude.NFData SequenceNumberRange