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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(ConfigureShard -> ConfigureShard -> Bool)
-> (ConfigureShard -> ConfigureShard -> Bool) -> Eq ConfigureShard
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]
(Int -> ReadS ConfigureShard)
-> ReadS [ConfigureShard]
-> ReadPrec ConfigureShard
-> ReadPrec [ConfigureShard]
-> Read 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
(Int -> ConfigureShard -> ShowS)
-> (ConfigureShard -> String)
-> ([ConfigureShard] -> ShowS)
-> Show ConfigureShard
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. ConfigureShard -> Rep ConfigureShard x)
-> (forall x. Rep ConfigureShard x -> ConfigureShard)
-> Generic ConfigureShard
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' :: Maybe [Text] -> Maybe [Text] -> Text -> Int -> ConfigureShard
ConfigureShard'
    { $sel:preferredAvailabilityZones:ConfigureShard' :: Maybe [Text]
preferredAvailabilityZones =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:preferredOutpostArns:ConfigureShard' :: Maybe [Text]
preferredOutpostArns = Maybe [Text]
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 :: (Maybe [Text] -> f (Maybe [Text]))
-> ConfigureShard -> f ConfigureShard
configureShard_preferredAvailabilityZones = (ConfigureShard -> Maybe [Text])
-> (ConfigureShard -> Maybe [Text] -> ConfigureShard)
-> Lens ConfigureShard ConfigureShard (Maybe [Text]) (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text]))
 -> ConfigureShard -> f ConfigureShard)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ConfigureShard
-> f ConfigureShard
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
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 :: (Maybe [Text] -> f (Maybe [Text]))
-> ConfigureShard -> f ConfigureShard
configureShard_preferredOutpostArns = (ConfigureShard -> Maybe [Text])
-> (ConfigureShard -> Maybe [Text] -> ConfigureShard)
-> Lens ConfigureShard ConfigureShard (Maybe [Text]) (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text]))
 -> ConfigureShard -> f ConfigureShard)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ConfigureShard
-> f ConfigureShard
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
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 :: (Text -> f Text) -> ConfigureShard -> f ConfigureShard
configureShard_nodeGroupId = (ConfigureShard -> Text)
-> (ConfigureShard -> Text -> ConfigureShard)
-> Lens ConfigureShard ConfigureShard Text Text
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 :: (Int -> f Int) -> ConfigureShard -> f ConfigureShard
configureShard_newReplicaCount = (ConfigureShard -> Int)
-> (ConfigureShard -> Int -> ConfigureShard)
-> Lens ConfigureShard ConfigureShard Int Int
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

instance Prelude.NFData ConfigureShard

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