{-# 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.KafkaConnect.Types.AutoScalingUpdate
-- 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.KafkaConnect.Types.AutoScalingUpdate where

import qualified Amazonka.Core as Core
import Amazonka.KafkaConnect.Types.ScaleInPolicyUpdate
import Amazonka.KafkaConnect.Types.ScaleOutPolicyUpdate
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The updates to the auto scaling parameters for the connector.
--
-- /See:/ 'newAutoScalingUpdate' smart constructor.
data AutoScalingUpdate = AutoScalingUpdate'
  { -- | The target maximum number of workers allocated to the connector.
    AutoScalingUpdate -> Natural
maxWorkerCount :: Prelude.Natural,
    -- | The target number of microcontroller units (MCUs) allocated to each
    -- connector worker. The valid values are 1,2,4,8.
    AutoScalingUpdate -> Natural
mcuCount :: Prelude.Natural,
    -- | The target minimum number of workers allocated to the connector.
    AutoScalingUpdate -> Natural
minWorkerCount :: Prelude.Natural,
    -- | The target sacle-in policy for the connector.
    AutoScalingUpdate -> ScaleInPolicyUpdate
scaleInPolicy :: ScaleInPolicyUpdate,
    -- | The target sacle-out policy for the connector.
    AutoScalingUpdate -> ScaleOutPolicyUpdate
scaleOutPolicy :: ScaleOutPolicyUpdate
  }
  deriving (AutoScalingUpdate -> AutoScalingUpdate -> Bool
(AutoScalingUpdate -> AutoScalingUpdate -> Bool)
-> (AutoScalingUpdate -> AutoScalingUpdate -> Bool)
-> Eq AutoScalingUpdate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AutoScalingUpdate -> AutoScalingUpdate -> Bool
$c/= :: AutoScalingUpdate -> AutoScalingUpdate -> Bool
== :: AutoScalingUpdate -> AutoScalingUpdate -> Bool
$c== :: AutoScalingUpdate -> AutoScalingUpdate -> Bool
Prelude.Eq, ReadPrec [AutoScalingUpdate]
ReadPrec AutoScalingUpdate
Int -> ReadS AutoScalingUpdate
ReadS [AutoScalingUpdate]
(Int -> ReadS AutoScalingUpdate)
-> ReadS [AutoScalingUpdate]
-> ReadPrec AutoScalingUpdate
-> ReadPrec [AutoScalingUpdate]
-> Read AutoScalingUpdate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AutoScalingUpdate]
$creadListPrec :: ReadPrec [AutoScalingUpdate]
readPrec :: ReadPrec AutoScalingUpdate
$creadPrec :: ReadPrec AutoScalingUpdate
readList :: ReadS [AutoScalingUpdate]
$creadList :: ReadS [AutoScalingUpdate]
readsPrec :: Int -> ReadS AutoScalingUpdate
$creadsPrec :: Int -> ReadS AutoScalingUpdate
Prelude.Read, Int -> AutoScalingUpdate -> ShowS
[AutoScalingUpdate] -> ShowS
AutoScalingUpdate -> String
(Int -> AutoScalingUpdate -> ShowS)
-> (AutoScalingUpdate -> String)
-> ([AutoScalingUpdate] -> ShowS)
-> Show AutoScalingUpdate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AutoScalingUpdate] -> ShowS
$cshowList :: [AutoScalingUpdate] -> ShowS
show :: AutoScalingUpdate -> String
$cshow :: AutoScalingUpdate -> String
showsPrec :: Int -> AutoScalingUpdate -> ShowS
$cshowsPrec :: Int -> AutoScalingUpdate -> ShowS
Prelude.Show, (forall x. AutoScalingUpdate -> Rep AutoScalingUpdate x)
-> (forall x. Rep AutoScalingUpdate x -> AutoScalingUpdate)
-> Generic AutoScalingUpdate
forall x. Rep AutoScalingUpdate x -> AutoScalingUpdate
forall x. AutoScalingUpdate -> Rep AutoScalingUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AutoScalingUpdate x -> AutoScalingUpdate
$cfrom :: forall x. AutoScalingUpdate -> Rep AutoScalingUpdate x
Prelude.Generic)

-- |
-- Create a value of 'AutoScalingUpdate' 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:
--
-- 'maxWorkerCount', 'autoScalingUpdate_maxWorkerCount' - The target maximum number of workers allocated to the connector.
--
-- 'mcuCount', 'autoScalingUpdate_mcuCount' - The target number of microcontroller units (MCUs) allocated to each
-- connector worker. The valid values are 1,2,4,8.
--
-- 'minWorkerCount', 'autoScalingUpdate_minWorkerCount' - The target minimum number of workers allocated to the connector.
--
-- 'scaleInPolicy', 'autoScalingUpdate_scaleInPolicy' - The target sacle-in policy for the connector.
--
-- 'scaleOutPolicy', 'autoScalingUpdate_scaleOutPolicy' - The target sacle-out policy for the connector.
newAutoScalingUpdate ::
  -- | 'maxWorkerCount'
  Prelude.Natural ->
  -- | 'mcuCount'
  Prelude.Natural ->
  -- | 'minWorkerCount'
  Prelude.Natural ->
  -- | 'scaleInPolicy'
  ScaleInPolicyUpdate ->
  -- | 'scaleOutPolicy'
  ScaleOutPolicyUpdate ->
  AutoScalingUpdate
