{-# 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.ElastiCache.Types.ConfigureShard
-- 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.ElastiCache.Types.ConfigureShard 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

-- | Node group (shard) configuration options when adding or removing
-- replicas. Each node group (shard) configuration has the following
-- members: NodeGroupId, NewReplicaCount, and PreferredAvailabilityZones.
--
-- /See:/ 'newConfigureShard' smart constructor.
data ConfigureShard = ConfigureShard'
  { -- | A list of @PreferredAvailabilityZone@ strings that specify which
    -- availability zones the replication group\'s nodes are to be in. The
    -- nummber of @PreferredAvailabilityZone@ values must equal the value of
    -- @NewReplicaCount@ plus 1 to account for the primary node. If this member
    -- of @ReplicaConfiguration@ is omitted, ElastiCache for Redis selects the
    -- availability zone for each of the replicas.
    ConfigureShard -> Maybe [Text]
preferredAvailabilityZones :: Prelude.Maybe [Prelude.Text],
    -- | The outpost ARNs in which the cache cluster is created.
    ConfigureShard -> Maybe [Text]
preferredOutpostArns :: Prelude.Maybe [Prelude.Text],
    -- | The 4-digit id for the node group you are configuring. For Redis
    -- (cluster mode disabled) replication groups, the node group id is always
    -- 0001. To find a Redis (cluster mode enabled)\'s node group\'s (shard\'s)
    -- id, see
    -- <https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/shard-find-id.html Finding a Shard\'s Id>.
    ConfigureShard -> Text
nodeGroupId :: Prelude.Text,
    -- | The number of replicas you want in this node group at the end of this
    -- operation. The maximum value for @NewReplicaCount@ is 5. The minimum
    -- value depends upon the type of Redis replication group you are working
    -- with.
    --
    -- The minimum number of replicas in a shard or replication group is:
    --
    -- -   Redis (cluster mode disabled)
    --
    --     -   If Multi-AZ: 1
    --
    --     -   If Multi-AZ: 0
    --
    -- -   Redis (cluster mode enabled): 0 (though you will not be able to
    --     failover to a replica if your primary node fails)
    ConfigureShard -> Int
newReplicaCount' :: Prelude.Int
  }
  deriving (ConfigureShard -> ConfigureShard -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConfigureShard -> ConfigureShard -> Bool
$c/= :: ConfigureShard -> ConfigureShard -> Bool
== :: ConfigureShard -> ConfigureShard -> Bool
$c== :: ConfigureShard -> ConfigureShard -> Bool
Prelude.Eq, ReadPrec [ConfigureShard]
ReadPrec ConfigureShard
Int -> ReadS ConfigureShard
ReadS [ConfigureShard]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConfigureShard]
$creadListPrec :: ReadPrec [ConfigureShard]
readPrec :: ReadPrec ConfigureShard
$creadPrec :: ReadPrec ConfigureShard
readList :: ReadS [ConfigureShard]
$creadList :: ReadS [ConfigureShard]
readsPrec :: Int -> ReadS ConfigureShard
$creadsPrec :: Int -> ReadS ConfigureShard
Prelude.Read, Int -> ConfigureShard -> ShowS
[ConfigureShard] -> ShowS
ConfigureShard -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConfigureShard] -> ShowS
$cshowList :: [ConfigureShard] -> ShowS
show :: ConfigureShard -> String
$cshow :: ConfigureShard -> String
showsPrec :: Int -> ConfigureShard -> ShowS
$cshowsPrec :: Int -> ConfigureShard -> ShowS
Prelude.Show, forall x. Rep ConfigureShard x -> ConfigureShard
forall x. ConfigureShard -> Rep ConfigureShard x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ConfigureShard x -> ConfigureShard
$cfrom :: forall x. ConfigureShard -> Rep ConfigureShard x
Prelude.Generic)

