{-# 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.ResourceConfig
-- 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.ResourceConfig 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
import Amazonka.SageMaker.Types.InstanceGroup
import Amazonka.SageMaker.Types.TrainingInstanceType

-- | Describes the resources, including machine learning (ML) compute
-- instances and ML storage volumes, to use for model training.
--
-- /See:/ 'newResourceConfig' smart constructor.
data ResourceConfig = ResourceConfig'
  { -- | The number of ML compute instances to use. For distributed training,
    -- provide a value greater than 1.
    ResourceConfig -> Maybe Natural
instanceCount :: Prelude.Maybe Prelude.Natural,
    -- | The configuration of a heterogeneous cluster in JSON format.
    ResourceConfig -> Maybe [InstanceGroup]
instanceGroups :: Prelude.Maybe [InstanceGroup],
    -- | The ML compute instance type.
    --
    -- SageMaker Training on Amazon Elastic Compute Cloud (EC2) P4de instances
    -- is in preview release starting December 9th, 2022.
    --
    -- <http://aws.amazon.com/ec2/instance-types/p4/ Amazon EC2 P4de instances>
    -- (currently in preview) are powered by 8 NVIDIA A100 GPUs with 80GB
    -- high-performance HBM2e GPU memory, which accelerate the speed of
    -- training ML models that need to be trained on large datasets of
    -- high-resolution data. In this preview release, Amazon SageMaker supports
    -- ML training jobs on P4de instances (@ml.p4de.24xlarge@) to reduce model
    -- training time. The @ml.p4de.24xlarge@ instances are available in the
    -- following Amazon Web Services Regions.
    --
    -- -   US East (N. Virginia) (us-east-1)
    --
    -- -   US West (Oregon) (us-west-2)
    --
    -- To request quota limit increase and start using P4de instances, contact
    -- the SageMaker Training service team through your account team.
    ResourceConfig -> Maybe TrainingInstanceType
instanceType :: Prelude.Maybe TrainingInstanceType,
    -- | The duration of time in seconds to retain configured resources in a warm
    -- pool for subsequent training jobs.
    ResourceConfig -> Maybe Natural
keepAlivePeriodInSeconds :: Prelude.Maybe Prelude.Natural,
    -- | The Amazon Web Services KMS key that SageMaker uses to encrypt data on
    -- the storage volume attached to the ML compute instance(s) that run the
    -- training job.
    --
    -- Certain Nitro-based instances include local storage, dependent on the
    -- instance type. Local storage volumes are encrypted using a hardware
    -- module on the instance. You can\'t request a @VolumeKmsKeyId@ when using
    -- an instance type with local storage.
    --
    -- For a list of instance types that support local instance storage, see
    -- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html#instance-store-volumes Instance Store Volumes>.
    --
    -- For more information about local instance storage encryption, see
    -- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ssd-instance-store.html SSD Instance Store Volumes>.
    --
    -- The @VolumeKmsKeyId@ can be in any of the following formats:
    --
    -- -   \/\/ KMS Key ID
    --
    --     @\"1234abcd-12ab-34cd-56ef-1234567890ab\"@
    --
    -- -   \/\/ Amazon Resource Name (ARN) of a KMS Key
    --
    --     @\"arn:aws:kms:us-west-2:111122223333:key\/1234abcd-12ab-34cd-56ef-1234567890ab\"@
    ResourceConfig -> Maybe Text
volumeKmsKeyId :: Prelude.Maybe Prelude.Text,
    -- | The size of the ML storage volume that you want to provision.
    --
    -- ML storage volumes store model artifacts and incremental states.
    -- Training algorithms might also use the ML storage volume for scratch
    -- space. If you want to store the training data in the ML storage volume,
    -- choose @File@ as the @TrainingInputMode@ in the algorithm specification.
    --
    -- When using an ML instance with
    -- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ssd-instance-store.html#nvme-ssd-volumes NVMe SSD volumes>,
    -- SageMaker doesn\'t provision Amazon EBS General Purpose SSD (gp2)
    -- storage. Available storage is fixed to the NVMe-type instance\'s storage
    -- capacity. SageMaker configures storage paths for training datasets,
    -- checkpoints, model artifacts, and outputs to use the entire capacity of
    -- the instance storage. For example, ML instance families with the
    -- NVMe-type instance storage include @ml.p4d@, @ml.g4dn@, and @ml.g5@.
    --
    -- When using an ML instance with the EBS-only storage option and without
    -- instance storage, you must define the size of EBS volume through
    -- @VolumeSizeInGB@ in the @ResourceConfig@ API. For example, ML instance
    -- families that use EBS volumes include @ml.c5@ and @ml.p2@.
    --
    -- To look up instance types and their instance storage types and volumes,
    -- see
    -- <http://aws.amazon.com/ec2/instance-types/ Amazon EC2 Instance Types>.
    --
    -- To find the default local paths defined by the SageMaker training
    -- platform, see
    -- <https://docs.aws.amazon.com/sagemaker/latest/dg/model-train-storage.html Amazon SageMaker Training Storage Folders for Training Datasets, Checkpoints, Model Artifacts, and Outputs>.
    ResourceConfig -> Natural
volumeSizeInGB :: Prelude.Natural
  }
  deriving (ResourceConfig -> ResourceConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourceConfig -> ResourceConfig -> Bool
$c/= :: ResourceConfig -> ResourceConfig -> Bool
== :: ResourceConfig -> ResourceConfig -> Bool
$c== :: ResourceConfig -> ResourceConfig -> Bool
Prelude.Eq, ReadPrec [ResourceConfig]
ReadPrec ResourceConfig
Int -> ReadS ResourceConfig
ReadS [ResourceConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourceConfig]
$creadListPrec :: ReadPrec [ResourceConfig]
readPrec :: ReadPrec ResourceConfig
$creadPrec :: ReadPrec ResourceConfig
readList :: ReadS [ResourceConfig]
$creadList :: ReadS [ResourceConfig]
readsPrec :: Int -> ReadS ResourceConfig
$creadsPrec :: Int -> ReadS ResourceConfig
Prelude.Read, Int -> ResourceConfig -> ShowS
[ResourceConfig] -> ShowS
ResourceConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourceConfig] -> ShowS
$cshowList :: [ResourceConfig] -> ShowS
show :: ResourceConfig -> String
$cshow :: ResourceConfig -> String
showsPrec :: Int -> ResourceConfig -> ShowS
$cshowsPrec :: Int -> ResourceConfig -> ShowS
Prelude.Show, forall x. Rep ResourceConfig x -> ResourceConfig
forall x. ResourceConfig -> Rep ResourceConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResourceConfig x -> ResourceConfig
$cfrom :: forall x. ResourceConfig -> Rep ResourceConfig x
Prelude.Generic)

