{-# 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.ProcessingClusterConfig
-- 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.ProcessingClusterConfig 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.ProcessingInstanceType

-- | Configuration for the cluster used to run a processing job.
--
-- /See:/ 'newProcessingClusterConfig' smart constructor.
data ProcessingClusterConfig = ProcessingClusterConfig'
  { -- | The Amazon Web Services Key Management Service (Amazon Web Services KMS)
    -- key that Amazon SageMaker uses to encrypt data on the storage volume
    -- attached to the ML compute instance(s) that run the processing 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>.
    ProcessingClusterConfig -> Maybe Text
volumeKmsKeyId :: Prelude.Maybe Prelude.Text,
    -- | The number of ML compute instances to use in the processing job. For
    -- distributed processing jobs, specify a value greater than 1. The default
    -- value is 1.
    ProcessingClusterConfig -> Natural
instanceCount :: Prelude.Natural,
    -- | The ML compute instance type for the processing job.
    ProcessingClusterConfig -> ProcessingInstanceType
instanceType :: ProcessingInstanceType,
    -- | The size of the ML storage volume in gigabytes that you want to
    -- provision. You must specify sufficient ML storage for your scenario.
    --
    -- Certain Nitro-based instances include local storage with a fixed total
    -- size, dependent on the instance type. When using these instances for
    -- processing, Amazon SageMaker mounts the local instance storage instead
    -- of Amazon EBS gp2 storage. You can\'t request a @VolumeSizeInGB@ greater
    -- than the total size of the local instance storage.
    --
    -- For a list of instance types that support local instance storage,
    -- including the total size per instance type, see
    -- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html#instance-store-volumes Instance Store Volumes>.
    ProcessingClusterConfig -> Natural
volumeSizeInGB :: Prelude.Natural
  }
  deriving (ProcessingClusterConfig -> ProcessingClusterConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProcessingClusterConfig -> ProcessingClusterConfig -> Bool
$c/= :: ProcessingClusterConfig -> ProcessingClusterConfig -> Bool
== :: ProcessingClusterConfig -> ProcessingClusterConfig -> Bool
$c== :: ProcessingClusterConfig -> ProcessingClusterConfig -> Bool
Prelude.Eq, ReadPrec [ProcessingClusterConfig]
ReadPrec ProcessingClusterConfig
Int -> ReadS ProcessingClusterConfig
ReadS [ProcessingClusterConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ProcessingClusterConfig]
$creadListPrec :: ReadPrec [ProcessingClusterConfig]
readPrec :: ReadPrec ProcessingClusterConfig
$creadPrec :: ReadPrec ProcessingClusterConfig
readList :: ReadS [ProcessingClusterConfig]
$creadList :: ReadS [ProcessingClusterConfig]
readsPrec :: Int -> ReadS ProcessingClusterConfig
$creadsPrec :: Int -> ReadS ProcessingClusterConfig
Prelude.Read, Int -> ProcessingClusterConfig -> ShowS
[ProcessingClusterConfig] -> ShowS
ProcessingClusterConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProcessingClusterConfig] -> ShowS
$cshowList :: [ProcessingClusterConfig] -> ShowS
show :: ProcessingClusterConfig -> String
$cshow :: ProcessingClusterConfig -> String
showsPrec :: Int -> ProcessingClusterConfig -> ShowS
$cshowsPrec :: Int -> ProcessingClusterConfig -> ShowS
Prelude.Show, forall x. Rep ProcessingClusterConfig x -> ProcessingClusterConfig
forall x. ProcessingClusterConfig -> Rep ProcessingClusterConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ProcessingClusterConfig x -> ProcessingClusterConfig
$cfrom :: forall x. ProcessingClusterConfig -> Rep ProcessingClusterConfig x
Prelude.Generic)

