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

import qualified Amazonka.Core as Core
import Amazonka.KafkaConnect.Types.AutoScalingUpdate
import Amazonka.KafkaConnect.Types.ProvisionedCapacityUpdate
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The target capacity for the connector. The capacity can be auto scaled
-- or provisioned.
--
-- /See:/ 'newCapacityUpdate' smart constructor.
data CapacityUpdate = CapacityUpdate'
  { -- | The target auto scaling setting.
    CapacityUpdate -> Maybe AutoScalingUpdate
autoScaling :: Prelude.Maybe AutoScalingUpdate,
    -- | The target settings for provisioned capacity.
    CapacityUpdate -> Maybe ProvisionedCapacityUpdate
provisionedCapacity :: Prelude.Maybe ProvisionedCapacityUpdate
  }
  deriving (CapacityUpdate -> CapacityUpdate -> Bool
(CapacityUpdate -> CapacityUpdate -> Bool)
-> (CapacityUpdate -> CapacityUpdate -> Bool) -> Eq CapacityUpdate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CapacityUpdate -> CapacityUpdate -> Bool
$c/= :: CapacityUpdate -> CapacityUpdate -> Bool
== :: CapacityUpdate -> CapacityUpdate -> Bool
$c== :: CapacityUpdate -> CapacityUpdate -> Bool
Prelude.Eq, ReadPrec [CapacityUpdate]
ReadPrec CapacityUpdate
Int -> ReadS CapacityUpdate
ReadS [CapacityUpdate]
(Int -> ReadS CapacityUpdate)
-> ReadS [CapacityUpdate]
-> ReadPrec CapacityUpdate
-> ReadPrec [CapacityUpdate]
-> Read CapacityUpdate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CapacityUpdate]
$creadListPrec :: ReadPrec [CapacityUpdate]
readPrec :: ReadPrec CapacityUpdate
$creadPrec :: ReadPrec CapacityUpdate
readList :: ReadS [CapacityUpdate]
$creadList :: ReadS [CapacityUpdate]
readsPrec :: Int -> ReadS CapacityUpdate
$creadsPrec :: Int -> ReadS CapacityUpdate
Prelude.Read, Int -> CapacityUpdate -> ShowS
[CapacityUpdate] -> ShowS
CapacityUpdate -> String
(Int -> CapacityUpdate -> ShowS)
-> (CapacityUpdate -> String)
-> ([CapacityUpdate] -> ShowS)
-> Show CapacityUpdate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CapacityUpdate] -> ShowS
$cshowList :: [CapacityUpdate] -> ShowS
show :: CapacityUpdate -> String
$cshow :: CapacityUpdate -> String
showsPrec :: Int -> CapacityUpdate -> ShowS
$cshowsPrec :: Int -> CapacityUpdate -> ShowS
Prelude.Show, (forall x. CapacityUpdate -> Rep CapacityUpdate x)
-> (forall x. Rep CapacityUpdate x -> CapacityUpdate)
-> Generic CapacityUpdate
forall x. Rep CapacityUpdate x -> CapacityUpdate
forall x. CapacityUpdate -> Rep CapacityUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CapacityUpdate x -> CapacityUpdate
$cfrom :: forall x. CapacityUpdate -> Rep CapacityUpdate x
Prelude.Generic)

-- |
-- Create a value of 'CapacityUpdate' 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:
--
-- 'autoScaling', 'capacityUpdate_autoScaling' - The target auto scaling setting.
--
-- 'provisionedCapacity', 'capacityUpdate_provisionedCapacity' - The target settings for provisioned capacity.
newCapacityUpdate ::
  CapacityUpdate
newCapacityUpdate :: CapacityUpdate
newCapacityUpdate =
  CapacityUpdate' :: Maybe AutoScalingUpdate
-> Maybe ProvisionedCapacityUpdate -> CapacityUpdate
CapacityUpdate'
    { $sel:autoScaling:CapacityUpdate' :: Maybe AutoScalingUpdate
autoScaling = Maybe AutoScalingUpdate
forall a. Maybe a
Prelude.Nothing,
      $sel:provisionedCapacity:CapacityUpdate' :: Maybe ProvisionedCapacityUpdate
provisionedCapacity = Maybe ProvisionedCapacityUpdate
forall a. Maybe a
Prelude.Nothing
    }

