{-# 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.CloudSearch.Types.ScalingParameters
-- 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.CloudSearch.Types.ScalingParameters where

import Amazonka.CloudSearch.Types.PartitionInstanceType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The desired instance type and desired number of replicas of each index
-- partition.
--
-- /See:/ 'newScalingParameters' smart constructor.
data ScalingParameters = ScalingParameters'
  { -- | The instance type that you want to preconfigure for your domain. For
    -- example, @search.m1.small@.
    ScalingParameters -> Maybe PartitionInstanceType
desiredInstanceType :: Prelude.Maybe PartitionInstanceType,
    -- | The number of replicas you want to preconfigure for each index
    -- partition.
    ScalingParameters -> Maybe Natural
desiredReplicationCount :: Prelude.Maybe Prelude.Natural,
    -- | The number of partitions you want to preconfigure for your domain. Only
    -- valid when you select @m2.2xlarge@ as the desired instance type.
    ScalingParameters -> Maybe Natural
desiredPartitionCount :: Prelude.Maybe Prelude.Natural
  }
  deriving (ScalingParameters -> ScalingParameters -> Bool
(ScalingParameters -> ScalingParameters -> Bool)
-> (ScalingParameters -> ScalingParameters -> Bool)
-> Eq ScalingParameters
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ScalingParameters -> ScalingParameters -> Bool
$c/= :: ScalingParameters -> ScalingParameters -> Bool
== :: ScalingParameters -> ScalingParameters -> Bool
$c== :: ScalingParameters -> ScalingParameters -> Bool
Prelude.Eq, ReadPrec [ScalingParameters]
ReadPrec ScalingParameters
Int -> ReadS ScalingParameters
ReadS [ScalingParameters]
(Int -> ReadS ScalingParameters)
-> ReadS [ScalingParameters]
-> ReadPrec ScalingParameters
-> ReadPrec [ScalingParameters]
-> Read ScalingParameters
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ScalingParameters]
$creadListPrec :: ReadPrec [ScalingParameters]
readPrec :: ReadPrec ScalingParameters
$creadPrec :: ReadPrec ScalingParameters
readList :: ReadS [ScalingParameters]
$creadList :: ReadS [ScalingParameters]
readsPrec :: Int -> ReadS ScalingParameters
$creadsPrec :: Int -> ReadS ScalingParameters
Prelude.Read, Int -> ScalingParameters -> ShowS
[ScalingParameters] -> ShowS
ScalingParameters -> String
(Int -> ScalingParameters -> ShowS)
-> (ScalingParameters -> String)
-> ([ScalingParameters] -> ShowS)
-> Show ScalingParameters
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ScalingParameters] -> ShowS
$cshowList :: [ScalingParameters] -> ShowS
show :: ScalingParameters -> String
$cshow :: ScalingParameters -> String
showsPrec :: Int -> ScalingParameters -> ShowS
$cshowsPrec :: Int -> ScalingParameters -> ShowS
Prelude.Show, (forall x. ScalingParameters -> Rep ScalingParameters x)
-> (forall x. Rep ScalingParameters x -> ScalingParameters)
-> Generic ScalingParameters
forall x. Rep ScalingParameters x -> ScalingParameters
forall x. ScalingParameters -> Rep ScalingParameters x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ScalingParameters x -> ScalingParameters
$cfrom :: forall x. ScalingParameters -> Rep ScalingParameters x
Prelude.Generic)

-- |
-- Create a value of 'ScalingParameters' 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:
--
-- 'desiredInstanceType', 'scalingParameters_desiredInstanceType' - The instance type that you want to preconfigure for your domain. For
-- example, @search.m1.small@.
--
-- 'desiredReplicationCount', 'scalingParameters_desiredReplicationCount' - The number of replicas you want to preconfigure for each index
-- partition.
--
-- 'desiredPartitionCount', 'scalingParameters_desiredPartitionCount' - The number of partitions you want to preconfigure for your domain. Only
-- valid when you select @m2.2xlarge@ as the desired instance type.
newScalingParameters ::
  ScalingParameters
newScalingParameters :: ScalingParameters
newScalingParameters =
  ScalingParameters' :: Maybe PartitionInstanceType
-> Maybe Natural -> Maybe Natural -> ScalingParameters
ScalingParameters'
    { $sel:desiredInstanceType:ScalingParameters' :: Maybe PartitionInstanceType
desiredInstanceType =
        Maybe PartitionInstanceType
forall a. Maybe a
Prelude.Nothing,
      $sel:desiredReplicationCount:ScalingParameters' :: Maybe Natural
desiredReplicationCount = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:desiredPartitionCount:ScalingParameters' :: Maybe Natural
desiredPartitionCount = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The instance type that you want to preconfigure for your domain. For
-- example, @search.m1.small@.
scalingParameters_desiredInstanceType :: Lens.Lens' ScalingParameters (Prelude.Maybe PartitionInstanceType)
scalingParameters_desiredInstanceType :: (Maybe PartitionInstanceType -> f (Maybe PartitionInstanceType))
-> ScalingParameters -> f ScalingParameters
scalingParameters_desiredInstanceType = (ScalingParameters -> Maybe PartitionInstanceType)
-> (ScalingParameters
    -> Maybe PartitionInstanceType -> ScalingParameters)
-> Lens
     ScalingParameters
     ScalingParameters
     (Maybe PartitionInstanceType)
     (Maybe PartitionInstanceType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingParameters' {Maybe PartitionInstanceType
desiredInstanceType :: Maybe PartitionInstanceType
$sel:desiredInstanceType:ScalingParameters' :: ScalingParameters -> Maybe PartitionInstanceType
desiredInstanceType} -> Maybe PartitionInstanceType
desiredInstanceType) (\s :: ScalingParameters
s@ScalingParameters' {} Maybe PartitionInstanceType
a -> ScalingParameters
s {$sel:desiredInstanceType:ScalingParameters' :: Maybe PartitionInstanceType
desiredInstanceType = Maybe PartitionInstanceType
a} :: ScalingParameters)

