{-# 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.KinesisAnalyticsV2.Types.ParallelismConfiguration
-- 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.KinesisAnalyticsV2.Types.ParallelismConfiguration where

import qualified Amazonka.Core as Core
import Amazonka.KinesisAnalyticsV2.Types.ConfigurationType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes parameters for how a Flink-based Kinesis Data Analytics
-- application executes multiple tasks simultaneously. For more information
-- about parallelism, see
-- <https://ci.apache.org/projects/flink/flink-docs-release-1.8/dev/parallel.html Parallel Execution>
-- in the
-- <https://ci.apache.org/projects/flink/flink-docs-release-1.8/ Apache Flink Documentation>.
--
-- /See:/ 'newParallelismConfiguration' smart constructor.
data ParallelismConfiguration = ParallelismConfiguration'
  { -- | Describes whether the Kinesis Data Analytics service can increase the
    -- parallelism of the application in response to increased throughput.
    ParallelismConfiguration -> Maybe Bool
autoScalingEnabled :: Prelude.Maybe Prelude.Bool,
    -- | Describes the number of parallel tasks that a Flink-based Kinesis Data
    -- Analytics application can perform per Kinesis Processing Unit (KPU) used
    -- by the application. For more information about KPUs, see
    -- <http://aws.amazon.com/kinesis/data-analytics/pricing/ Amazon Kinesis Data Analytics Pricing>.
    ParallelismConfiguration -> Maybe Natural
parallelismPerKPU :: Prelude.Maybe Prelude.Natural,
    -- | Describes the initial number of parallel tasks that a Flink-based
    -- Kinesis Data Analytics application can perform. If @AutoScalingEnabled@
    -- is set to True, Kinesis Data Analytics increases the
    -- @CurrentParallelism@ value in response to application load. The service
    -- can increase the @CurrentParallelism@ value up to the maximum
    -- parallelism, which is @ParalellismPerKPU@ times the maximum KPUs for the
    -- application. The maximum KPUs for an application is 32 by default, and
    -- can be increased by requesting a limit increase. If application load is
    -- reduced, the service can reduce the @CurrentParallelism@ value down to
    -- the @Parallelism@ setting.
    ParallelismConfiguration -> Maybe Natural
parallelism :: Prelude.Maybe Prelude.Natural,
    -- | Describes whether the application uses the default parallelism for the
    -- Kinesis Data Analytics service. You must set this property to @CUSTOM@
    -- in order to change your application\'s @AutoScalingEnabled@,
    -- @Parallelism@, or @ParallelismPerKPU@ properties.
    ParallelismConfiguration -> ConfigurationType
configurationType :: ConfigurationType
  }
  deriving (ParallelismConfiguration -> ParallelismConfiguration -> Bool
(ParallelismConfiguration -> ParallelismConfiguration -> Bool)
-> (ParallelismConfiguration -> ParallelismConfiguration -> Bool)
-> Eq ParallelismConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ParallelismConfiguration -> ParallelismConfiguration -> Bool
$c/= :: ParallelismConfiguration -> ParallelismConfiguration -> Bool
== :: ParallelismConfiguration -> ParallelismConfiguration -> Bool
$c== :: ParallelismConfiguration -> ParallelismConfiguration -> Bool
Prelude.Eq, ReadPrec [ParallelismConfiguration]
ReadPrec ParallelismConfiguration
Int -> ReadS ParallelismConfiguration
ReadS [ParallelismConfiguration]
(Int -> ReadS ParallelismConfiguration)
-> ReadS [ParallelismConfiguration]
-> ReadPrec ParallelismConfiguration
-> ReadPrec [ParallelismConfiguration]
-> Read ParallelismConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ParallelismConfiguration]
$creadListPrec :: ReadPrec [ParallelismConfiguration]
readPrec :: ReadPrec ParallelismConfiguration
$creadPrec :: ReadPrec ParallelismConfiguration
readList :: ReadS [ParallelismConfiguration]
$creadList :: ReadS [ParallelismConfiguration]
readsPrec :: Int -> ReadS ParallelismConfiguration
$creadsPrec :: Int -> ReadS ParallelismConfiguration
Prelude.Read, Int -> ParallelismConfiguration -> ShowS
[ParallelismConfiguration] -> ShowS
ParallelismConfiguration -> String
(Int -> ParallelismConfiguration -> ShowS)
-> (ParallelismConfiguration -> String)
-> ([ParallelismConfiguration] -> ShowS)
-> Show ParallelismConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ParallelismConfiguration] -> ShowS
$cshowList :: [ParallelismConfiguration] -> ShowS
show :: ParallelismConfiguration -> String
$cshow :: ParallelismConfiguration -> String
showsPrec :: Int -> ParallelismConfiguration -> ShowS
$cshowsPrec :: Int -> ParallelismConfiguration -> ShowS
Prelude.Show, (forall x.
 ParallelismConfiguration -> Rep ParallelismConfiguration x)
-> (forall x.
    Rep ParallelismConfiguration x -> ParallelismConfiguration)