-- |
-- Create a value of 'ResourceConfig' 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:
--
-- 'instanceCount', 'resourceConfig_instanceCount' - The number of ML compute instances to use. For distributed training,
-- provide a value greater than 1.
--
-- 'instanceGroups', 'resourceConfig_instanceGroups' - The configuration of a heterogeneous cluster in JSON format.
--
-- 'instanceType', 'resourceConfig_instanceType' - The ML compute instance type.
--
-- SageMaker Training on Amazon Elastic Compute Cloud (EC2) P4de instances
-- is in preview release starting December 9th, 2022.
--
-- <http://aws.amazon.com/ec2/instance-types/p4/ Amazon EC2 P4de instances>
-- (currently in preview) are powered by 8 NVIDIA A100 GPUs with 80GB
-- high-performance HBM2e GPU memory, which accelerate the speed of
-- training ML models that need to be trained on large datasets of
-- high-resolution data. In this preview release, Amazon SageMaker supports
-- ML training jobs on P4de instances (@ml.p4de.24xlarge@) to reduce model
-- training time. The @ml.p4de.24xlarge@ instances are available in the
-- following Amazon Web Services Regions.
--
-- -   US East (N. Virginia) (us-east-1)
--
-- -   US West (Oregon) (us-west-2)
--
-- To request quota limit increase and start using P4de instances, contact
-- the SageMaker Training service team through your account team.
--
-- 'keepAlivePeriodInSeconds', 'resourceConfig_keepAlivePeriodInSeconds' - The duration of time in seconds to retain configured resources in a warm
-- pool for subsequent training jobs.
--
-- 'volumeKmsKeyId', 'resourceConfig_volumeKmsKeyId' - The Amazon Web Services KMS key that SageMaker uses to encrypt data on
-- the storage volume attached to the ML compute instance(s) that run the
-- training job.
--
-- Certain Nitro-based instances include local storage, dependent on the
-- instance type. Local storage volumes are encrypted using a hardware
-- module on the instance. You can\'t request a @VolumeKmsKeyId@ when using
-- an instance type with local storage.
--
-- For a list of instance types that support local instance storage, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html#instance-store-volumes Instance Store Volumes>.
--
-- For more information about local instance storage encryption, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ssd-instance-store.html SSD Instance Store Volumes>.
--
-- The @VolumeKmsKeyId@ can be in any of the following formats:
--
-- -   \/\/ KMS Key ID
--
--     @\"1234abcd-12ab-34cd-56ef-1234567890ab\"@
--
-- -   \/\/ Amazon Resource Name (ARN) of a KMS Key
--
--     @\"arn:aws:kms:us-west-2:111122223333:key\/1234abcd-12ab-34cd-56ef-1234567890ab\"@
--
-- 'volumeSizeInGB', 'resourceConfig_volumeSizeInGB' - The size of the ML storage volume that you want to provision.
--
-- ML storage volumes store model artifacts and incremental states.
-- Training algorithms might also use the ML storage volume for scratch
-- space. If you want to store the training data in the ML storage volume,
-- choose @File@ as the @TrainingInputMode@ in the algorithm specification.
--
-- When using an ML instance with
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ssd-instance-store.html#nvme-ssd-volumes NVMe SSD volumes>,
-- SageMaker doesn\'t provision Amazon EBS General Purpose SSD (gp2)
-- storage. Available storage is fixed to the NVMe-type instance\'s storage
-- capacity. SageMaker configures storage paths for training datasets,
-- checkpoints, model artifacts, and outputs to use the entire capacity of
-- the instance storage. For example, ML instance families with the
-- NVMe-type instance storage include @ml.p4d@, @ml.g4dn@, and @ml.g5@.
--
-- When using an ML instance with the EBS-only storage option and without
-- instance storage, you must define the size of EBS volume through
-- @VolumeSizeInGB@ in the @ResourceConfig@ API. For example, ML instance
-- families that use EBS volumes include @ml.c5@ and @ml.p2@.
--
-- To look up instance types and their instance storage types and volumes,
-- see
-- <http://aws.amazon.com/ec2/instance-types/ Amazon EC2 Instance Types>.
--
-- To find the default local paths defined by the SageMaker training
-- platform, see
-- <https://docs.aws.amazon.com/sagemaker/latest/dg/model-train-storage.html Amazon SageMaker Training Storage Folders for Training Datasets, Checkpoints, Model Artifacts, and Outputs>.
newResourceConfig ::
  -- | 'volumeSizeInGB'
  Prelude.Natural ->
  ResourceConfig
