{-# 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.Kinesis.Types.HashKeyRange
-- 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.Kinesis.Types.HashKeyRange where

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

-- | The range of possible hash key values for the shard, which is a set of
-- ordered contiguous positive integers.
--
-- /See:/ 'newHashKeyRange' smart constructor.
data HashKeyRange = HashKeyRange'
  { -- | The starting hash key of the hash key range.
    HashKeyRange -> Text
startingHashKey :: Prelude.Text,
    -- | The ending hash key of the hash key range.
    HashKeyRange -> Text
endingHashKey :: Prelude.Text
  }
  deriving (HashKeyRange -> HashKeyRange -> Bool
(HashKeyRange -> HashKeyRange -> Bool)
-> (HashKeyRange -> HashKeyRange -> Bool) -> Eq HashKeyRange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HashKeyRange -> HashKeyRange -> Bool
$c/= :: HashKeyRange -> HashKeyRange -> Bool
== :: HashKeyRange -> HashKeyRange -> Bool
$c== :: HashKeyRange -> HashKeyRange -> Bool
Prelude.Eq, ReadPrec [HashKeyRange]
ReadPrec HashKeyRange
Int -> ReadS HashKeyRange
ReadS [HashKeyRange]
(Int -> ReadS HashKeyRange)
-> ReadS [HashKeyRange]
-> ReadPrec HashKeyRange
-> ReadPrec [HashKeyRange]
-> Read HashKeyRange
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HashKeyRange]
$creadListPrec :: ReadPrec [HashKeyRange]
readPrec :: ReadPrec HashKeyRange
$creadPrec :: ReadPrec HashKeyRange
readList :: ReadS [HashKeyRange]
$creadList :: ReadS [HashKeyRange]
readsPrec :: Int -> ReadS HashKeyRange
$creadsPrec :: Int -> ReadS HashKeyRange
Prelude.Read, Int -> HashKeyRange -> ShowS
[HashKeyRange] -> ShowS
HashKeyRange -> String
(Int -> HashKeyRange -> ShowS)
-> (HashKeyRange -> String)
-> ([HashKeyRange] -> ShowS)
-> Show HashKeyRange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HashKeyRange] -> ShowS
$cshowList :: [HashKeyRange] -> ShowS
show :: HashKeyRange -> String
$cshow :: HashKeyRange -> String
showsPrec :: Int -> HashKeyRange -> ShowS
$cshowsPrec :: Int -> HashKeyRange -> ShowS
Prelude.Show, (forall x. HashKeyRange -> Rep HashKeyRange x)
-> (forall x. Rep HashKeyRange x -> HashKeyRange)
-> Generic HashKeyRange
forall x. Rep HashKeyRange x -> HashKeyRange
forall x. HashKeyRange -> Rep HashKeyRange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HashKeyRange x -> HashKeyRange
$cfrom :: forall x. HashKeyRange -> Rep HashKeyRange x
Prelude.Generic)

-- |
-- Create a value of 'HashKeyRange' 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:
--
-- 'startingHashKey', 'hashKeyRange_startingHashKey' - The starting hash key of the hash key range.
--
-- 'endingHashKey', 'hashKeyRange_endingHashKey' - The ending hash key of the hash key range.
newHashKeyRange ::
  -- | 'startingHashKey'
  Prelude.Text ->
  -- | 'endingHashKey'
  Prelude.Text ->
  HashKeyRange
newHashKeyRange :: Text -> Text -> HashKeyRange
newHashKeyRange Text
pStartingHashKey_ Text
pEndingHashKey_ =
  HashKeyRange' :: Text -> Text -> HashKeyRange
HashKeyRange'
    { $sel:startingHashKey:HashKeyRange' :: Text
startingHashKey = Text
pStartingHashKey_,
      $sel:endingHashKey:HashKeyRange' :: Text
endingHashKey = Text
pEndingHashKey_
    }

-- | The starting hash key of the hash key range.
hashKeyRange_startingHashKey :: Lens.Lens' HashKeyRange Prelude.Text
hashKeyRange_startingHashKey :: (Text -> f Text) -> HashKeyRange -> f HashKeyRange
hashKeyRange_startingHashKey = (HashKeyRange -> Text)
-> (HashKeyRange -> Text -> HashKeyRange)
-> Lens HashKeyRange HashKeyRange Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HashKeyRange' {Text
startingHashKey :: Text
$sel:startingHashKey:HashKeyRange' :: HashKeyRange -> Text
startingHashKey} -> Text
startingHashKey) (\s :: HashKeyRange
s@HashKeyRange' {} Text
a -> HashKeyRange
s {$sel:startingHashKey:HashKeyRange' :: Text
startingHashKey = Text
a} :: HashKeyRange)

-- | The ending hash key of the hash key range.
hashKeyRange_endingHashKey :: Lens.Lens' HashKeyRange Prelude.Text
hashKeyRange_endingHashKey :: (Text -> f Text) -> HashKeyRange -> f HashKeyRange
hashKeyRange_endingHashKey = (HashKeyRange -> Text)
-> (HashKeyRange -> Text -> HashKeyRange)
-> Lens HashKeyRange HashKeyRange Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HashKeyRange' {Text
endingHashKey :: Text
$sel:endingHashKey:HashKeyRange' :: HashKeyRange -> Text
endingHashKey} -> Text
endingHashKey) (\s :: HashKeyRange
s@HashKeyRange' {} Text
a -> HashKeyRange
s {$sel:endingHashKey:HashKeyRange' :: Text
endingHashKey = Text
a} :: HashKeyRange)

instance Core.FromJSON HashKeyRange where
  parseJSON :: Value -> Parser HashKeyRange
parseJSON =
    String
-> (Object -> Parser HashKeyRange) -> Value -> Parser HashKeyRange
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"HashKeyRange"
      ( \Object
x ->
          Text -> Text -> HashKeyRange
HashKeyRange'
            (Text -> Text -> HashKeyRange)
-> Parser Text -> Parser (Text -> HashKeyRange)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"StartingHashKey")
            Parser (Text -> HashKeyRange) -> Parser Text -> Parser HashKeyRange
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"EndingHashKey")
      )

instance Prelude.Hashable HashKeyRange

instance Prelude.NFData HashKeyRange