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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SageMaker.Types.TransformInstanceType

-- | Describes the resources, including ML instance types and ML instance
-- count, to use for transform job.
--
-- /See:/ 'newTransformResources' smart constructor.
data TransformResources = TransformResources'
  { -- | The Amazon Web Services Key Management Service (Amazon Web Services KMS)
    -- key that Amazon SageMaker uses to encrypt model data on the storage
    -- volume attached to the ML compute instance(s) that run the batch
    -- transform 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 any of the following formats:
    --
    -- -   Key ID: @1234abcd-12ab-34cd-56ef-1234567890ab@
    --
    -- -   Key ARN:
    --     @arn:aws:kms:us-west-2:111122223333:key\/1234abcd-12ab-34cd-56ef-1234567890ab@
    --
    -- -   Alias name: @alias\/ExampleAlias@
    --
    -- -   Alias name ARN:
    --     @arn:aws:kms:us-west-2:111122223333:alias\/ExampleAlias@
    TransformResources -> Maybe Text
volumeKmsKeyId :: Prelude.Maybe Prelude.Text,
    -- | The ML compute instance type for the transform job. If you are using
    -- built-in algorithms to transform moderately sized datasets, we recommend
    -- using ml.m4.xlarge or @ml.m5.large@instance types.
    TransformResources -> TransformInstanceType
instanceType :: TransformInstanceType,
    -- | The number of ML compute instances to use in the transform job. For
    -- distributed transform jobs, specify a value greater than 1. The default
    -- value is @1@.
    TransformResources -> Natural
instanceCount :: Prelude.Natural
  }
  deriving (TransformResources -> TransformResources -> Bool
(TransformResources -> TransformResources -> Bool)
-> (TransformResources -> TransformResources -> Bool)
-> Eq TransformResources
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TransformResources -> TransformResources -> Bool
$c/= :: TransformResources -> TransformResources -> Bool
== :: TransformResources -> TransformResources -> Bool
$c== :: TransformResources -> TransformResources -> Bool
Prelude.Eq, ReadPrec [TransformResources]
ReadPrec TransformResources
Int -> ReadS TransformResources
ReadS [TransformResources]
(Int -> ReadS TransformResources)
-> ReadS [TransformResources]
-> ReadPrec TransformResources
-> ReadPrec [TransformResources]
-> Read TransformResources
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TransformResources]
$creadListPrec :: ReadPrec [TransformResources]
readPrec :: ReadPrec TransformResources
$creadPrec :: ReadPrec TransformResources
readList :: ReadS [TransformResources]
$creadList :: ReadS [TransformResources]
readsPrec :: Int -> ReadS TransformResources
$creadsPrec :: Int -> ReadS TransformResources
Prelude.Read, Int -> TransformResources -> ShowS
[TransformResources] -> ShowS
TransformResources -> String
(Int -> TransformResources -> ShowS)
-> (TransformResources -> String)
-> ([TransformResources] -> ShowS)
-> Show TransformResources
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TransformResources] -> ShowS
$cshowList :: [TransformResources] -> ShowS
show :: TransformResources -> String
$cshow :: TransformResources -> String
showsPrec :: Int -> TransformResources -> ShowS
$cshowsPrec :: Int -> TransformResources -> ShowS
Prelude.Show, (forall x. TransformResources -> Rep TransformResources x)
-> (forall x. Rep TransformResources x -> TransformResources)
-> Generic TransformResources
forall x. Rep TransformResources x -> TransformResources
forall x. TransformResources -> Rep TransformResources x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TransformResources x -> TransformResources
$cfrom :: forall x. TransformResources -> Rep TransformResources x
Prelude.Generic)

-- |
-- Create a value of 'TransformResources' 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', 'transformResources_volumeKmsKeyId' - The Amazon Web Services Key Management Service (Amazon Web Services KMS)
-- key that Amazon SageMaker uses to encrypt model data on the storage
-- volume attached to the ML compute instance(s) that run the batch
-- transform 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 any of the following formats:
--
-- -   Key ID: @1234abcd-12ab-34cd-56ef-1234567890ab@
--
-- -   Key ARN:
--     @arn:aws:kms:us-west-2:111122223333:key\/1234abcd-12ab-34cd-56ef-1234567890ab@
--
-- -   Alias name: @alias\/ExampleAlias@
--
-- -   Alias name ARN:
--     @arn:aws:kms:us-west-2:111122223333:alias\/ExampleAlias@
--
-- 'instanceType', 'transformResources_instanceType' - The ML compute instance type for the transform job. If you are using
-- built-in algorithms to transform moderately sized datasets, we recommend
-- using ml.m4.xlarge or @ml.m5.large@instance types.
--
-- 'instanceCount', 'transformResources_instanceCount' - The number of ML compute instances to use in the transform job. For
-- distributed transform jobs, specify a value greater than 1. The default
-- value is @1@.
newTransformResources ::
  -- | 'instanceType'
  TransformInstanceType ->
  -- | 'instanceCount'
  Prelude.Natural ->
  TransformResources