newResourceConfig :: Natural -> ResourceConfig
newResourceConfig Natural
pVolumeSizeInGB_ =
  ResourceConfig'
    { $sel:instanceCount:ResourceConfig' :: Maybe Natural
instanceCount = forall a. Maybe a
Prelude.Nothing,
      $sel:instanceGroups:ResourceConfig' :: Maybe [InstanceGroup]
instanceGroups = forall a. Maybe a
Prelude.Nothing,
      $sel:instanceType:ResourceConfig' :: Maybe TrainingInstanceType
instanceType = forall a. Maybe a
Prelude.Nothing,
      $sel:keepAlivePeriodInSeconds:ResourceConfig' :: Maybe Natural
keepAlivePeriodInSeconds = forall a. Maybe a
Prelude.Nothing,
      $sel:volumeKmsKeyId:ResourceConfig' :: Maybe Text
volumeKmsKeyId = forall a. Maybe a
Prelude.Nothing,
      $sel:volumeSizeInGB:ResourceConfig' :: Natural
volumeSizeInGB = Natural
pVolumeSizeInGB_
    }

-- | The number of ML compute instances to use. For distributed training,
-- provide a value greater than 1.
resourceConfig_instanceCount :: Lens.Lens' ResourceConfig (Prelude.Maybe Prelude.Natural)
resourceConfig_instanceCount :: Lens' ResourceConfig (Maybe Natural)
resourceConfig_instanceCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceConfig' {Maybe Natural
instanceCount :: Maybe Natural
$sel:instanceCount:ResourceConfig' :: ResourceConfig -> Maybe Natural
instanceCount} -> Maybe Natural
instanceCount) (\s :: ResourceConfig
s@ResourceConfig' {} Maybe Natural
a -> ResourceConfig
s {$sel:instanceCount:ResourceConfig' :: Maybe Natural
instanceCount = Maybe Natural
a} :: ResourceConfig)

