{-# 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.ReshardingConfiguration
-- 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.ReshardingConfiguration where

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

-- | A list of @PreferredAvailabilityZones@ objects that specifies the
-- configuration of a node group in the resharded cluster.
--
-- /See:/ 'newReshardingConfiguration' smart constructor.
data ReshardingConfiguration = ReshardingConfiguration'
  { -- | A list of preferred availability zones for the nodes in this cluster.
    ReshardingConfiguration -> Maybe [Text]
preferredAvailabilityZones :: Prelude.Maybe [Prelude.Text],
    -- | Either the ElastiCache for Redis supplied 4-digit id or a user supplied
    -- id for the node group these configuration values apply to.
    ReshardingConfiguration -> Maybe Text
nodeGroupId :: Prelude.Maybe Prelude.Text
  }
  deriving (ReshardingConfiguration -> ReshardingConfiguration -> Bool
(ReshardingConfiguration -> ReshardingConfiguration -> Bool)
-> (ReshardingConfiguration -> ReshardingConfiguration -> Bool)
-> Eq ReshardingConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReshardingConfiguration -> ReshardingConfiguration -> Bool
$c/= :: ReshardingConfiguration -> ReshardingConfiguration -> Bool
== :: ReshardingConfiguration -> ReshardingConfiguration -> Bool
$c== :: ReshardingConfiguration -> ReshardingConfiguration -> Bool
Prelude.Eq, ReadPrec [ReshardingConfiguration]
ReadPrec ReshardingConfiguration
Int -> ReadS ReshardingConfiguration
ReadS [ReshardingConfiguration]
(Int -> ReadS ReshardingConfiguration)
-> ReadS [ReshardingConfiguration]
-> ReadPrec ReshardingConfiguration
-> ReadPrec [ReshardingConfiguration]
-> Read ReshardingConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReshardingConfiguration]
$creadListPrec :: ReadPrec [ReshardingConfiguration]
readPrec :: ReadPrec ReshardingConfiguration
$creadPrec :: ReadPrec ReshardingConfiguration
readList :: ReadS [ReshardingConfiguration]
$creadList :: ReadS [ReshardingConfiguration]
readsPrec :: Int -> ReadS ReshardingConfiguration
$creadsPrec :: Int -> ReadS ReshardingConfiguration
Prelude.Read, Int -> ReshardingConfiguration -> ShowS
[ReshardingConfiguration] -> ShowS
ReshardingConfiguration -> String
(Int -> ReshardingConfiguration -> ShowS)
-> (ReshardingConfiguration -> String)
-> ([ReshardingConfiguration] -> ShowS)
-> Show ReshardingConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReshardingConfiguration] -> ShowS
$cshowList :: [ReshardingConfiguration] -> ShowS
show :: ReshardingConfiguration -> String
$cshow :: ReshardingConfiguration -> String
showsPrec :: Int -> ReshardingConfiguration -> ShowS
$cshowsPrec :: Int -> ReshardingConfiguration -> ShowS
Prelude.Show, (forall x.
 ReshardingConfiguration -> Rep ReshardingConfiguration x)
-> (forall x.
    Rep ReshardingConfiguration x -> ReshardingConfiguration)
-> Generic ReshardingConfiguration
forall x. Rep ReshardingConfiguration x -> ReshardingConfiguration
forall x. ReshardingConfiguration -> Rep ReshardingConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReshardingConfiguration x -> ReshardingConfiguration
$cfrom :: forall x. ReshardingConfiguration -> Rep ReshardingConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ReshardingConfiguration' 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', 'reshardingConfiguration_preferredAvailabilityZones' - A list of preferred availability zones for the nodes in this cluster.
--
-- 'nodeGroupId', 'reshardingConfiguration_nodeGroupId' - Either the ElastiCache for Redis supplied 4-digit id or a user supplied
-- id for the node group these configuration values apply to.
newReshardingConfiguration ::
  ReshardingConfiguration