-- |
-- Create a value of 'ConfigureShard' 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:
--
-- 'preferredAvailabilityZones', 'configureShard_preferredAvailabilityZones' - A list of @PreferredAvailabilityZone@ strings that specify which
-- availability zones the replication group\'s nodes are to be in. The
-- nummber of @PreferredAvailabilityZone@ values must equal the value of
-- @NewReplicaCount@ plus 1 to account for the primary node. If this member
-- of @ReplicaConfiguration@ is omitted, ElastiCache for Redis selects the
-- availability zone for each of the replicas.
--
-- 'preferredOutpostArns', 'configureShard_preferredOutpostArns' - The outpost ARNs in which the cache cluster is created.
--
-- 'nodeGroupId', 'configureShard_nodeGroupId' - The 4-digit id for the node group you are configuring. For Redis
-- (cluster mode disabled) replication groups, the node group id is always
-- 0001. To find a Redis (cluster mode enabled)\'s node group\'s (shard\'s)
-- id, see
-- <https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/shard-find-id.html Finding a Shard\'s Id>.
--
-- 'newReplicaCount'', 'configureShard_newReplicaCount' - The number of replicas you want in this node group at the end of this
-- operation. The maximum value for @NewReplicaCount@ is 5. The minimum
-- value depends upon the type of Redis replication group you are working
-- with.
--
-- The minimum number of replicas in a shard or replication group is:
--
-- -   Redis (cluster mode disabled)
--
--     -   If Multi-AZ: 1
--
--     -   If Multi-AZ: 0
--
-- -   Redis (cluster mode enabled): 0 (though you will not be able to
--     failover to a replica if your primary node fails)
newConfigureShard ::
  -- | 'nodeGroupId'
  Prelude.Text ->
  -- | 'newReplicaCount''
  Prelude.Int ->
  ConfigureShard
newConfigureShard :: Text -> Int -> ConfigureShard
newConfigureShard Text
pNodeGroupId_ Int
pNewReplicaCount_ =
  ConfigureShard'
    { $sel:preferredAvailabilityZones:ConfigureShard' :: Maybe [Text]
preferredAvailabilityZones =
        forall a. Maybe a
Prelude.Nothing,
      $sel:preferredOutpostArns:ConfigureShard' :: Maybe [Text]
preferredOutpostArns = forall a. Maybe a
Prelude.Nothing,
      $sel:nodeGroupId:ConfigureShard' :: Text
nodeGroupId = Text
pNodeGroupId_,
      $sel:newReplicaCount':ConfigureShard' :: Int
newReplicaCount' = Int
pNewReplicaCount_
    }

-- | A list of @PreferredAvailabilityZone@ strings that specify which
-- availability zones the replication group\'s nodes are to be in. The
-- nummber of @PreferredAvailabilityZone@ values must equal the value of
-- @NewReplicaCount@ plus 1 to account for the primary node. If this member
-- of @ReplicaConfiguration@ is omitted, ElastiCache for Redis selects the
-- availability zone for each of the replicas.
configureShard_preferredAvailabilityZones :: Lens.Lens' ConfigureShard (Prelude.Maybe [Prelude.Text])
configureShard_preferredAvailabilityZones :: Lens' ConfigureShard (Maybe [Text])
configureShard_preferredAvailabilityZones = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigureShard' {Maybe [Text]
preferredAvailabilityZones :: Maybe [Text]
$sel:preferredAvailabilityZones:ConfigureShard' :: ConfigureShard -> Maybe [Text]
preferredAvailabilityZones} -> Maybe [Text]
preferredAvailabilityZones) (\s :: ConfigureShard
s@ConfigureShard' {} Maybe [Text]
a -> ConfigureShard
s {$sel:preferredAvailabilityZones:ConfigureShard' :: Maybe [Text]
preferredAvailabilityZones = Maybe [Text]
a} :: ConfigureShard) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The outpost ARNs in which the cache cluster is created.
configureShard_preferredOutpostArns :: Lens.Lens' ConfigureShard (Prelude.Maybe [Prelude.Text])
configureShard_preferredOutpostArns :: Lens' ConfigureShard (Maybe [Text])
configureShard_preferredOutpostArns = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigureShard' {Maybe [Text]
preferredOutpostArns :: Maybe [Text]
$sel:preferredOutpostArns:ConfigureShard' :: ConfigureShard -> Maybe [Text]
preferredOutpostArns} -> Maybe [Text]
preferredOutpostArns) (\s :: ConfigureShard
s@ConfigureShard' {} Maybe [Text]
a -> ConfigureShard
s {$sel:preferredOutpostArns:ConfigureShard' :: Maybe [Text]
preferredOutpostArns = Maybe [Text]
a} :: ConfigureShard) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The 4-digit id for the node group you are configuring. For Redis
-- (cluster mode disabled) replication groups, the node group id is always
-- 0001. To find a Redis (cluster mode enabled)\'s node group\'s (shard\'s)
-- id, see
-- <https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/shard-find-id.html Finding a Shard\'s Id>.
configureShard_nodeGroupId :: Lens.Lens' ConfigureShard Prelude.Text
configureShard_nodeGroupId :: Lens' ConfigureShard Text
configureShard_nodeGroupId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigureShard' {Text
nodeGroupId :: Text
$sel:nodeGroupId:ConfigureShard' :: ConfigureShard -> Text
nodeGroupId} -> Text
nodeGroupId) (\s :: ConfigureShard
s@ConfigureShard' {} Text
a -> ConfigureShard
s {$sel:nodeGroupId:ConfigureShard' :: Text
nodeGroupId = Text
a} :: ConfigureShard)