-- | The configuration of a heterogeneous cluster in JSON format.
resourceConfig_instanceGroups :: Lens.Lens' ResourceConfig (Prelude.Maybe [InstanceGroup])
resourceConfig_instanceGroups :: Lens' ResourceConfig (Maybe [InstanceGroup])
resourceConfig_instanceGroups = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceConfig' {Maybe [InstanceGroup]
instanceGroups :: Maybe [InstanceGroup]
$sel:instanceGroups:ResourceConfig' :: ResourceConfig -> Maybe [InstanceGroup]
instanceGroups} -> Maybe [InstanceGroup]
instanceGroups) (\s :: ResourceConfig
s@ResourceConfig' {} Maybe [InstanceGroup]
a -> ResourceConfig
s {$sel:instanceGroups:ResourceConfig' :: Maybe [InstanceGroup]
instanceGroups = Maybe [InstanceGroup]
a} :: ResourceConfig) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ML compute instance type.
--
-- SageMaker Training on Amazon Elastic Compute Cloud (EC2) P4de instances
-- is in preview release starting December 9th, 2022.
--
-- <http://aws.amazon.com/ec2/instance-types/p4/ Amazon EC2 P4de instances>
-- (currently in preview) are powered by 8 NVIDIA A100 GPUs with 80GB
-- high-performance HBM2e GPU memory, which accelerate the speed of
-- training ML models that need to be trained on large datasets of
-- high-resolution data. In this preview release, Amazon SageMaker supports
-- ML training jobs on P4de instances (@ml.p4de.24xlarge@) to reduce model
-- training time. The @ml.p4de.24xlarge@ instances are available in the
-- following Amazon Web Services Regions.
--
-- -   US East (N. Virginia) (us-east-1)
--
-- -   US West (Oregon) (us-west-2)
--
-- To request quota limit increase and start using P4de instances, contact
-- the SageMaker Training service team through your account team.
resourceConfig_instanceType :: Lens.Lens' ResourceConfig (Prelude.Maybe TrainingInstanceType)
resourceConfig_instanceType :: Lens' ResourceConfig (Maybe TrainingInstanceType)
resourceConfig_instanceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceConfig' {Maybe TrainingInstanceType
instanceType :: Maybe TrainingInstanceType
$sel:instanceType:ResourceConfig' :: ResourceConfig -> Maybe TrainingInstanceType
instanceType} -> Maybe TrainingInstanceType
instanceType) (\s :: ResourceConfig
s@ResourceConfig' {} Maybe TrainingInstanceType
a -> ResourceConfig
s {$sel:instanceType:ResourceConfig' :: Maybe TrainingInstanceType
instanceType = Maybe TrainingInstanceType
a} :: ResourceConfig)

-- | The duration of time in seconds to retain configured resources in a warm
-- pool for subsequent training jobs.
resourceConfig_keepAlivePeriodInSeconds :: Lens.Lens' ResourceConfig (Prelude.Maybe Prelude.Natural)
resourceConfig_keepAlivePeriodInSeconds :: Lens' ResourceConfig (Maybe Natural)
resourceConfig_keepAlivePeriodInSeconds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceConfig' {Maybe Natural
keepAlivePeriodInSeconds :: Maybe Natural
$sel:keepAlivePeriodInSeconds:ResourceConfig' :: ResourceConfig -> Maybe Natural
keepAlivePeriodInSeconds} -> Maybe Natural
keepAlivePeriodInSeconds) (\s :: ResourceConfig
s@ResourceConfig' {} Maybe Natural
a -> ResourceConfig
s {$sel:keepAlivePeriodInSeconds:ResourceConfig' :: Maybe Natural
keepAlivePeriodInSeconds = Maybe Natural
a} :: ResourceConfig)