newAutoScalingUpdate :: Natural
-> Natural
-> Natural
-> ScaleInPolicyUpdate
-> ScaleOutPolicyUpdate
-> AutoScalingUpdate
newAutoScalingUpdate
  Natural
pMaxWorkerCount_
  Natural
pMcuCount_
  Natural
pMinWorkerCount_
  ScaleInPolicyUpdate
pScaleInPolicy_
  ScaleOutPolicyUpdate
pScaleOutPolicy_ =
    AutoScalingUpdate' :: Natural
-> Natural
-> Natural
-> ScaleInPolicyUpdate
-> ScaleOutPolicyUpdate
-> AutoScalingUpdate
AutoScalingUpdate'
      { $sel:maxWorkerCount:AutoScalingUpdate' :: Natural
maxWorkerCount =
          Natural
pMaxWorkerCount_,
        $sel:mcuCount:AutoScalingUpdate' :: Natural
mcuCount = Natural
pMcuCount_,
        $sel:minWorkerCount:AutoScalingUpdate' :: Natural
minWorkerCount = Natural
pMinWorkerCount_,
        $sel:scaleInPolicy:AutoScalingUpdate' :: ScaleInPolicyUpdate
scaleInPolicy = ScaleInPolicyUpdate
pScaleInPolicy_,
        $sel:scaleOutPolicy:AutoScalingUpdate' :: ScaleOutPolicyUpdate
scaleOutPolicy = ScaleOutPolicyUpdate
pScaleOutPolicy_
      }

-- | The target maximum number of workers allocated to the connector.
autoScalingUpdate_maxWorkerCount :: Lens.Lens' AutoScalingUpdate Prelude.Natural
autoScalingUpdate_maxWorkerCount :: (Natural -> f Natural) -> AutoScalingUpdate -> f AutoScalingUpdate
autoScalingUpdate_maxWorkerCount = (AutoScalingUpdate -> Natural)
-> (AutoScalingUpdate -> Natural -> AutoScalingUpdate)
-> Lens AutoScalingUpdate AutoScalingUpdate Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoScalingUpdate' {Natural
maxWorkerCount :: Natural
$sel:maxWorkerCount:AutoScalingUpdate' :: AutoScalingUpdate -> Natural
maxWorkerCount} -> Natural
maxWorkerCount) (\s :: AutoScalingUpdate
s@AutoScalingUpdate' {} Natural
a -> AutoScalingUpdate
s {$sel:maxWorkerCount:AutoScalingUpdate' :: Natural
maxWorkerCount = Natural
a} :: AutoScalingUpdate)

-- | The target number of microcontroller units (MCUs) allocated to each
-- connector worker. The valid values are 1,2,4,8.
autoScalingUpdate_mcuCount :: Lens.Lens' AutoScalingUpdate Prelude.Natural
autoScalingUpdate_mcuCount :: (Natural -> f Natural) -> AutoScalingUpdate -> f AutoScalingUpdate
autoScalingUpdate_mcuCount = (AutoScalingUpdate -> Natural)
-> (AutoScalingUpdate -> Natural -> AutoScalingUpdate)
-> Lens AutoScalingUpdate AutoScalingUpdate Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoScalingUpdate' {Natural
mcuCount :: Natural
$sel:mcuCount:AutoScalingUpdate' :: AutoScalingUpdate -> Natural
mcuCount} -> Natural
mcuCount) (\s :: AutoScalingUpdate
s@AutoScalingUpdate' {} Natural
a -> AutoScalingUpdate
s {$sel:mcuCount:AutoScalingUpdate' :: Natural
mcuCount = Natural
a} :: AutoScalingUpdate)

-- | The target minimum number of workers allocated to the connector.
autoScalingUpdate_minWorkerCount :: Lens.Lens' AutoScalingUpdate Prelude.Natural
autoScalingUpdate_minWorkerCount :: (Natural -> f Natural) -> AutoScalingUpdate -> f AutoScalingUpdate
autoScalingUpdate_minWorkerCount = (AutoScalingUpdate -> Natural)
-> (AutoScalingUpdate -> Natural -> AutoScalingUpdate)
-> Lens AutoScalingUpdate AutoScalingUpdate Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoScalingUpdate' {Natural
minWorkerCount :: Natural
$sel:minWorkerCount:AutoScalingUpdate' :: AutoScalingUpdate -> Natural
minWorkerCount} -> Natural
minWorkerCount) (\s :: AutoScalingUpdate
s@AutoScalingUpdate' {} Natural
a -> AutoScalingUpdate
s {$sel:minWorkerCount:AutoScalingUpdate' :: Natural
minWorkerCount = Natural
a} :: AutoScalingUpdate)