-- | The number of replicas you want in this node group at the end of this
-- operation. The maximum value for @NewReplicaCount@ is 5. The minimum
-- value depends upon the type of Redis replication group you are working
-- with.
--
-- The minimum number of replicas in a shard or replication group is:
--
-- -   Redis (cluster mode disabled)
--
--     -   If Multi-AZ: 1
--
--     -   If Multi-AZ: 0
--
-- -   Redis (cluster mode enabled): 0 (though you will not be able to
--     failover to a replica if your primary node fails)
configureShard_newReplicaCount :: Lens.Lens' ConfigureShard Prelude.Int
configureShard_newReplicaCount :: Lens' ConfigureShard Int
configureShard_newReplicaCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigureShard' {Int
newReplicaCount' :: Int
$sel:newReplicaCount':ConfigureShard' :: ConfigureShard -> Int
newReplicaCount'} -> Int
newReplicaCount') (\s :: ConfigureShard
s@ConfigureShard' {} Int
a -> ConfigureShard
s {$sel:newReplicaCount':ConfigureShard' :: Int
newReplicaCount' = Int
a} :: ConfigureShard)

instance Prelude.Hashable ConfigureShard where
  hashWithSalt :: Int -> ConfigureShard -> Int
hashWithSalt Int
_salt ConfigureShard' {Int
Maybe [Text]
Text
newReplicaCount' :: Int
nodeGroupId :: Text
preferredOutpostArns :: Maybe [Text]
preferredAvailabilityZones :: Maybe [Text]
$sel:newReplicaCount':ConfigureShard' :: ConfigureShard -> Int
$sel:nodeGroupId:ConfigureShard' :: ConfigureShard -> Text
$sel:preferredOutpostArns:ConfigureShard' :: ConfigureShard -> Maybe [Text]
$sel:preferredAvailabilityZones:ConfigureShard' :: ConfigureShard -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
preferredAvailabilityZones
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
preferredOutpostArns
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
nodeGroupId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
newReplicaCount'

instance Prelude.NFData ConfigureShard where
  rnf :: ConfigureShard -> ()
rnf ConfigureShard' {Int
Maybe [Text]
Text
newReplicaCount' :: Int
nodeGroupId :: Text
preferredOutpostArns :: Maybe [Text]
preferredAvailabilityZones :: Maybe [Text]
$sel:newReplicaCount':ConfigureShard' :: ConfigureShard -> Int
$sel:nodeGroupId:ConfigureShard' :: ConfigureShard -> Text
$sel:preferredOutpostArns:ConfigureShard' :: ConfigureShard -> Maybe [Text]
$sel:preferredAvailabilityZones:ConfigureShard' :: ConfigureShard -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
preferredAvailabilityZones
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
preferredOutpostArns
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
nodeGroupId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
newReplicaCount'

instance Data.ToQuery ConfigureShard where
  toQuery :: ConfigureShard -> QueryString
toQuery ConfigureShard' {Int
Maybe [Text]
Text
newReplicaCount' :: Int
nodeGroupId :: Text
preferredOutpostArns :: Maybe [Text]
preferredAvailabilityZones :: Maybe [Text]
$sel:newReplicaCount':ConfigureShard' :: ConfigureShard -> Int
$sel:nodeGroupId:ConfigureShard' :: ConfigureShard -> Text
$sel:preferredOutpostArns:ConfigureShard' :: ConfigureShard -> Maybe [Text]
$sel:preferredAvailabilityZones:ConfigureShard' :: ConfigureShard -> Maybe [Text]
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"PreferredAvailabilityZones"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a. ToQuery a => a -> QueryString
Data.toQuery
            ( forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"PreferredAvailabilityZone"
                forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
preferredAvailabilityZones
            ),
        ByteString
"PreferredOutpostArns"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a. ToQuery a => a -> QueryString
Data.toQuery
            ( forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"PreferredOutpostArn"
                forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
preferredOutpostArns
            ),
        ByteString
"NodeGroupId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
nodeGroupId,
        ByteString
"NewReplicaCount" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Int
newReplicaCount'
      ]