-> Generic ParallelismConfiguration
forall x.
Rep ParallelismConfiguration x -> ParallelismConfiguration
forall x.
ParallelismConfiguration -> Rep ParallelismConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ParallelismConfiguration x -> ParallelismConfiguration
$cfrom :: forall x.
ParallelismConfiguration -> Rep ParallelismConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ParallelismConfiguration' 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:
--
-- 'autoScalingEnabled', 'parallelismConfiguration_autoScalingEnabled' - Describes whether the Kinesis Data Analytics service can increase the
-- parallelism of the application in response to increased throughput.
--
-- 'parallelismPerKPU', 'parallelismConfiguration_parallelismPerKPU' - Describes the number of parallel tasks that a Flink-based Kinesis Data
-- Analytics application can perform per Kinesis Processing Unit (KPU) used
-- by the application. For more information about KPUs, see
-- <http://aws.amazon.com/kinesis/data-analytics/pricing/ Amazon Kinesis Data Analytics Pricing>.
--
-- 'parallelism', 'parallelismConfiguration_parallelism' - Describes the initial number of parallel tasks that a Flink-based
-- Kinesis Data Analytics application can perform. If @AutoScalingEnabled@
-- is set to True, Kinesis Data Analytics increases the
-- @CurrentParallelism@ value in response to application load. The service
-- can increase the @CurrentParallelism@ value up to the maximum
-- parallelism, which is @ParalellismPerKPU@ times the maximum KPUs for the
-- application. The maximum KPUs for an application is 32 by default, and
-- can be increased by requesting a limit increase. If application load is
-- reduced, the service can reduce the @CurrentParallelism@ value down to
-- the @Parallelism@ setting.
--
-- 'configurationType', 'parallelismConfiguration_configurationType' - Describes whether the application uses the default parallelism for the
-- Kinesis Data Analytics service. You must set this property to @CUSTOM@
-- in order to change your application\'s @AutoScalingEnabled@,
-- @Parallelism@, or @ParallelismPerKPU@ properties.
newParallelismConfiguration ::
  -- | 'configurationType'
  ConfigurationType ->
  ParallelismConfiguration
newParallelismConfiguration :: ConfigurationType -> ParallelismConfiguration
newParallelismConfiguration ConfigurationType
pConfigurationType_ =
  ParallelismConfiguration' :: Maybe Bool
-> Maybe Natural
-> Maybe Natural
-> ConfigurationType
-> ParallelismConfiguration
ParallelismConfiguration'
    { $sel:autoScalingEnabled:ParallelismConfiguration' :: Maybe Bool
autoScalingEnabled =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:parallelismPerKPU:ParallelismConfiguration' :: Maybe Natural
parallelismPerKPU = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:parallelism:ParallelismConfiguration' :: Maybe Natural
parallelism = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:configurationType:ParallelismConfiguration' :: ConfigurationType
configurationType = ConfigurationType
pConfigurationType_
    }

-- | Describes whether the Kinesis Data Analytics service can increase the
-- parallelism of the application in response to increased throughput.
parallelismConfiguration_autoScalingEnabled :: Lens.Lens' ParallelismConfiguration (Prelude.Maybe Prelude.Bool)
parallelismConfiguration_autoScalingEnabled :: (Maybe Bool -> f (Maybe Bool))
-> ParallelismConfiguration -> f ParallelismConfiguration
parallelismConfiguration_autoScalingEnabled = (ParallelismConfiguration -> Maybe Bool)
-> (ParallelismConfiguration
    -> Maybe Bool -> ParallelismConfiguration)
-> Lens
     ParallelismConfiguration
     ParallelismConfiguration
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ParallelismConfiguration' {Maybe Bool
autoScalingEnabled :: Maybe Bool
$sel:autoScalingEnabled:ParallelismConfiguration' :: ParallelismConfiguration -> Maybe Bool
autoScalingEnabled} -> Maybe Bool
autoScalingEnabled) (\s :: ParallelismConfiguration
s@ParallelismConfiguration' {} Maybe Bool
a -> ParallelismConfiguration
s {$sel:autoScalingEnabled:ParallelismConfiguration' :: Maybe Bool
autoScalingEnabled = Maybe Bool
a} :: ParallelismConfiguration)

-- | Describes the number of parallel tasks that a Flink-based Kinesis Data
-- Analytics application can perform per Kinesis Processing Unit (KPU) used
-- by the application. For more information about KPUs, see
-- <http://aws.amazon.com/kinesis/data-analytics/pricing/ Amazon Kinesis Data Analytics Pricing>.
parallelismConfiguration_parallelismPerKPU :: Lens.Lens' ParallelismConfiguration (Prelude.Maybe Prelude.Natural)
parallelismConfiguration_parallelismPerKPU :: (Maybe Natural -> f (Maybe Natural))
-> ParallelismConfiguration -> f ParallelismConfiguration
parallelismConfiguration_parallelismPerKPU = (ParallelismConfiguration -> Maybe Natural)
-> (ParallelismConfiguration
    -> Maybe Natural -> ParallelismConfiguration)