-- | The number of replicas you want to preconfigure for each index
-- partition.
scalingParameters_desiredReplicationCount :: Lens.Lens' ScalingParameters (Prelude.Maybe Prelude.Natural)
scalingParameters_desiredReplicationCount :: (Maybe Natural -> f (Maybe Natural))
-> ScalingParameters -> f ScalingParameters
scalingParameters_desiredReplicationCount = (ScalingParameters -> Maybe Natural)
-> (ScalingParameters -> Maybe Natural -> ScalingParameters)
-> Lens
     ScalingParameters ScalingParameters (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingParameters' {Maybe Natural
desiredReplicationCount :: Maybe Natural
$sel:desiredReplicationCount:ScalingParameters' :: ScalingParameters -> Maybe Natural
desiredReplicationCount} -> Maybe Natural
desiredReplicationCount) (\s :: ScalingParameters
s@ScalingParameters' {} Maybe Natural
a -> ScalingParameters
s {$sel:desiredReplicationCount:ScalingParameters' :: Maybe Natural
desiredReplicationCount = Maybe Natural
a} :: ScalingParameters)

-- | The number of partitions you want to preconfigure for your domain. Only
-- valid when you select @m2.2xlarge@ as the desired instance type.
scalingParameters_desiredPartitionCount :: Lens.Lens' ScalingParameters (Prelude.Maybe Prelude.Natural)
scalingParameters_desiredPartitionCount :: (Maybe Natural -> f (Maybe Natural))
-> ScalingParameters -> f ScalingParameters
scalingParameters_desiredPartitionCount = (ScalingParameters -> Maybe Natural)
-> (ScalingParameters -> Maybe Natural -> ScalingParameters)
-> Lens
     ScalingParameters ScalingParameters (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingParameters' {Maybe Natural
desiredPartitionCount :: Maybe Natural
$sel:desiredPartitionCount:ScalingParameters' :: ScalingParameters -> Maybe Natural
desiredPartitionCount} -> Maybe Natural
desiredPartitionCount) (\s :: ScalingParameters
s@ScalingParameters' {} Maybe Natural
a -> ScalingParameters
s {$sel:desiredPartitionCount:ScalingParameters' :: Maybe Natural
desiredPartitionCount = Maybe Natural
a} :: ScalingParameters)

instance Core.FromXML ScalingParameters where
  parseXML :: [Node] -> Either String ScalingParameters
parseXML [Node]
x =
    Maybe PartitionInstanceType
-> Maybe Natural -> Maybe Natural -> ScalingParameters
ScalingParameters'
      (Maybe PartitionInstanceType
 -> Maybe Natural -> Maybe Natural -> ScalingParameters)
-> Either String (Maybe PartitionInstanceType)
-> Either
     String (Maybe Natural -> Maybe Natural -> ScalingParameters)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe PartitionInstanceType)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"DesiredInstanceType")
      Either String (Maybe Natural -> Maybe Natural -> ScalingParameters)
-> Either String (Maybe Natural)
-> Either String (Maybe Natural -> ScalingParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Natural)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"DesiredReplicationCount")
      Either String (Maybe Natural -> ScalingParameters)
-> Either String (Maybe Natural) -> Either String ScalingParameters
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Natural)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"DesiredPartitionCount")

instance Prelude.Hashable ScalingParameters

instance Prelude.NFData ScalingParameters

instance Core.ToQuery ScalingParameters where
  toQuery :: ScalingParameters -> QueryString
toQuery ScalingParameters' {Maybe Natural
Maybe PartitionInstanceType
desiredPartitionCount :: Maybe Natural
desiredReplicationCount :: Maybe Natural
desiredInstanceType :: Maybe PartitionInstanceType
$sel:desiredPartitionCount:ScalingParameters' :: ScalingParameters -> Maybe Natural
$sel:desiredReplicationCount:ScalingParameters' :: ScalingParameters -> Maybe Natural
$sel:desiredInstanceType:ScalingParameters' :: ScalingParameters -> Maybe PartitionInstanceType
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"DesiredInstanceType" ByteString -> Maybe PartitionInstanceType -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe PartitionInstanceType
desiredInstanceType,
        ByteString
"DesiredReplicationCount"
          ByteString -> Maybe Natural -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Natural
desiredReplicationCount,
        ByteString
"DesiredPartitionCount"
          ByteString -> Maybe Natural -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Natural
desiredPartitionCount
      ]