newTransformResources :: TransformInstanceType -> Natural -> TransformResources
newTransformResources TransformInstanceType
pInstanceType_ Natural
pInstanceCount_ =
  TransformResources' :: Maybe Text
-> TransformInstanceType -> Natural -> TransformResources
TransformResources'
    { $sel:volumeKmsKeyId:TransformResources' :: Maybe Text
volumeKmsKeyId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:instanceType:TransformResources' :: TransformInstanceType
instanceType = TransformInstanceType
pInstanceType_,
      $sel:instanceCount:TransformResources' :: Natural
instanceCount = Natural
pInstanceCount_
    }

-- | The Amazon Web Services Key Management Service (Amazon Web Services KMS)
-- key that Amazon SageMaker uses to encrypt model data on the storage
-- volume attached to the ML compute instance(s) that run the batch
-- transform 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 any of the following formats:
--
-- -   Key ID: @1234abcd-12ab-34cd-56ef-1234567890ab@
--
-- -   Key ARN:
--     @arn:aws:kms:us-west-2:111122223333:key\/1234abcd-12ab-34cd-56ef-1234567890ab@
--
-- -   Alias name: @alias\/ExampleAlias@
--
-- -   Alias name ARN:
--     @arn:aws:kms:us-west-2:111122223333:alias\/ExampleAlias@
transformResources_volumeKmsKeyId :: Lens.Lens' TransformResources (Prelude.Maybe Prelude.Text)
transformResources_volumeKmsKeyId :: (Maybe Text -> f (Maybe Text))
-> TransformResources -> f TransformResources
transformResources_volumeKmsKeyId = (TransformResources -> Maybe Text)
-> (TransformResources -> Maybe Text -> TransformResources)
-> Lens
     TransformResources TransformResources (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TransformResources' {Maybe Text
volumeKmsKeyId :: Maybe Text
$sel:volumeKmsKeyId:TransformResources' :: TransformResources -> Maybe Text
volumeKmsKeyId} -> Maybe Text
volumeKmsKeyId) (\s :: TransformResources
s@TransformResources' {} Maybe Text
a -> TransformResources
s {$sel:volumeKmsKeyId:TransformResources' :: Maybe Text
volumeKmsKeyId = Maybe Text
a} :: TransformResources)

-- | The ML compute instance type for the transform job. If you are using
-- built-in algorithms to transform moderately sized datasets, we recommend
-- using ml.m4.xlarge or @ml.m5.large@instance types.
transformResources_instanceType :: Lens.Lens' TransformResources TransformInstanceType
transformResources_instanceType :: (TransformInstanceType -> f TransformInstanceType)
-> TransformResources -> f TransformResources
transformResources_instanceType = (TransformResources -> TransformInstanceType)
-> (TransformResources
    -> TransformInstanceType -> TransformResources)
-> Lens
     TransformResources
     TransformResources
     TransformInstanceType
     TransformInstanceType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TransformResources' {TransformInstanceType
instanceType :: TransformInstanceType
$sel:instanceType:TransformResources' :: TransformResources -> TransformInstanceType
instanceType} -> TransformInstanceType
instanceType) (\s :: TransformResources
s@TransformResources' {} TransformInstanceType
a -> TransformResources
s {$sel:instanceType:TransformResources' :: TransformInstanceType
instanceType = TransformInstanceType
a} :: TransformResources)

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

instance Core.FromJSON TransformResources where
  parseJSON :: Value -> Parser TransformResources
parseJSON =
    String
-> (Object -> Parser TransformResources)
-> Value
-> Parser TransformResources
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TransformResources"
      ( \Object
x ->
          Maybe Text
-> TransformInstanceType -> Natural -> TransformResources
TransformResources'
            (Maybe Text
 -> TransformInstanceType -> Natural -> TransformResources)
-> Parser (Maybe Text)
-> Parser (TransformInstanceType -> Natural -> TransformResources)
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 (TransformInstanceType -> Natural -> TransformResources)
-> Parser TransformInstanceType
-> Parser (Natural -> TransformResources)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser TransformInstanceType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"InstanceType")
            Parser (Natural -> TransformResources)
-> Parser Natural -> Parser TransformResources
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")
      )

instance Prelude.Hashable TransformResources

instance Prelude.NFData TransformResources

instance Core.ToJSON TransformResources where
  toJSON :: TransformResources -> Value
toJSON TransformResources' {Natural
Maybe Text
TransformInstanceType
instanceCount :: Natural
instanceType :: TransformInstanceType
volumeKmsKeyId :: Maybe Text
$sel:instanceCount:TransformResources' :: TransformResources -> Natural
$sel:instanceType:TransformResources' :: TransformResources -> TransformInstanceType
$sel:volumeKmsKeyId:TransformResources' :: TransformResources -> 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
"InstanceType" Text -> TransformInstanceType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= TransformInstanceType
instanceType),
            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)
          ]
      )