-- | The target auto scaling setting.
capacityUpdate_autoScaling :: Lens.Lens' CapacityUpdate (Prelude.Maybe AutoScalingUpdate)
capacityUpdate_autoScaling :: (Maybe AutoScalingUpdate -> f (Maybe AutoScalingUpdate))
-> CapacityUpdate -> f CapacityUpdate
capacityUpdate_autoScaling = (CapacityUpdate -> Maybe AutoScalingUpdate)
-> (CapacityUpdate -> Maybe AutoScalingUpdate -> CapacityUpdate)
-> Lens
     CapacityUpdate
     CapacityUpdate
     (Maybe AutoScalingUpdate)
     (Maybe AutoScalingUpdate)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CapacityUpdate' {Maybe AutoScalingUpdate
autoScaling :: Maybe AutoScalingUpdate
$sel:autoScaling:CapacityUpdate' :: CapacityUpdate -> Maybe AutoScalingUpdate
autoScaling} -> Maybe AutoScalingUpdate
autoScaling) (\s :: CapacityUpdate
s@CapacityUpdate' {} Maybe AutoScalingUpdate
a -> CapacityUpdate
s {$sel:autoScaling:CapacityUpdate' :: Maybe AutoScalingUpdate
autoScaling = Maybe AutoScalingUpdate
a} :: CapacityUpdate)

-- | The target settings for provisioned capacity.
capacityUpdate_provisionedCapacity :: Lens.Lens' CapacityUpdate (Prelude.Maybe ProvisionedCapacityUpdate)
capacityUpdate_provisionedCapacity :: (Maybe ProvisionedCapacityUpdate
 -> f (Maybe ProvisionedCapacityUpdate))
-> CapacityUpdate -> f CapacityUpdate
capacityUpdate_provisionedCapacity = (CapacityUpdate -> Maybe ProvisionedCapacityUpdate)
-> (CapacityUpdate
    -> Maybe ProvisionedCapacityUpdate -> CapacityUpdate)
-> Lens
     CapacityUpdate
     CapacityUpdate
     (Maybe ProvisionedCapacityUpdate)
     (Maybe ProvisionedCapacityUpdate)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CapacityUpdate' {Maybe ProvisionedCapacityUpdate
provisionedCapacity :: Maybe ProvisionedCapacityUpdate
$sel:provisionedCapacity:CapacityUpdate' :: CapacityUpdate -> Maybe ProvisionedCapacityUpdate
provisionedCapacity} -> Maybe ProvisionedCapacityUpdate
provisionedCapacity) (\s :: CapacityUpdate
s@CapacityUpdate' {} Maybe ProvisionedCapacityUpdate
a -> CapacityUpdate
s {$sel:provisionedCapacity:CapacityUpdate' :: Maybe ProvisionedCapacityUpdate
provisionedCapacity = Maybe ProvisionedCapacityUpdate
a} :: CapacityUpdate)

instance Prelude.Hashable CapacityUpdate

instance Prelude.NFData CapacityUpdate

instance Core.ToJSON CapacityUpdate where
  toJSON :: CapacityUpdate -> Value
toJSON CapacityUpdate' {Maybe ProvisionedCapacityUpdate
Maybe AutoScalingUpdate
provisionedCapacity :: Maybe ProvisionedCapacityUpdate
autoScaling :: Maybe AutoScalingUpdate
$sel:provisionedCapacity:CapacityUpdate' :: CapacityUpdate -> Maybe ProvisionedCapacityUpdate
$sel:autoScaling:CapacityUpdate' :: CapacityUpdate -> Maybe AutoScalingUpdate
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"autoScaling" Text -> AutoScalingUpdate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (AutoScalingUpdate -> Pair)
-> Maybe AutoScalingUpdate -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AutoScalingUpdate
autoScaling,
            (Text
"provisionedCapacity" Text -> ProvisionedCapacityUpdate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ProvisionedCapacityUpdate -> Pair)
-> Maybe ProvisionedCapacityUpdate -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ProvisionedCapacityUpdate
provisionedCapacity
          ]
      )