{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 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,
    -- | The number of replicas you want to preconfigure for each index
    -- partition.
    ScalingParameters -> Maybe Natural
desiredReplicationCount :: Prelude.Maybe Prelude.Natural
  }
  deriving (ScalingParameters -> ScalingParameters -> Bool
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]
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
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. 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@.
--
-- '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.
--
-- 'desiredReplicationCount', 'scalingParameters_desiredReplicationCount' - The number of replicas you want to preconfigure for each index
-- partition.
newScalingParameters ::
  ScalingParameters
newScalingParameters :: ScalingParameters
newScalingParameters =
  ScalingParameters'
    { $sel:desiredInstanceType:ScalingParameters' :: Maybe PartitionInstanceType
desiredInstanceType =
        forall a. Maybe a
Prelude.Nothing,
      $sel:desiredPartitionCount:ScalingParameters' :: Maybe Natural
desiredPartitionCount = forall a. Maybe a
Prelude.Nothing,
      $sel:desiredReplicationCount:ScalingParameters' :: Maybe Natural
desiredReplicationCount = 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 :: Lens' ScalingParameters (Maybe PartitionInstanceType)
scalingParameters_desiredInstanceType = 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 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 :: Lens' ScalingParameters (Maybe Natural)
scalingParameters_desiredPartitionCount = 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)

-- | The number of replicas you want to preconfigure for each index
-- partition.
scalingParameters_desiredReplicationCount :: Lens.Lens' ScalingParameters (Prelude.Maybe Prelude.Natural)
scalingParameters_desiredReplicationCount :: Lens' ScalingParameters (Maybe Natural)
scalingParameters_desiredReplicationCount = 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)

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

instance Prelude.Hashable ScalingParameters where
  hashWithSalt :: Int -> ScalingParameters -> Int
hashWithSalt Int
_salt ScalingParameters' {Maybe Natural
Maybe PartitionInstanceType
desiredReplicationCount :: Maybe Natural
desiredPartitionCount :: Maybe Natural
desiredInstanceType :: Maybe PartitionInstanceType
$sel:desiredReplicationCount:ScalingParameters' :: ScalingParameters -> Maybe Natural
$sel:desiredPartitionCount:ScalingParameters' :: ScalingParameters -> Maybe Natural
$sel:desiredInstanceType:ScalingParameters' :: ScalingParameters -> Maybe PartitionInstanceType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe PartitionInstanceType
desiredInstanceType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
desiredPartitionCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
desiredReplicationCount

instance Prelude.NFData ScalingParameters where
  rnf :: ScalingParameters -> ()
rnf ScalingParameters' {Maybe Natural
Maybe PartitionInstanceType
desiredReplicationCount :: Maybe Natural
desiredPartitionCount :: Maybe Natural
desiredInstanceType :: Maybe PartitionInstanceType
$sel:desiredReplicationCount:ScalingParameters' :: ScalingParameters -> Maybe Natural
$sel:desiredPartitionCount:ScalingParameters' :: ScalingParameters -> Maybe Natural
$sel:desiredInstanceType:ScalingParameters' :: ScalingParameters -> Maybe PartitionInstanceType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe PartitionInstanceType
desiredInstanceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
desiredPartitionCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
desiredReplicationCount

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