{-# 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.KinesisAnalytics.Types.InputParallelism
-- 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.KinesisAnalytics.Types.InputParallelism where

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

-- | Describes the number of in-application streams to create for a given
-- streaming source. For information about parallelism, see
-- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/how-it-works-input.html Configuring Application Input>.
--
-- /See:/ 'newInputParallelism' smart constructor.
data InputParallelism = InputParallelism'
  { -- | Number of in-application streams to create. For more information, see
    -- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/limits.html Limits>.
    InputParallelism -> Maybe Natural
count :: Prelude.Maybe Prelude.Natural
  }
  deriving (InputParallelism -> InputParallelism -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InputParallelism -> InputParallelism -> Bool
$c/= :: InputParallelism -> InputParallelism -> Bool
== :: InputParallelism -> InputParallelism -> Bool
$c== :: InputParallelism -> InputParallelism -> Bool
Prelude.Eq, ReadPrec [InputParallelism]
ReadPrec InputParallelism
Int -> ReadS InputParallelism
ReadS [InputParallelism]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InputParallelism]
$creadListPrec :: ReadPrec [InputParallelism]
readPrec :: ReadPrec InputParallelism
$creadPrec :: ReadPrec InputParallelism
readList :: ReadS [InputParallelism]
$creadList :: ReadS [InputParallelism]
readsPrec :: Int -> ReadS InputParallelism
$creadsPrec :: Int -> ReadS InputParallelism
Prelude.Read, Int -> InputParallelism -> ShowS
[InputParallelism] -> ShowS
InputParallelism -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InputParallelism] -> ShowS
$cshowList :: [InputParallelism] -> ShowS
show :: InputParallelism -> String
$cshow :: InputParallelism -> String
showsPrec :: Int -> InputParallelism -> ShowS
$cshowsPrec :: Int -> InputParallelism -> ShowS
Prelude.Show, forall x. Rep InputParallelism x -> InputParallelism
forall x. InputParallelism -> Rep InputParallelism x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InputParallelism x -> InputParallelism
$cfrom :: forall x. InputParallelism -> Rep InputParallelism x
Prelude.Generic)

-- |
-- Create a value of 'InputParallelism' 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:
--
-- 'count', 'inputParallelism_count' - Number of in-application streams to create. For more information, see
-- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/limits.html Limits>.
newInputParallelism ::
  InputParallelism
newInputParallelism :: InputParallelism
newInputParallelism =
  InputParallelism' {$sel:count:InputParallelism' :: Maybe Natural
count = forall a. Maybe a
Prelude.Nothing}

-- | Number of in-application streams to create. For more information, see
-- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/limits.html Limits>.
inputParallelism_count :: Lens.Lens' InputParallelism (Prelude.Maybe Prelude.Natural)
inputParallelism_count :: Lens' InputParallelism (Maybe Natural)
inputParallelism_count = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputParallelism' {Maybe Natural
count :: Maybe Natural
$sel:count:InputParallelism' :: InputParallelism -> Maybe Natural
count} -> Maybe Natural
count) (\s :: InputParallelism
s@InputParallelism' {} Maybe Natural
a -> InputParallelism
s {$sel:count:InputParallelism' :: Maybe Natural
count = Maybe Natural
a} :: InputParallelism)

instance Data.FromJSON InputParallelism where
  parseJSON :: Value -> Parser InputParallelism
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"InputParallelism"
      ( \Object
x ->
          Maybe Natural -> InputParallelism
InputParallelism' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Count")
      )

instance Prelude.Hashable InputParallelism where
  hashWithSalt :: Int -> InputParallelism -> Int
hashWithSalt Int
_salt InputParallelism' {Maybe Natural
count :: Maybe Natural
$sel:count:InputParallelism' :: InputParallelism -> Maybe Natural
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
count

instance Prelude.NFData InputParallelism where
  rnf :: InputParallelism -> ()
rnf InputParallelism' {Maybe Natural
count :: Maybe Natural
$sel:count:InputParallelism' :: InputParallelism -> Maybe Natural
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
count

instance Data.ToJSON InputParallelism where
  toJSON :: InputParallelism -> Value
toJSON InputParallelism' {Maybe Natural
count :: Maybe Natural
$sel:count:InputParallelism' :: InputParallelism -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"Count" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
count]
      )