{-# 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.Lambda.Types.Concurrency
-- 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.Lambda.Types.Concurrency where

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

-- | /See:/ 'newConcurrency' smart constructor.
data Concurrency = Concurrency'
  { -- | The number of concurrent executions that are reserved for this function.
    -- For more information, see
    -- <https://docs.aws.amazon.com/lambda/latest/dg/configuration-concurrency.html Managing Concurrency>.
    Concurrency -> Maybe Natural
reservedConcurrentExecutions :: Prelude.Maybe Prelude.Natural
  }
  deriving (Concurrency -> Concurrency -> Bool
(Concurrency -> Concurrency -> Bool)
-> (Concurrency -> Concurrency -> Bool) -> Eq Concurrency
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Concurrency -> Concurrency -> Bool
$c/= :: Concurrency -> Concurrency -> Bool
== :: Concurrency -> Concurrency -> Bool
$c== :: Concurrency -> Concurrency -> Bool
Prelude.Eq, ReadPrec [Concurrency]
ReadPrec Concurrency
Int -> ReadS Concurrency
ReadS [Concurrency]
(Int -> ReadS Concurrency)
-> ReadS [Concurrency]
-> ReadPrec Concurrency
-> ReadPrec [Concurrency]
-> Read Concurrency
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Concurrency]
$creadListPrec :: ReadPrec [Concurrency]
readPrec :: ReadPrec Concurrency
$creadPrec :: ReadPrec Concurrency
readList :: ReadS [Concurrency]
$creadList :: ReadS [Concurrency]
readsPrec :: Int -> ReadS Concurrency
$creadsPrec :: Int -> ReadS Concurrency
Prelude.Read, Int -> Concurrency -> ShowS
[Concurrency] -> ShowS
Concurrency -> String
(Int -> Concurrency -> ShowS)
-> (Concurrency -> String)
-> ([Concurrency] -> ShowS)
-> Show Concurrency
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Concurrency] -> ShowS
$cshowList :: [Concurrency] -> ShowS
show :: Concurrency -> String
$cshow :: Concurrency -> String
showsPrec :: Int -> Concurrency -> ShowS
$cshowsPrec :: Int -> Concurrency -> ShowS
Prelude.Show, (forall x. Concurrency -> Rep Concurrency x)
-> (forall x. Rep Concurrency x -> Concurrency)
-> Generic Concurrency
forall x. Rep Concurrency x -> Concurrency
forall x. Concurrency -> Rep Concurrency x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Concurrency x -> Concurrency
$cfrom :: forall x. Concurrency -> Rep Concurrency x
Prelude.Generic)

-- |
-- Create a value of 'Concurrency' 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:
--
-- 'reservedConcurrentExecutions', 'concurrency_reservedConcurrentExecutions' - The number of concurrent executions that are reserved for this function.
-- For more information, see
-- <https://docs.aws.amazon.com/lambda/latest/dg/configuration-concurrency.html Managing Concurrency>.
newConcurrency ::
  Concurrency
newConcurrency :: Concurrency
newConcurrency =
  Concurrency' :: Maybe Natural -> Concurrency
Concurrency'
    { $sel:reservedConcurrentExecutions:Concurrency' :: Maybe Natural
reservedConcurrentExecutions =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The number of concurrent executions that are reserved for this function.
-- For more information, see
-- <https://docs.aws.amazon.com/lambda/latest/dg/configuration-concurrency.html Managing Concurrency>.
concurrency_reservedConcurrentExecutions :: Lens.Lens' Concurrency (Prelude.Maybe Prelude.Natural)
concurrency_reservedConcurrentExecutions :: (Maybe Natural -> f (Maybe Natural))
-> Concurrency -> f Concurrency
concurrency_reservedConcurrentExecutions = (Concurrency -> Maybe Natural)
-> (Concurrency -> Maybe Natural -> Concurrency)
-> Lens Concurrency Concurrency (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Concurrency' {Maybe Natural
reservedConcurrentExecutions :: Maybe Natural
$sel:reservedConcurrentExecutions:Concurrency' :: Concurrency -> Maybe Natural
reservedConcurrentExecutions} -> Maybe Natural
reservedConcurrentExecutions) (\s :: Concurrency
s@Concurrency' {} Maybe Natural
a -> Concurrency
s {$sel:reservedConcurrentExecutions:Concurrency' :: Maybe Natural
reservedConcurrentExecutions = Maybe Natural
a} :: Concurrency)

instance Core.FromJSON Concurrency where
  parseJSON :: Value -> Parser Concurrency
parseJSON =
    String
-> (Object -> Parser Concurrency) -> Value -> Parser Concurrency
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Concurrency"
      ( \Object
x ->
          Maybe Natural -> Concurrency
Concurrency'
            (Maybe Natural -> Concurrency)
-> Parser (Maybe Natural) -> Parser Concurrency
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
"ReservedConcurrentExecutions")
      )

instance Prelude.Hashable Concurrency

instance Prelude.NFData Concurrency