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

import qualified Amazonka.Core as Core
import Amazonka.KafkaConnect.Types.ScaleInPolicy
import Amazonka.KafkaConnect.Types.ScaleOutPolicy
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

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

-- |
-- Create a value of 'AutoScaling' 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:
--
-- 'scaleInPolicy', 'autoScaling_scaleInPolicy' - The sacle-in policy for the connector.
--
-- 'scaleOutPolicy', 'autoScaling_scaleOutPolicy' - The sacle-out policy for the connector.
--
-- 'maxWorkerCount', 'autoScaling_maxWorkerCount' - The maximum number of workers allocated to the connector.
--
-- 'mcuCount', 'autoScaling_mcuCount' - The number of microcontroller units (MCUs) allocated to each connector
-- worker. The valid values are 1,2,4,8.
--
-- 'minWorkerCount', 'autoScaling_minWorkerCount' - The minimum number of workers allocated to the connector.
newAutoScaling ::
  -- | 'maxWorkerCount'
  Prelude.Natural ->
  -- | 'mcuCount'
  Prelude.Natural ->
  -- | 'minWorkerCount'
  Prelude.Natural ->
  AutoScaling
newAutoScaling :: Natural -> Natural -> Natural -> AutoScaling
newAutoScaling
  Natural
pMaxWorkerCount_
  Natural
pMcuCount_
  Natural
pMinWorkerCount_ =
    AutoScaling' :: Maybe ScaleInPolicy
-> Maybe ScaleOutPolicy
-> Natural
-> Natural
-> Natural
-> AutoScaling
AutoScaling'
      { $sel:scaleInPolicy:AutoScaling' :: Maybe ScaleInPolicy
scaleInPolicy = Maybe ScaleInPolicy
forall a. Maybe a
Prelude.Nothing,
        $sel:scaleOutPolicy:AutoScaling' :: Maybe ScaleOutPolicy
scaleOutPolicy = Maybe ScaleOutPolicy
forall a. Maybe a
Prelude.Nothing,
        $sel:maxWorkerCount:AutoScaling' :: Natural
maxWorkerCount = Natural
pMaxWorkerCount_,
        $sel:mcuCount:AutoScaling' :: Natural
mcuCount = Natural
pMcuCount_,
        $sel:minWorkerCount:AutoScaling' :: Natural
minWorkerCount = Natural
pMinWorkerCount_
      }

-- | The sacle-in policy for the connector.
autoScaling_scaleInPolicy :: Lens.Lens' AutoScaling (Prelude.Maybe ScaleInPolicy)
autoScaling_scaleInPolicy :: (Maybe ScaleInPolicy -> f (Maybe ScaleInPolicy))
-> AutoScaling -> f AutoScaling
autoScaling_scaleInPolicy = (AutoScaling -> Maybe ScaleInPolicy)
-> (AutoScaling -> Maybe ScaleInPolicy -> AutoScaling)
-> Lens
     AutoScaling AutoScaling (Maybe ScaleInPolicy) (Maybe ScaleInPolicy)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoScaling' {Maybe ScaleInPolicy
scaleInPolicy :: Maybe ScaleInPolicy
$sel:scaleInPolicy:AutoScaling' :: AutoScaling -> Maybe ScaleInPolicy
scaleInPolicy} -> Maybe ScaleInPolicy
scaleInPolicy) (\s :: AutoScaling
s@AutoScaling' {} Maybe ScaleInPolicy
a -> AutoScaling
s {$sel:scaleInPolicy:AutoScaling' :: Maybe ScaleInPolicy
scaleInPolicy = Maybe ScaleInPolicy
a} :: AutoScaling)

-- | The sacle-out policy for the connector.
autoScaling_scaleOutPolicy :: Lens.Lens' AutoScaling (Prelude.Maybe ScaleOutPolicy)
autoScaling_scaleOutPolicy :: (Maybe ScaleOutPolicy -> f (Maybe ScaleOutPolicy))
-> AutoScaling -> f AutoScaling
autoScaling_scaleOutPolicy = (AutoScaling -> Maybe ScaleOutPolicy)
-> (AutoScaling -> Maybe ScaleOutPolicy -> AutoScaling)
-> Lens
     AutoScaling
     AutoScaling
     (Maybe ScaleOutPolicy)
     (Maybe ScaleOutPolicy)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoScaling' {Maybe ScaleOutPolicy
scaleOutPolicy :: Maybe ScaleOutPolicy
$sel:scaleOutPolicy:AutoScaling' :: AutoScaling -> Maybe ScaleOutPolicy
scaleOutPolicy} -> Maybe ScaleOutPolicy
scaleOutPolicy) (\s :: AutoScaling
s@AutoScaling' {} Maybe ScaleOutPolicy
a -> AutoScaling
s {$sel:scaleOutPolicy:AutoScaling' :: Maybe ScaleOutPolicy
scaleOutPolicy = Maybe ScaleOutPolicy
a} :: AutoScaling)

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

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

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

instance Prelude.Hashable AutoScaling

instance Prelude.NFData AutoScaling

instance Core.ToJSON AutoScaling where
  toJSON :: AutoScaling -> Value
toJSON AutoScaling' {Natural
Maybe ScaleInPolicy
Maybe ScaleOutPolicy
minWorkerCount :: Natural
mcuCount :: Natural
maxWorkerCount :: Natural
scaleOutPolicy :: Maybe ScaleOutPolicy
scaleInPolicy :: Maybe ScaleInPolicy
$sel:minWorkerCount:AutoScaling' :: AutoScaling -> Natural
$sel:mcuCount:AutoScaling' :: AutoScaling -> Natural
$sel:maxWorkerCount:AutoScaling' :: AutoScaling -> Natural
$sel:scaleOutPolicy:AutoScaling' :: AutoScaling -> Maybe ScaleOutPolicy
$sel:scaleInPolicy:AutoScaling' :: AutoScaling -> Maybe ScaleInPolicy
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"scaleInPolicy" Text -> ScaleInPolicy -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ScaleInPolicy -> Pair) -> Maybe ScaleInPolicy -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ScaleInPolicy
scaleInPolicy,
            (Text
"scaleOutPolicy" Text -> ScaleOutPolicy -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ScaleOutPolicy -> Pair) -> Maybe ScaleOutPolicy -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ScaleOutPolicy
scaleOutPolicy,
            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)
          ]
      )