-- |
-- Create a value of 'ProcessingClusterConfig' 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:
--
-- 'volumeKmsKeyId', 'processingClusterConfig_volumeKmsKeyId' - The Amazon Web Services Key Management Service (Amazon Web Services KMS)
-- key that Amazon SageMaker uses to encrypt data on the storage volume
-- attached to the ML compute instance(s) that run the processing 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>.
--
-- 'instanceCount', 'processingClusterConfig_instanceCount' - The number of ML compute instances to use in the processing job. For
-- distributed processing jobs, specify a value greater than 1. The default
-- value is 1.
--
-- 'instanceType', 'processingClusterConfig_instanceType' - The ML compute instance type for the processing job.
--
-- 'volumeSizeInGB', 'processingClusterConfig_volumeSizeInGB' - The size of the ML storage volume in gigabytes that you want to
-- provision. You must specify sufficient ML storage for your scenario.
--
-- Certain Nitro-based instances include local storage with a fixed total
-- size, dependent on the instance type. When using these instances for
-- processing, Amazon SageMaker mounts the local instance storage instead
-- of Amazon EBS gp2 storage. You can\'t request a @VolumeSizeInGB@ greater
-- than the total size of the local instance storage.
--
-- For a list of instance types that support local instance storage,
-- including the total size per instance type, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html#instance-store-volumes Instance Store Volumes>.
newProcessingClusterConfig ::
  -- | 'instanceCount'
  Prelude.Natural ->
  -- | 'instanceType'
  ProcessingInstanceType ->
  -- | 'volumeSizeInGB'
  Prelude.Natural ->
  ProcessingClusterConfig
newProcessingClusterConfig :: Natural
-> ProcessingInstanceType -> Natural -> ProcessingClusterConfig
newProcessingClusterConfig
  Natural
pInstanceCount_
  ProcessingInstanceType
pInstanceType_
  Natural
pVolumeSizeInGB_ =
    ProcessingClusterConfig'
      { $sel:volumeKmsKeyId:ProcessingClusterConfig' :: Maybe Text
volumeKmsKeyId =
          forall a. Maybe a
Prelude.Nothing,
        $sel:instanceCount:ProcessingClusterConfig' :: Natural
instanceCount = Natural
pInstanceCount_,
        $sel:instanceType:ProcessingClusterConfig' :: ProcessingInstanceType
instanceType = ProcessingInstanceType
pInstanceType_,
        $sel:volumeSizeInGB:ProcessingClusterConfig' :: Natural
volumeSizeInGB = Natural
pVolumeSizeInGB_
      }

-- | The Amazon Web Services Key Management Service (Amazon Web Services KMS)
-- key that Amazon SageMaker uses to encrypt data on the storage volume
-- attached to the ML compute instance(s) that run the processing 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>.
processingClusterConfig_volumeKmsKeyId :: Lens.Lens' ProcessingClusterConfig (Prelude.Maybe Prelude.Text)
processingClusterConfig_volumeKmsKeyId :: Lens' ProcessingClusterConfig (Maybe Text)
processingClusterConfig_volumeKmsKeyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProcessingClusterConfig' {Maybe Text
volumeKmsKeyId :: Maybe Text
$sel:volumeKmsKeyId:ProcessingClusterConfig' :: ProcessingClusterConfig -> Maybe Text
volumeKmsKeyId} -> Maybe Text
volumeKmsKeyId) (\s :: ProcessingClusterConfig
s@ProcessingClusterConfig' {} Maybe Text
a -> ProcessingClusterConfig
s {$sel:volumeKmsKeyId:ProcessingClusterConfig' :: Maybe Text
volumeKmsKeyId = Maybe Text
a} :: ProcessingClusterConfig)

-- | The number of ML compute instances to use in the processing job. For
-- distributed processing jobs, specify a value greater than 1. The default
-- value is 1.
processingClusterConfig_instanceCount :: Lens.Lens' ProcessingClusterConfig Prelude.Natural
processingClusterConfig_instanceCount :: Lens' ProcessingClusterConfig Natural
processingClusterConfig_instanceCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProcessingClusterConfig' {Natural
instanceCount :: Natural
$sel:instanceCount:ProcessingClusterConfig' :: ProcessingClusterConfig -> Natural
instanceCount} -> Natural
instanceCount) (\s :: ProcessingClusterConfig
s@ProcessingClusterConfig' {} Natural
a -> ProcessingClusterConfig
s {$sel:instanceCount:ProcessingClusterConfig' :: Natural
instanceCount = Natural
a} :: ProcessingClusterConfig)

