{-# 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.Glue.Types.ExecutionProperty
-- 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.Glue.Types.ExecutionProperty where

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

-- | An execution property of a job.
--
-- /See:/ 'newExecutionProperty' smart constructor.
data ExecutionProperty = ExecutionProperty'
  { -- | The maximum number of concurrent runs allowed for the job. The default
    -- is 1. An error is returned when this threshold is reached. The maximum
    -- value you can specify is controlled by a service limit.
    ExecutionProperty -> Maybe Int
maxConcurrentRuns :: Prelude.Maybe Prelude.Int
  }
  deriving (ExecutionProperty -> ExecutionProperty -> Bool
(ExecutionProperty -> ExecutionProperty -> Bool)
-> (ExecutionProperty -> ExecutionProperty -> Bool)
-> Eq ExecutionProperty
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExecutionProperty -> ExecutionProperty -> Bool
$c/= :: ExecutionProperty -> ExecutionProperty -> Bool
== :: ExecutionProperty -> ExecutionProperty -> Bool
$c== :: ExecutionProperty -> ExecutionProperty -> Bool
Prelude.Eq, ReadPrec [ExecutionProperty]
ReadPrec ExecutionProperty
Int -> ReadS ExecutionProperty
ReadS [ExecutionProperty]
(Int -> ReadS ExecutionProperty)
-> ReadS [ExecutionProperty]
-> ReadPrec ExecutionProperty
-> ReadPrec [ExecutionProperty]
-> Read ExecutionProperty
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExecutionProperty]
$creadListPrec :: ReadPrec [ExecutionProperty]
readPrec :: ReadPrec ExecutionProperty
$creadPrec :: ReadPrec ExecutionProperty
readList :: ReadS [ExecutionProperty]
$creadList :: ReadS [ExecutionProperty]
readsPrec :: Int -> ReadS ExecutionProperty
$creadsPrec :: Int -> ReadS ExecutionProperty
Prelude.Read, Int -> ExecutionProperty -> ShowS
[ExecutionProperty] -> ShowS
ExecutionProperty -> String
(Int -> ExecutionProperty -> ShowS)
-> (ExecutionProperty -> String)
-> ([ExecutionProperty] -> ShowS)
-> Show ExecutionProperty
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExecutionProperty] -> ShowS
$cshowList :: [ExecutionProperty] -> ShowS
show :: ExecutionProperty -> String
$cshow :: ExecutionProperty -> String
showsPrec :: Int -> ExecutionProperty -> ShowS
$cshowsPrec :: Int -> ExecutionProperty -> ShowS
Prelude.Show, (forall x. ExecutionProperty -> Rep ExecutionProperty x)
-> (forall x. Rep ExecutionProperty x -> ExecutionProperty)
-> Generic ExecutionProperty
forall x. Rep ExecutionProperty x -> ExecutionProperty
forall x. ExecutionProperty -> Rep ExecutionProperty x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExecutionProperty x -> ExecutionProperty
$cfrom :: forall x. ExecutionProperty -> Rep ExecutionProperty x
Prelude.Generic)

-- |
-- Create a value of 'ExecutionProperty' 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:
--
-- 'maxConcurrentRuns', 'executionProperty_maxConcurrentRuns' - The maximum number of concurrent runs allowed for the job. The default
-- is 1. An error is returned when this threshold is reached. The maximum
-- value you can specify is controlled by a service limit.
newExecutionProperty ::
  ExecutionProperty
newExecutionProperty :: ExecutionProperty
newExecutionProperty =
  ExecutionProperty' :: Maybe Int -> ExecutionProperty
ExecutionProperty'
    { $sel:maxConcurrentRuns:ExecutionProperty' :: Maybe Int
maxConcurrentRuns =
        Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of concurrent runs allowed for the job. The default
-- is 1. An error is returned when this threshold is reached. The maximum
-- value you can specify is controlled by a service limit.
executionProperty_maxConcurrentRuns :: Lens.Lens' ExecutionProperty (Prelude.Maybe Prelude.Int)
executionProperty_maxConcurrentRuns :: (Maybe Int -> f (Maybe Int))
-> ExecutionProperty -> f ExecutionProperty
executionProperty_maxConcurrentRuns = (ExecutionProperty -> Maybe Int)
-> (ExecutionProperty -> Maybe Int -> ExecutionProperty)
-> Lens ExecutionProperty ExecutionProperty (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecutionProperty' {Maybe Int
maxConcurrentRuns :: Maybe Int
$sel:maxConcurrentRuns:ExecutionProperty' :: ExecutionProperty -> Maybe Int
maxConcurrentRuns} -> Maybe Int
maxConcurrentRuns) (\s :: ExecutionProperty
s@ExecutionProperty' {} Maybe Int
a -> ExecutionProperty
s {$sel:maxConcurrentRuns:ExecutionProperty' :: Maybe Int
maxConcurrentRuns = Maybe Int
a} :: ExecutionProperty)

instance Core.FromJSON ExecutionProperty where
  parseJSON :: Value -> Parser ExecutionProperty
parseJSON =
    String
-> (Object -> Parser ExecutionProperty)
-> Value
-> Parser ExecutionProperty
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ExecutionProperty"
      ( \Object
x ->
          Maybe Int -> ExecutionProperty
ExecutionProperty'
            (Maybe Int -> ExecutionProperty)
-> Parser (Maybe Int) -> Parser ExecutionProperty
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MaxConcurrentRuns")
      )

instance Prelude.Hashable ExecutionProperty

instance Prelude.NFData ExecutionProperty

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