{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Kinesis.Types.HashKeyRange 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

-- | 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
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]
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
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. 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'
    { $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 :: Lens' HashKeyRange Text
hashKeyRange_startingHashKey = 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 :: Lens' HashKeyRange Text
hashKeyRange_endingHashKey = 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 Data.FromJSON HashKeyRange where
  parseJSON :: Value -> Parser HashKeyRange
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"HashKeyRange"
      ( \Object
x ->
          Text -> Text -> HashKeyRange
HashKeyRange'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"StartingHashKey")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"EndingHashKey")
      )

instance Prelude.Hashable HashKeyRange where
  hashWithSalt :: Int -> HashKeyRange -> Int
hashWithSalt Int
_salt HashKeyRange' {Text
endingHashKey :: Text
startingHashKey :: Text
$sel:endingHashKey:HashKeyRange' :: HashKeyRange -> Text
$sel:startingHashKey:HashKeyRange' :: HashKeyRange -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
startingHashKey
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
endingHashKey

instance Prelude.NFData HashKeyRange where
  rnf :: HashKeyRange -> ()
rnf HashKeyRange' {Text
endingHashKey :: Text
startingHashKey :: Text
$sel:endingHashKey:HashKeyRange' :: HashKeyRange -> Text
$sel:startingHashKey:HashKeyRange' :: HashKeyRange -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
startingHashKey
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
endingHashKey