-- | The target sacle-in policy for the connector.
autoScalingUpdate_scaleInPolicy :: Lens.Lens' AutoScalingUpdate ScaleInPolicyUpdate
autoScalingUpdate_scaleInPolicy :: (ScaleInPolicyUpdate -> f ScaleInPolicyUpdate)
-> AutoScalingUpdate -> f AutoScalingUpdate
autoScalingUpdate_scaleInPolicy = (AutoScalingUpdate -> ScaleInPolicyUpdate)
-> (AutoScalingUpdate -> ScaleInPolicyUpdate -> AutoScalingUpdate)
-> Lens
     AutoScalingUpdate
     AutoScalingUpdate
     ScaleInPolicyUpdate
     ScaleInPolicyUpdate
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoScalingUpdate' {ScaleInPolicyUpdate
scaleInPolicy :: ScaleInPolicyUpdate
$sel:scaleInPolicy:AutoScalingUpdate' :: AutoScalingUpdate -> ScaleInPolicyUpdate
scaleInPolicy} -> ScaleInPolicyUpdate
scaleInPolicy) (\s :: AutoScalingUpdate
s@AutoScalingUpdate' {} ScaleInPolicyUpdate
a -> AutoScalingUpdate
s {$sel:scaleInPolicy:AutoScalingUpdate' :: ScaleInPolicyUpdate
scaleInPolicy = ScaleInPolicyUpdate
a} :: AutoScalingUpdate)

-- | The target sacle-out policy for the connector.
autoScalingUpdate_scaleOutPolicy :: Lens.Lens' AutoScalingUpdate ScaleOutPolicyUpdate
autoScalingUpdate_scaleOutPolicy :: (ScaleOutPolicyUpdate -> f ScaleOutPolicyUpdate)
-> AutoScalingUpdate -> f AutoScalingUpdate
autoScalingUpdate_scaleOutPolicy = (AutoScalingUpdate -> ScaleOutPolicyUpdate)
-> (AutoScalingUpdate -> ScaleOutPolicyUpdate -> AutoScalingUpdate)
-> Lens
     AutoScalingUpdate
     AutoScalingUpdate
     ScaleOutPolicyUpdate
     ScaleOutPolicyUpdate
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoScalingUpdate' {ScaleOutPolicyUpdate
scaleOutPolicy :: ScaleOutPolicyUpdate
$sel:scaleOutPolicy:AutoScalingUpdate' :: AutoScalingUpdate -> ScaleOutPolicyUpdate
scaleOutPolicy} -> ScaleOutPolicyUpdate
scaleOutPolicy) (\s :: AutoScalingUpdate
s@AutoScalingUpdate' {} ScaleOutPolicyUpdate
a -> AutoScalingUpdate
s {$sel:scaleOutPolicy:AutoScalingUpdate' :: ScaleOutPolicyUpdate
scaleOutPolicy = ScaleOutPolicyUpdate
a} :: AutoScalingUpdate)

instance Prelude.Hashable AutoScalingUpdate

instance Prelude.NFData AutoScalingUpdate

instance Core.ToJSON AutoScalingUpdate where
  toJSON :: AutoScalingUpdate -> Value
toJSON AutoScalingUpdate' {Natural
ScaleInPolicyUpdate
ScaleOutPolicyUpdate
scaleOutPolicy :: ScaleOutPolicyUpdate
scaleInPolicy :: ScaleInPolicyUpdate
minWorkerCount :: Natural
mcuCount :: Natural
maxWorkerCount :: Natural
$sel:scaleOutPolicy:AutoScalingUpdate' :: AutoScalingUpdate -> ScaleOutPolicyUpdate
$sel:scaleInPolicy:AutoScalingUpdate' :: AutoScalingUpdate -> ScaleInPolicyUpdate
$sel:minWorkerCount:AutoScalingUpdate' :: AutoScalingUpdate -> Natural
$sel:mcuCount:AutoScalingUpdate' :: AutoScalingUpdate -> Natural
$sel:maxWorkerCount:AutoScalingUpdate' :: AutoScalingUpdate -> Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"maxWorkerCount" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
maxWorkerCount),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"mcuCount" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
mcuCount),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"minWorkerCount" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
minWorkerCount),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"scaleInPolicy" Text -> ScaleInPolicyUpdate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ScaleInPolicyUpdate
scaleInPolicy),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"scaleOutPolicy" Text -> ScaleOutPolicyUpdate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ScaleOutPolicyUpdate
scaleOutPolicy)
          ]
      )