newReshardingConfiguration :: ReshardingConfiguration
newReshardingConfiguration =
  ReshardingConfiguration' :: Maybe [Text] -> Maybe Text -> ReshardingConfiguration
ReshardingConfiguration'
    { $sel:preferredAvailabilityZones:ReshardingConfiguration' :: Maybe [Text]
preferredAvailabilityZones =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:nodeGroupId:ReshardingConfiguration' :: Maybe Text
nodeGroupId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A list of preferred availability zones for the nodes in this cluster.
reshardingConfiguration_preferredAvailabilityZones :: Lens.Lens' ReshardingConfiguration (Prelude.Maybe [Prelude.Text])
reshardingConfiguration_preferredAvailabilityZones :: (Maybe [Text] -> f (Maybe [Text]))
-> ReshardingConfiguration -> f ReshardingConfiguration
reshardingConfiguration_preferredAvailabilityZones = (ReshardingConfiguration -> Maybe [Text])
-> (ReshardingConfiguration
    -> Maybe [Text] -> ReshardingConfiguration)
-> Lens
     ReshardingConfiguration
     ReshardingConfiguration
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReshardingConfiguration' {Maybe [Text]
preferredAvailabilityZones :: Maybe [Text]
$sel:preferredAvailabilityZones:ReshardingConfiguration' :: ReshardingConfiguration -> Maybe [Text]
preferredAvailabilityZones} -> Maybe [Text]
preferredAvailabilityZones) (\s :: ReshardingConfiguration
s@ReshardingConfiguration' {} Maybe [Text]
a -> ReshardingConfiguration
s {$sel:preferredAvailabilityZones:ReshardingConfiguration' :: Maybe [Text]
preferredAvailabilityZones = Maybe [Text]
a} :: ReshardingConfiguration) ((Maybe [Text] -> f (Maybe [Text]))
 -> ReshardingConfiguration -> f ReshardingConfiguration)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ReshardingConfiguration
-> f ReshardingConfiguration
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

-- | Either the ElastiCache for Redis supplied 4-digit id or a user supplied
-- id for the node group these configuration values apply to.
reshardingConfiguration_nodeGroupId :: Lens.Lens' ReshardingConfiguration (Prelude.Maybe Prelude.Text)
reshardingConfiguration_nodeGroupId :: (Maybe Text -> f (Maybe Text))
-> ReshardingConfiguration -> f ReshardingConfiguration
reshardingConfiguration_nodeGroupId = (ReshardingConfiguration -> Maybe Text)
-> (ReshardingConfiguration
    -> Maybe Text -> ReshardingConfiguration)
-> Lens
     ReshardingConfiguration
     ReshardingConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReshardingConfiguration' {Maybe Text
nodeGroupId :: Maybe Text
$sel:nodeGroupId:ReshardingConfiguration' :: ReshardingConfiguration -> Maybe Text
nodeGroupId} -> Maybe Text
nodeGroupId) (\s :: ReshardingConfiguration
s@ReshardingConfiguration' {} Maybe Text
a -> ReshardingConfiguration
s {$sel:nodeGroupId:ReshardingConfiguration' :: Maybe Text
nodeGroupId = Maybe Text
a} :: ReshardingConfiguration)

instance Prelude.Hashable ReshardingConfiguration

instance Prelude.NFData ReshardingConfiguration

instance Core.ToQuery ReshardingConfiguration where
  toQuery :: ReshardingConfiguration -> QueryString
toQuery ReshardingConfiguration' {Maybe [Text]
Maybe Text
nodeGroupId :: Maybe Text
preferredAvailabilityZones :: Maybe [Text]
$sel:nodeGroupId:ReshardingConfiguration' :: ReshardingConfiguration -> Maybe Text
$sel:preferredAvailabilityZones:ReshardingConfiguration' :: ReshardingConfiguration -> 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
"AvailabilityZone"
                ([Text] -> QueryString) -> Maybe [Text] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
preferredAvailabilityZones
            ),
        ByteString
"NodeGroupId" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
nodeGroupId
      ]