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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | For a SQL-based Kinesis Data Analytics application, describes the number
-- of in-application streams to create for a given streaming source.
--
-- /See:/ 'newInputParallelism' smart constructor.
data InputParallelism = InputParallelism'
  { -- | The number of in-application streams to create.
    InputParallelism -> Maybe Natural
count :: Prelude.Maybe Prelude.Natural
  }
  deriving (InputParallelism -> InputParallelism -> Bool
(InputParallelism -> InputParallelism -> Bool)
-> (InputParallelism -> InputParallelism -> Bool)
-> Eq InputParallelism
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]
(Int -> ReadS InputParallelism)
-> ReadS [InputParallelism]
-> ReadPrec InputParallelism
-> ReadPrec [InputParallelism]
-> Read 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
(Int -> InputParallelism -> ShowS)
-> (InputParallelism -> String)
-> ([InputParallelism] -> ShowS)
-> Show InputParallelism
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. InputParallelism -> Rep InputParallelism x)
-> (forall x. Rep InputParallelism x -> InputParallelism)
-> Generic InputParallelism
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' - The number of in-application streams to create.
newInputParallelism ::
  InputParallelism
newInputParallelism :: InputParallelism
newInputParallelism =
  InputParallelism' :: Maybe Natural -> InputParallelism
InputParallelism' {$sel:count:InputParallelism' :: Maybe Natural
count = Maybe Natural
forall a. Maybe a
Prelude.Nothing}

-- | The number of in-application streams to create.
inputParallelism_count :: Lens.Lens' InputParallelism (Prelude.Maybe Prelude.Natural)
inputParallelism_count :: (Maybe Natural -> f (Maybe Natural))
-> InputParallelism -> f InputParallelism
inputParallelism_count = (InputParallelism -> Maybe Natural)
-> (InputParallelism -> Maybe Natural -> InputParallelism)
-> Lens
     InputParallelism InputParallelism (Maybe Natural) (Maybe Natural)
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 Core.FromJSON InputParallelism where
  parseJSON :: Value -> Parser InputParallelism
parseJSON =
    String
-> (Object -> Parser InputParallelism)
-> Value
-> Parser InputParallelism
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"InputParallelism"
      ( \Object
x ->
          Maybe Natural -> InputParallelism
InputParallelism' (Maybe Natural -> InputParallelism)
-> Parser (Maybe Natural) -> Parser InputParallelism
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Count")
      )

instance Prelude.Hashable InputParallelism

instance Prelude.NFData InputParallelism

instance Core.ToJSON InputParallelism where
  toJSON :: InputParallelism -> Value
toJSON InputParallelism' {Maybe Natural
count :: Maybe Natural
$sel:count:InputParallelism' :: InputParallelism -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"Count" 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
count]
      )