-- | The Amazon Web Services KMS key that SageMaker uses to encrypt data on
-- the storage volume attached to the ML compute instance(s) that run the
-- training job.
--
-- Certain Nitro-based instances include local storage, dependent on the
-- instance type. Local storage volumes are encrypted using a hardware
-- module on the instance. You can\'t request a @VolumeKmsKeyId@ when using
-- an instance type with local storage.
--
-- For a list of instance types that support local instance storage, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html#instance-store-volumes Instance Store Volumes>.
--
-- For more information about local instance storage encryption, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ssd-instance-store.html SSD Instance Store Volumes>.
--
-- The @VolumeKmsKeyId@ can be in any of the following formats:
--
-- -   \/\/ KMS Key ID
--
--     @\"1234abcd-12ab-34cd-56ef-1234567890ab\"@
--
-- -   \/\/ Amazon Resource Name (ARN) of a KMS Key
--
--     @\"arn:aws:kms:us-west-2:111122223333:key\/1234abcd-12ab-34cd-56ef-1234567890ab\"@
resourceConfig_volumeKmsKeyId :: Lens.Lens' ResourceConfig (Prelude.Maybe Prelude.Text)
resourceConfig_volumeKmsKeyId :: Lens' ResourceConfig (Maybe Text)
resourceConfig_volumeKmsKeyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceConfig' {Maybe Text
volumeKmsKeyId :: Maybe Text
$sel:volumeKmsKeyId:ResourceConfig' :: ResourceConfig -> Maybe Text
volumeKmsKeyId} -> Maybe Text
volumeKmsKeyId) (\s :: ResourceConfig
s@ResourceConfig' {} Maybe Text
a -> ResourceConfig
s {$sel:volumeKmsKeyId:ResourceConfig' :: Maybe Text
volumeKmsKeyId = Maybe Text
a} :: ResourceConfig)

-- | The size of the ML storage volume that you want to provision.
--
-- ML storage volumes store model artifacts and incremental states.
-- Training algorithms might also use the ML storage volume for scratch
-- space. If you want to store the training data in the ML storage volume,
-- choose @File@ as the @TrainingInputMode@ in the algorithm specification.
--
-- When using an ML instance with
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ssd-instance-store.html#nvme-ssd-volumes NVMe SSD volumes>,
-- SageMaker doesn\'t provision Amazon EBS General Purpose SSD (gp2)
-- storage. Available storage is fixed to the NVMe-type instance\'s storage
-- capacity. SageMaker configures storage paths for training datasets,
-- checkpoints, model artifacts, and outputs to use the entire capacity of
-- the instance storage. For example, ML instance families with the
-- NVMe-type instance storage include @ml.p4d@, @ml.g4dn@, and @ml.g5@.
--
-- When using an ML instance with the EBS-only storage option and without
-- instance storage, you must define the size of EBS volume through
-- @VolumeSizeInGB@ in the @ResourceConfig@ API. For example, ML instance
-- families that use EBS volumes include @ml.c5@ and @ml.p2@.
--
-- To look up instance types and their instance storage types and volumes,
-- see
-- <http://aws.amazon.com/ec2/instance-types/ Amazon EC2 Instance Types>.
--
-- To find the default local paths defined by the SageMaker training
-- platform, see
-- <https://docs.aws.amazon.com/sagemaker/latest/dg/model-train-storage.html Amazon SageMaker Training Storage Folders for Training Datasets, Checkpoints, Model Artifacts, and Outputs>.
resourceConfig_volumeSizeInGB :: Lens.Lens' ResourceConfig Prelude.Natural
resourceConfig_volumeSizeInGB :: Lens' ResourceConfig Natural
resourceConfig_volumeSizeInGB = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceConfig' {Natural
volumeSizeInGB :: Natural
$sel:volumeSizeInGB:ResourceConfig' :: ResourceConfig -> Natural
volumeSizeInGB} -> Natural
volumeSizeInGB) (\s :: ResourceConfig
s@ResourceConfig' {} Natural
a -> ResourceConfig
s {$sel:volumeSizeInGB:ResourceConfig' :: Natural
volumeSizeInGB = Natural
a} :: ResourceConfig)

instance Data.FromJSON ResourceConfig where
  parseJSON :: Value -> Parser ResourceConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ResourceConfig"
      ( \Object
x ->
          Maybe Natural
-> Maybe [InstanceGroup]
-> Maybe TrainingInstanceType
-> Maybe Natural
-> Maybe Text
-> Natural
-> ResourceConfig
ResourceConfig'
            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
"InstanceCount")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"InstanceGroups" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"InstanceType")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"KeepAlivePeriodInSeconds")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"VolumeKmsKeyId")
            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
