{-# 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.MemoryDb.Types.ShardConfiguration
-- 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.MemoryDb.Types.ShardConfiguration 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

-- | Shard configuration options. Each shard configuration has the following:
-- Slots and ReplicaCount.
--
-- /See:/ 'newShardConfiguration' smart constructor.
data ShardConfiguration = ShardConfiguration'
  { -- | The number of read replica nodes in this shard.
    ShardConfiguration -> Maybe Int
replicaCount :: Prelude.Maybe Prelude.Int,
    -- | A string that specifies the keyspace for a particular node group.
    -- Keyspaces range from 0 to 16,383. The string is in the format
    -- startkey-endkey.
    ShardConfiguration -> Maybe Text
slots :: Prelude.Maybe Prelude.Text
  }
  deriving (ShardConfiguration -> ShardConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ShardConfiguration -> ShardConfiguration -> Bool
$c/= :: ShardConfiguration -> ShardConfiguration -> Bool
== :: ShardConfiguration -> ShardConfiguration -> Bool
$c== :: ShardConfiguration -> ShardConfiguration -> Bool
Prelude.Eq, ReadPrec [ShardConfiguration]
ReadPrec ShardConfiguration
Int -> ReadS ShardConfiguration
ReadS [ShardConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ShardConfiguration]
$creadListPrec :: ReadPrec [ShardConfiguration]
readPrec :: ReadPrec ShardConfiguration
$creadPrec :: ReadPrec ShardConfiguration
readList :: ReadS [ShardConfiguration]
$creadList :: ReadS [ShardConfiguration]
readsPrec :: Int -> ReadS ShardConfiguration
$creadsPrec :: Int -> ReadS ShardConfiguration
Prelude.Read, Int -> ShardConfiguration -> ShowS
[ShardConfiguration] -> ShowS
ShardConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ShardConfiguration] -> ShowS
$cshowList :: [ShardConfiguration] -> ShowS
show :: ShardConfiguration -> String
$cshow :: ShardConfiguration -> String
showsPrec :: Int -> ShardConfiguration -> ShowS
$cshowsPrec :: Int -> ShardConfiguration -> ShowS
Prelude.Show, forall x. Rep ShardConfiguration x -> ShardConfiguration
forall x. ShardConfiguration -> Rep ShardConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ShardConfiguration x -> ShardConfiguration
$cfrom :: forall x. ShardConfiguration -> Rep ShardConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ShardConfiguration' 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:
--
-- 'replicaCount', 'shardConfiguration_replicaCount' - The number of read replica nodes in this shard.
--
-- 'slots', 'shardConfiguration_slots' - A string that specifies the keyspace for a particular node group.
-- Keyspaces range from 0 to 16,383. The string is in the format
-- startkey-endkey.
newShardConfiguration ::
  ShardConfiguration
newShardConfiguration :: ShardConfiguration
newShardConfiguration =
  ShardConfiguration'
    { $sel:replicaCount:ShardConfiguration' :: Maybe Int
replicaCount = forall a. Maybe a
Prelude.Nothing,
      $sel:slots:ShardConfiguration' :: Maybe Text
slots = forall a. Maybe a
Prelude.Nothing
    }

-- | The number of read replica nodes in this shard.
shardConfiguration_replicaCount :: Lens.Lens' ShardConfiguration (Prelude.Maybe Prelude.Int)
shardConfiguration_replicaCount :: Lens' ShardConfiguration (Maybe Int)
shardConfiguration_replicaCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ShardConfiguration' {Maybe Int
replicaCount :: Maybe Int
$sel:replicaCount:ShardConfiguration' :: ShardConfiguration -> Maybe Int
replicaCount} -> Maybe Int
replicaCount) (\s :: ShardConfiguration
s@ShardConfiguration' {} Maybe Int
a -> ShardConfiguration
s {$sel:replicaCount:ShardConfiguration' :: Maybe Int
replicaCount = Maybe Int
a} :: ShardConfiguration)

-- | A string that specifies the keyspace for a particular node group.
-- Keyspaces range from 0 to 16,383. The string is in the format
-- startkey-endkey.
shardConfiguration_slots :: Lens.Lens' ShardConfiguration (Prelude.Maybe Prelude.Text)
shardConfiguration_slots :: Lens' ShardConfiguration (Maybe Text)
shardConfiguration_slots = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ShardConfiguration' {Maybe Text
slots :: Maybe Text
$sel:slots:ShardConfiguration' :: ShardConfiguration -> Maybe Text
slots} -> Maybe Text
slots) (\s :: ShardConfiguration
s@ShardConfiguration' {} Maybe Text
a -> ShardConfiguration
s {$sel:slots:ShardConfiguration' :: Maybe Text
slots = Maybe Text
a} :: ShardConfiguration)

instance Data.FromJSON ShardConfiguration where
  parseJSON :: Value -> Parser ShardConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ShardConfiguration"
      ( \Object
x ->
          Maybe Int -> Maybe Text -> ShardConfiguration
ShardConfiguration'
            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
"ReplicaCount")
            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
"Slots")
      )

instance Prelude.Hashable ShardConfiguration where
  hashWithSalt :: Int -> ShardConfiguration -> Int
hashWithSalt Int
_salt ShardConfiguration' {Maybe Int
Maybe Text
slots :: Maybe Text
replicaCount :: Maybe Int
$sel:slots:ShardConfiguration' :: ShardConfiguration -> Maybe Text
$sel:replicaCount:ShardConfiguration' :: ShardConfiguration -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
replicaCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
slots

instance Prelude.NFData ShardConfiguration where
  rnf :: ShardConfiguration -> ()
rnf ShardConfiguration' {Maybe Int
Maybe Text
slots :: Maybe Text
replicaCount :: Maybe Int
$sel:slots:ShardConfiguration' :: ShardConfiguration -> Maybe Text
$sel:replicaCount:ShardConfiguration' :: ShardConfiguration -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
replicaCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
slots