{-# 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.SageMaker.Types.ResourceLimits
-- 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.SageMaker.Types.ResourceLimits where

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

-- | Specifies the maximum number of training jobs and parallel training jobs
-- that a hyperparameter tuning job can launch.
--
-- /See:/ 'newResourceLimits' smart constructor.
data ResourceLimits = ResourceLimits'
  { -- | The maximum number of training jobs that a hyperparameter tuning job can
    -- launch.
    ResourceLimits -> Natural
maxNumberOfTrainingJobs :: Prelude.Natural,
    -- | The maximum number of concurrent training jobs that a hyperparameter
    -- tuning job can launch.
    ResourceLimits -> Natural
maxParallelTrainingJobs :: Prelude.Natural
  }
  deriving (ResourceLimits -> ResourceLimits -> Bool
(ResourceLimits -> ResourceLimits -> Bool)
-> (ResourceLimits -> ResourceLimits -> Bool) -> Eq ResourceLimits
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourceLimits -> ResourceLimits -> Bool
$c/= :: ResourceLimits -> ResourceLimits -> Bool
== :: ResourceLimits -> ResourceLimits -> Bool
$c== :: ResourceLimits -> ResourceLimits -> Bool
Prelude.Eq, ReadPrec [ResourceLimits]
ReadPrec ResourceLimits
Int -> ReadS ResourceLimits
ReadS [ResourceLimits]
(Int -> ReadS ResourceLimits)
-> ReadS [ResourceLimits]
-> ReadPrec ResourceLimits
-> ReadPrec [ResourceLimits]
-> Read ResourceLimits
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourceLimits]
$creadListPrec :: ReadPrec [ResourceLimits]
readPrec :: ReadPrec ResourceLimits
$creadPrec :: ReadPrec ResourceLimits
readList :: ReadS [ResourceLimits]
$creadList :: ReadS [ResourceLimits]
readsPrec :: Int -> ReadS ResourceLimits
$creadsPrec :: Int -> ReadS ResourceLimits
Prelude.Read, Int -> ResourceLimits -> ShowS
[ResourceLimits] -> ShowS
ResourceLimits -> String
(Int -> ResourceLimits -> ShowS)
-> (ResourceLimits -> String)
-> ([ResourceLimits] -> ShowS)
-> Show ResourceLimits
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourceLimits] -> ShowS
$cshowList :: [ResourceLimits] -> ShowS
show :: ResourceLimits -> String
$cshow :: ResourceLimits -> String
showsPrec :: Int -> ResourceLimits -> ShowS
$cshowsPrec :: Int -> ResourceLimits -> ShowS
Prelude.Show, (forall x. ResourceLimits -> Rep ResourceLimits x)
-> (forall x. Rep ResourceLimits x -> ResourceLimits)
-> Generic ResourceLimits
forall x. Rep ResourceLimits x -> ResourceLimits
forall x. ResourceLimits -> Rep ResourceLimits x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResourceLimits x -> ResourceLimits
$cfrom :: forall x. ResourceLimits -> Rep ResourceLimits x
Prelude.Generic)

-- |
-- Create a value of 'ResourceLimits' 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:
--
-- 'maxNumberOfTrainingJobs', 'resourceLimits_maxNumberOfTrainingJobs' - The maximum number of training jobs that a hyperparameter tuning job can
-- launch.
--
-- 'maxParallelTrainingJobs', 'resourceLimits_maxParallelTrainingJobs' - The maximum number of concurrent training jobs that a hyperparameter
-- tuning job can launch.
newResourceLimits ::
  -- | 'maxNumberOfTrainingJobs'
  Prelude.Natural ->
  -- | 'maxParallelTrainingJobs'
  Prelude.Natural ->
  ResourceLimits
newResourceLimits :: Natural -> Natural -> ResourceLimits
newResourceLimits
  Natural
pMaxNumberOfTrainingJobs_
  Natural
pMaxParallelTrainingJobs_ =
    ResourceLimits' :: Natural -> Natural -> ResourceLimits