"VolumeSizeInGB")
      )

instance Prelude.Hashable ResourceConfig where
  hashWithSalt :: Int -> ResourceConfig -> Int
hashWithSalt Int
_salt ResourceConfig' {Natural
Maybe Natural
Maybe [InstanceGroup]
Maybe Text
Maybe TrainingInstanceType
volumeSizeInGB :: Natural
volumeKmsKeyId :: Maybe Text
keepAlivePeriodInSeconds :: Maybe Natural
instanceType :: Maybe TrainingInstanceType
instanceGroups :: Maybe [InstanceGroup]
instanceCount :: Maybe Natural
$sel:volumeSizeInGB:ResourceConfig' :: ResourceConfig -> Natural
$sel:volumeKmsKeyId:ResourceConfig' :: ResourceConfig -> Maybe Text
$sel:keepAlivePeriodInSeconds:ResourceConfig' :: ResourceConfig -> Maybe Natural
$sel:instanceType:ResourceConfig' :: ResourceConfig -> Maybe TrainingInstanceType
$sel:instanceGroups:ResourceConfig' :: ResourceConfig -> Maybe [InstanceGroup]
$sel:instanceCount:ResourceConfig' :: ResourceConfig -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
instanceCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [InstanceGroup]
instanceGroups
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TrainingInstanceType
instanceType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
keepAlivePeriodInSeconds
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
volumeKmsKeyId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
volumeSizeInGB

instance Prelude.NFData ResourceConfig where
  rnf :: ResourceConfig -> ()
rnf ResourceConfig' {Natural
Maybe Natural
Maybe [InstanceGroup]
Maybe Text
Maybe TrainingInstanceType
volumeSizeInGB :: Natural
volumeKmsKeyId :: Maybe Text
keepAlivePeriodInSeconds :: Maybe Natural
instanceType :: Maybe TrainingInstanceType
instanceGroups :: Maybe [InstanceGroup]
instanceCount :: Maybe Natural
$sel:volumeSizeInGB:ResourceConfig' :: ResourceConfig -> Natural
$sel:volumeKmsKeyId:ResourceConfig' :: ResourceConfig -> Maybe Text
$sel:keepAlivePeriodInSeconds:ResourceConfig' :: ResourceConfig -> Maybe Natural
$sel:instanceType:ResourceConfig' :: ResourceConfig -> Maybe TrainingInstanceType
$sel:instanceGroups:ResourceConfig' :: ResourceConfig -> Maybe [InstanceGroup]
$sel:instanceCount:ResourceConfig' :: ResourceConfig -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
instanceCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [InstanceGroup]
instanceGroups
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TrainingInstanceType
instanceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
keepAlivePeriodInSeconds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
volumeKmsKeyId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
volumeSizeInGB

instance Data.ToJSON ResourceConfig where
  toJSON :: ResourceConfig -> Value
toJSON ResourceConfig' {Natural
Maybe Natural
Maybe [InstanceGroup]
Maybe Text
Maybe TrainingInstanceType
volumeSizeInGB :: Natural
volumeKmsKeyId :: Maybe Text
keepAlivePeriodInSeconds :: Maybe Natural
instanceType :: Maybe TrainingInstanceType
instanceGroups :: Maybe [InstanceGroup]
instanceCount :: Maybe Natural
$sel:volumeSizeInGB:ResourceConfig' :: ResourceConfig -> Natural
$sel:volumeKmsKeyId:ResourceConfig' :: ResourceConfig -> Maybe Text
$sel:keepAlivePeriodInSeconds:ResourceConfig' :: ResourceConfig -> Maybe Natural
$sel:instanceType:ResourceConfig' :: ResourceConfig -> Maybe TrainingInstanceType
$sel:instanceGroups:ResourceConfig' :: ResourceConfig -> Maybe [InstanceGroup]
$sel:instanceCount:ResourceConfig' :: ResourceConfig -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"InstanceCount" 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
instanceCount,
            (Key
"InstanceGroups" 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 [InstanceGroup]
instanceGroups,
            (Key
"InstanceType" 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 TrainingInstanceType
instanceType,
            (Key
"KeepAlivePeriodInSeconds" 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
keepAlivePeriodInSeconds,
            (Key
"VolumeKmsKeyId" 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 Text
volumeKmsKeyId,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"VolumeSizeInGB" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
volumeSizeInGB)
          ]
      )