-- | The ML compute instance type for the processing job.
processingClusterConfig_instanceType :: Lens.Lens' ProcessingClusterConfig ProcessingInstanceType
processingClusterConfig_instanceType :: Lens' ProcessingClusterConfig ProcessingInstanceType
processingClusterConfig_instanceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProcessingClusterConfig' {ProcessingInstanceType
instanceType :: ProcessingInstanceType
$sel:instanceType:ProcessingClusterConfig' :: ProcessingClusterConfig -> ProcessingInstanceType
instanceType} -> ProcessingInstanceType
instanceType) (\s :: ProcessingClusterConfig
s@ProcessingClusterConfig' {} ProcessingInstanceType
a -> ProcessingClusterConfig
s {$sel:instanceType:ProcessingClusterConfig' :: ProcessingInstanceType
instanceType = ProcessingInstanceType
a} :: ProcessingClusterConfig)

-- | The size of the ML storage volume in gigabytes that you want to
-- provision. You must specify sufficient ML storage for your scenario.
--
-- Certain Nitro-based instances include local storage with a fixed total
-- size, dependent on the instance type. When using these instances for
-- processing, Amazon SageMaker mounts the local instance storage instead
-- of Amazon EBS gp2 storage. You can\'t request a @VolumeSizeInGB@ greater
-- than the total size of the local instance storage.
--
-- For a list of instance types that support local instance storage,
-- including the total size per instance type, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html#instance-store-volumes Instance Store Volumes>.
processingClusterConfig_volumeSizeInGB :: Lens.Lens' ProcessingClusterConfig Prelude.Natural
processingClusterConfig_volumeSizeInGB :: Lens' ProcessingClusterConfig Natural
processingClusterConfig_volumeSizeInGB = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProcessingClusterConfig' {Natural
volumeSizeInGB :: Natural
$sel:volumeSizeInGB:ProcessingClusterConfig' :: ProcessingClusterConfig -> Natural
volumeSizeInGB} -> Natural
volumeSizeInGB) (\s :: ProcessingClusterConfig
s@ProcessingClusterConfig' {} Natural
a -> ProcessingClusterConfig
s {$sel:volumeSizeInGB:ProcessingClusterConfig' :: Natural
volumeSizeInGB = Natural
a} :: ProcessingClusterConfig)

instance Data.FromJSON ProcessingClusterConfig where
  parseJSON :: Value -> Parser ProcessingClusterConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ProcessingClusterConfig"
      ( \Object
x ->
          Maybe Text
-> Natural
-> ProcessingInstanceType
-> Natural
-> ProcessingClusterConfig
ProcessingClusterConfig'
            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
"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
"InstanceCount")
            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
"InstanceType")
            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 ProcessingClusterConfig where
  hashWithSalt :: Int -> ProcessingClusterConfig -> Int
hashWithSalt Int
_salt ProcessingClusterConfig' {Natural
Maybe Text
ProcessingInstanceType
volumeSizeInGB :: Natural
instanceType :: ProcessingInstanceType
instanceCount :: Natural
volumeKmsKeyId :: Maybe Text
$sel:volumeSizeInGB:ProcessingClusterConfig' :: ProcessingClusterConfig -> Natural
$sel:instanceType:ProcessingClusterConfig' :: ProcessingClusterConfig -> ProcessingInstanceType
$sel:instanceCount:ProcessingClusterConfig' :: ProcessingClusterConfig -> Natural
$sel:volumeKmsKeyId:ProcessingClusterConfig' :: ProcessingClusterConfig -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
volumeKmsKeyId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
instanceCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ProcessingInstanceType
instanceType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
volumeSizeInGB

instance Prelude.NFData ProcessingClusterConfig where
  rnf :: ProcessingClusterConfig -> ()
rnf ProcessingClusterConfig' {Natural
Maybe Text
ProcessingInstanceType
volumeSizeInGB :: Natural
instanceType :: ProcessingInstanceType
instanceCount :: Natural
volumeKmsKeyId :: Maybe Text
$sel:volumeSizeInGB:ProcessingClusterConfig' :: ProcessingClusterConfig -> Natural
$sel:instanceType:ProcessingClusterConfig' :: ProcessingClusterConfig -> ProcessingInstanceType
$sel:instanceCount:ProcessingClusterConfig' :: ProcessingClusterConfig -> Natural
$sel:volumeKmsKeyId:ProcessingClusterConfig' :: ProcessingClusterConfig -> Maybe Text
..} =
    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
instanceCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ProcessingInstanceType
instanceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
volumeSizeInGB

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