ResourceLimits'
      { $sel:maxNumberOfTrainingJobs:ResourceLimits' :: Natural
maxNumberOfTrainingJobs =
          Natural
pMaxNumberOfTrainingJobs_,
        $sel:maxParallelTrainingJobs:ResourceLimits' :: Natural
maxParallelTrainingJobs = Natural
pMaxParallelTrainingJobs_
      }

-- | The maximum number of training jobs that a hyperparameter tuning job can
-- launch.
resourceLimits_maxNumberOfTrainingJobs :: Lens.Lens' ResourceLimits Prelude.Natural
resourceLimits_maxNumberOfTrainingJobs :: (Natural -> f Natural) -> ResourceLimits -> f ResourceLimits
resourceLimits_maxNumberOfTrainingJobs = (ResourceLimits -> Natural)
-> (ResourceLimits -> Natural -> ResourceLimits)
-> Lens ResourceLimits ResourceLimits Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceLimits' {Natural
maxNumberOfTrainingJobs :: Natural
$sel:maxNumberOfTrainingJobs:ResourceLimits' :: ResourceLimits -> Natural
maxNumberOfTrainingJobs} -> Natural
maxNumberOfTrainingJobs) (\s :: ResourceLimits
s@ResourceLimits' {} Natural
a -> ResourceLimits
s {$sel:maxNumberOfTrainingJobs:ResourceLimits' :: Natural
maxNumberOfTrainingJobs = Natural
a} :: ResourceLimits)

-- | The maximum number of concurrent training jobs that a hyperparameter
-- tuning job can launch.
resourceLimits_maxParallelTrainingJobs :: Lens.Lens' ResourceLimits Prelude.Natural
resourceLimits_maxParallelTrainingJobs :: (Natural -> f Natural) -> ResourceLimits -> f ResourceLimits
resourceLimits_maxParallelTrainingJobs = (ResourceLimits -> Natural)
-> (ResourceLimits -> Natural -> ResourceLimits)
-> Lens ResourceLimits ResourceLimits Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceLimits' {Natural
maxParallelTrainingJobs :: Natural
$sel:maxParallelTrainingJobs:ResourceLimits' :: ResourceLimits -> Natural
maxParallelTrainingJobs} -> Natural
maxParallelTrainingJobs) (\s :: ResourceLimits
s@ResourceLimits' {} Natural
a -> ResourceLimits
s {$sel:maxParallelTrainingJobs:ResourceLimits' :: Natural
maxParallelTrainingJobs = Natural
a} :: ResourceLimits)

instance Core.FromJSON ResourceLimits where
  parseJSON :: Value -> Parser ResourceLimits
parseJSON =
    String
-> (Object -> Parser ResourceLimits)
-> Value
-> Parser ResourceLimits
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ResourceLimits"
      ( \Object
x ->
          Natural -> Natural -> ResourceLimits
ResourceLimits'
            (Natural -> Natural -> ResourceLimits)
-> Parser Natural -> Parser (Natural -> ResourceLimits)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"MaxNumberOfTrainingJobs")
            Parser (Natural -> ResourceLimits)
-> Parser Natural -> Parser ResourceLimits
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"MaxParallelTrainingJobs")
      )

instance Prelude.Hashable ResourceLimits

instance Prelude.NFData ResourceLimits

instance Core.ToJSON ResourceLimits where
  toJSON :: ResourceLimits -> Value
toJSON ResourceLimits' {Natural
maxParallelTrainingJobs :: Natural
maxNumberOfTrainingJobs :: Natural
$sel:maxParallelTrainingJobs:ResourceLimits' :: ResourceLimits -> Natural
$sel:maxNumberOfTrainingJobs:ResourceLimits' :: ResourceLimits -> Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"MaxNumberOfTrainingJobs"
                  Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
maxNumberOfTrainingJobs
              ),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"MaxParallelTrainingJobs"
                  Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
maxParallelTrainingJobs
              )
          ]
      )