{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SageMaker.Types.ResourceLimits 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

-- | 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 -> Maybe Natural
maxNumberOfTrainingJobs :: Prelude.Maybe 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
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]
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
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. 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 ::
  -- | 'maxParallelTrainingJobs'
  Prelude.Natural ->
  ResourceLimits
newResourceLimits :: Natural -> ResourceLimits
newResourceLimits Natural
pMaxParallelTrainingJobs_ =
  ResourceLimits'
    { $sel:maxNumberOfTrainingJobs:ResourceLimits' :: Maybe Natural
maxNumberOfTrainingJobs =
        forall a. Maybe a
Prelude.Nothing,
      $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.Maybe Prelude.Natural)
resourceLimits_maxNumberOfTrainingJobs :: Lens' ResourceLimits (Maybe Natural)
resourceLimits_maxNumberOfTrainingJobs = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceLimits' {Maybe Natural
maxNumberOfTrainingJobs :: Maybe Natural
$sel:maxNumberOfTrainingJobs:ResourceLimits' :: ResourceLimits -> Maybe Natural
maxNumberOfTrainingJobs} -> Maybe Natural
maxNumberOfTrainingJobs) (\s :: ResourceLimits
s@ResourceLimits' {} Maybe Natural
a -> ResourceLimits
s {$sel:maxNumberOfTrainingJobs:ResourceLimits' :: Maybe Natural
maxNumberOfTrainingJobs = Maybe 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 :: Lens' ResourceLimits Natural
resourceLimits_maxParallelTrainingJobs = 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 Data.FromJSON ResourceLimits where
  parseJSON :: Value -> Parser ResourceLimits
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ResourceLimits"
      ( \Object
x ->
          Maybe Natural -> Natural -> ResourceLimits
ResourceLimits'
            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
"MaxNumberOfTrainingJobs")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"MaxParallelTrainingJobs")
      )

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

instance Prelude.NFData ResourceLimits where
  rnf :: ResourceLimits -> ()
rnf ResourceLimits' {Natural
Maybe Natural
maxParallelTrainingJobs :: Natural
maxNumberOfTrainingJobs :: Maybe Natural
$sel:maxParallelTrainingJobs:ResourceLimits' :: ResourceLimits -> Natural
$sel:maxNumberOfTrainingJobs:ResourceLimits' :: ResourceLimits -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxNumberOfTrainingJobs
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
maxParallelTrainingJobs

instance Data.ToJSON ResourceLimits where
  toJSON :: ResourceLimits -> Value
toJSON ResourceLimits' {Natural
Maybe Natural
maxParallelTrainingJobs :: Natural
maxNumberOfTrainingJobs :: Maybe Natural
$sel:maxParallelTrainingJobs:ResourceLimits' :: ResourceLimits -> Natural
$sel:maxNumberOfTrainingJobs:ResourceLimits' :: ResourceLimits -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"MaxNumberOfTrainingJobs" 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
maxNumberOfTrainingJobs,
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"MaxParallelTrainingJobs"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
maxParallelTrainingJobs
              )
          ]
      )