-> Lens
     ParallelismConfiguration
     ParallelismConfiguration
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ParallelismConfiguration' {Maybe Natural
parallelismPerKPU :: Maybe Natural
$sel:parallelismPerKPU:ParallelismConfiguration' :: ParallelismConfiguration -> Maybe Natural
parallelismPerKPU} -> Maybe Natural
parallelismPerKPU) (\s :: ParallelismConfiguration
s@ParallelismConfiguration' {} Maybe Natural
a -> ParallelismConfiguration
s {$sel:parallelismPerKPU:ParallelismConfiguration' :: Maybe Natural
parallelismPerKPU = Maybe Natural
a} :: ParallelismConfiguration)

-- | Describes the initial number of parallel tasks that a Flink-based
-- Kinesis Data Analytics application can perform. If @AutoScalingEnabled@
-- is set to True, Kinesis Data Analytics increases the
-- @CurrentParallelism@ value in response to application load. The service
-- can increase the @CurrentParallelism@ value up to the maximum
-- parallelism, which is @ParalellismPerKPU@ times the maximum KPUs for the
-- application. The maximum KPUs for an application is 32 by default, and
-- can be increased by requesting a limit increase. If application load is
-- reduced, the service can reduce the @CurrentParallelism@ value down to
-- the @Parallelism@ setting.
parallelismConfiguration_parallelism :: Lens.Lens' ParallelismConfiguration (Prelude.Maybe Prelude.Natural)
parallelismConfiguration_parallelism :: (Maybe Natural -> f (Maybe Natural))
-> ParallelismConfiguration -> f ParallelismConfiguration
parallelismConfiguration_parallelism = (ParallelismConfiguration -> Maybe Natural)
-> (ParallelismConfiguration
    -> Maybe Natural -> ParallelismConfiguration)
-> Lens
     ParallelismConfiguration
     ParallelismConfiguration
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ParallelismConfiguration' {Maybe Natural
parallelism :: Maybe Natural
$sel:parallelism:ParallelismConfiguration' :: ParallelismConfiguration -> Maybe Natural
parallelism} -> Maybe Natural
parallelism) (\s :: ParallelismConfiguration
s@ParallelismConfiguration' {} Maybe Natural
a -> ParallelismConfiguration
s {$sel:parallelism:ParallelismConfiguration' :: Maybe Natural
parallelism = Maybe Natural
a} :: ParallelismConfiguration)

-- | Describes whether the application uses the default parallelism for the
-- Kinesis Data Analytics service. You must set this property to @CUSTOM@
-- in order to change your application\'s @AutoScalingEnabled@,
-- @Parallelism@, or @ParallelismPerKPU@ properties.
parallelismConfiguration_configurationType :: Lens.Lens' ParallelismConfiguration ConfigurationType
parallelismConfiguration_configurationType :: (ConfigurationType -> f ConfigurationType)
-> ParallelismConfiguration -> f ParallelismConfiguration
parallelismConfiguration_configurationType = (ParallelismConfiguration -> ConfigurationType)
-> (ParallelismConfiguration
    -> ConfigurationType -> ParallelismConfiguration)
-> Lens
     ParallelismConfiguration
     ParallelismConfiguration
     ConfigurationType
     ConfigurationType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ParallelismConfiguration' {ConfigurationType
configurationType :: ConfigurationType
$sel:configurationType:ParallelismConfiguration' :: ParallelismConfiguration -> ConfigurationType
configurationType} -> ConfigurationType
configurationType) (\s :: ParallelismConfiguration
s@ParallelismConfiguration' {} ConfigurationType
a -> ParallelismConfiguration
s {$sel:configurationType:ParallelismConfiguration' :: ConfigurationType
configurationType = ConfigurationType
a} :: ParallelismConfiguration)

instance Prelude.Hashable ParallelismConfiguration

instance Prelude.NFData ParallelismConfiguration

instance Core.ToJSON ParallelismConfiguration where
  toJSON :: ParallelismConfiguration -> Value
toJSON ParallelismConfiguration' {Maybe Bool
Maybe Natural
ConfigurationType
configurationType :: ConfigurationType
parallelism :: Maybe Natural
parallelismPerKPU :: Maybe Natural
autoScalingEnabled :: Maybe Bool
$sel:configurationType:ParallelismConfiguration' :: ParallelismConfiguration -> ConfigurationType
$sel:parallelism:ParallelismConfiguration' :: ParallelismConfiguration -> Maybe Natural
$sel:parallelismPerKPU:ParallelismConfiguration' :: ParallelismConfiguration -> Maybe Natural
$sel:autoScalingEnabled:ParallelismConfiguration' :: ParallelismConfiguration -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AutoScalingEnabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
autoScalingEnabled,
            (Text
"ParallelismPerKPU" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
parallelismPerKPU,
            (Text
"Parallelism" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
parallelism,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ConfigurationType" Text -> ConfigurationType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ConfigurationType
configurationType)
          ]
      )