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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(ProcessingClusterConfig -> ProcessingClusterConfig -> Bool)
-> (ProcessingClusterConfig -> ProcessingClusterConfig -> Bool)
-> Eq ProcessingClusterConfig
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]
(Int -> ReadS ProcessingClusterConfig)
-> ReadS [ProcessingClusterConfig]
-> ReadPrec ProcessingClusterConfig
-> ReadPrec [ProcessingClusterConfig]
-> Read 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
(Int -> ProcessingClusterConfig -> ShowS)
-> (ProcessingClusterConfig -> String)
-> ([ProcessingClusterConfig] -> ShowS)
-> Show ProcessingClusterConfig
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.
 ProcessingClusterConfig -> Rep ProcessingClusterConfig x)
-> (forall x.
    Rep ProcessingClusterConfig x -> ProcessingClusterConfig)
-> Generic ProcessingClusterConfig
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' :: Maybe Text
-> Natural
-> ProcessingInstanceType
-> Natural
-> ProcessingClusterConfig
ProcessingClusterConfig'
      { $sel:volumeKmsKeyId:ProcessingClusterConfig' :: Maybe Text
volumeKmsKeyId =
          Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> ProcessingClusterConfig -> f ProcessingClusterConfig
processingClusterConfig_volumeKmsKeyId = (ProcessingClusterConfig -> Maybe Text)
-> (ProcessingClusterConfig
    -> Maybe Text -> ProcessingClusterConfig)
-> Lens
     ProcessingClusterConfig
     ProcessingClusterConfig
     (Maybe Text)
     (Maybe Text)
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 :: (Natural -> f Natural)
-> ProcessingClusterConfig -> f ProcessingClusterConfig
processingClusterConfig_instanceCount = (ProcessingClusterConfig -> Natural)
-> (ProcessingClusterConfig -> Natural -> ProcessingClusterConfig)
-> Lens
     ProcessingClusterConfig ProcessingClusterConfig Natural Natural
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 :: (ProcessingInstanceType -> f ProcessingInstanceType)
-> ProcessingClusterConfig -> f ProcessingClusterConfig
processingClusterConfig_instanceType = (ProcessingClusterConfig -> ProcessingInstanceType)
-> (ProcessingClusterConfig
    -> ProcessingInstanceType -> ProcessingClusterConfig)
-> Lens
     ProcessingClusterConfig
     ProcessingClusterConfig
     ProcessingInstanceType
     ProcessingInstanceType
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 :: (Natural -> f Natural)
-> ProcessingClusterConfig -> f ProcessingClusterConfig
processingClusterConfig_volumeSizeInGB = (ProcessingClusterConfig -> Natural)
-> (ProcessingClusterConfig -> Natural -> ProcessingClusterConfig)
-> Lens
     ProcessingClusterConfig ProcessingClusterConfig Natural Natural
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 Core.FromJSON ProcessingClusterConfig where
  parseJSON :: Value -> Parser ProcessingClusterConfig
parseJSON =
    String
-> (Object -> Parser ProcessingClusterConfig)
-> Value
-> Parser ProcessingClusterConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ProcessingClusterConfig"
      ( \Object
x ->
          Maybe Text
-> Natural
-> ProcessingInstanceType
-> Natural
-> ProcessingClusterConfig
ProcessingClusterConfig'
            (Maybe Text
 -> Natural
 -> ProcessingInstanceType
 -> Natural
 -> ProcessingClusterConfig)
-> Parser (Maybe Text)
-> Parser
     (Natural
      -> ProcessingInstanceType -> Natural -> ProcessingClusterConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"VolumeKmsKeyId")
            Parser
  (Natural
   -> ProcessingInstanceType -> Natural -> ProcessingClusterConfig)
-> Parser Natural
-> Parser
     (ProcessingInstanceType -> Natural -> ProcessingClusterConfig)
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
"InstanceCount")
            Parser
  (ProcessingInstanceType -> Natural -> ProcessingClusterConfig)
-> Parser ProcessingInstanceType
-> Parser (Natural -> ProcessingClusterConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ProcessingInstanceType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"InstanceType")
            Parser (Natural -> ProcessingClusterConfig)
-> Parser Natural -> Parser ProcessingClusterConfig
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
"VolumeSizeInGB")
      )

instance Prelude.Hashable ProcessingClusterConfig

instance Prelude.NFData ProcessingClusterConfig

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"VolumeKmsKeyId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
volumeKmsKeyId,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"InstanceCount" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
instanceCount),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"InstanceType" Text -> ProcessingInstanceType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ProcessingInstanceType
instanceType),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"VolumeSizeInGB" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
volumeSizeInGB)
          ]
      )