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

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

-- | Identifies the resources, ML compute instances, and ML storage volumes
-- to deploy for a processing job. In distributed training, you specify
-- more than one instance.
--
-- /See:/ 'newProcessingResources' smart constructor.
data ProcessingResources = ProcessingResources'
  { -- | The configuration for the resources in a cluster used to run the
    -- processing job.
    ProcessingResources -> ProcessingClusterConfig
clusterConfig :: ProcessingClusterConfig
  }
  deriving (ProcessingResources -> ProcessingResources -> Bool
(ProcessingResources -> ProcessingResources -> Bool)
-> (ProcessingResources -> ProcessingResources -> Bool)
-> Eq ProcessingResources
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProcessingResources -> ProcessingResources -> Bool
$c/= :: ProcessingResources -> ProcessingResources -> Bool
== :: ProcessingResources -> ProcessingResources -> Bool
$c== :: ProcessingResources -> ProcessingResources -> Bool
Prelude.Eq, ReadPrec [ProcessingResources]
ReadPrec ProcessingResources
Int -> ReadS ProcessingResources
ReadS [ProcessingResources]
(Int -> ReadS ProcessingResources)
-> ReadS [ProcessingResources]
-> ReadPrec ProcessingResources
-> ReadPrec [ProcessingResources]
-> Read ProcessingResources
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ProcessingResources]
$creadListPrec :: ReadPrec [ProcessingResources]
readPrec :: ReadPrec ProcessingResources
$creadPrec :: ReadPrec ProcessingResources
readList :: ReadS [ProcessingResources]
$creadList :: ReadS [ProcessingResources]
readsPrec :: Int -> ReadS ProcessingResources
$creadsPrec :: Int -> ReadS ProcessingResources
Prelude.Read, Int -> ProcessingResources -> ShowS
[ProcessingResources] -> ShowS
ProcessingResources -> String
(Int -> ProcessingResources -> ShowS)
-> (ProcessingResources -> String)
-> ([ProcessingResources] -> ShowS)
-> Show ProcessingResources
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProcessingResources] -> ShowS
$cshowList :: [ProcessingResources] -> ShowS
show :: ProcessingResources -> String
$cshow :: ProcessingResources -> String
showsPrec :: Int -> ProcessingResources -> ShowS
$cshowsPrec :: Int -> ProcessingResources -> ShowS
Prelude.Show, (forall x. ProcessingResources -> Rep ProcessingResources x)
-> (forall x. Rep ProcessingResources x -> ProcessingResources)
-> Generic ProcessingResources
forall x. Rep ProcessingResources x -> ProcessingResources
forall x. ProcessingResources -> Rep ProcessingResources x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ProcessingResources x -> ProcessingResources
$cfrom :: forall x. ProcessingResources -> Rep ProcessingResources x
Prelude.Generic)

-- |
-- Create a value of 'ProcessingResources' 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:
--
-- 'clusterConfig', 'processingResources_clusterConfig' - The configuration for the resources in a cluster used to run the
-- processing job.
newProcessingResources ::
  -- | 'clusterConfig'
  ProcessingClusterConfig ->
  ProcessingResources
newProcessingResources :: ProcessingClusterConfig -> ProcessingResources
newProcessingResources ProcessingClusterConfig
pClusterConfig_ =
  ProcessingResources' :: ProcessingClusterConfig -> ProcessingResources
ProcessingResources'
    { $sel:clusterConfig:ProcessingResources' :: ProcessingClusterConfig
clusterConfig =
        ProcessingClusterConfig
pClusterConfig_
    }

-- | The configuration for the resources in a cluster used to run the
-- processing job.
processingResources_clusterConfig :: Lens.Lens' ProcessingResources ProcessingClusterConfig
processingResources_clusterConfig :: (ProcessingClusterConfig -> f ProcessingClusterConfig)
-> ProcessingResources -> f ProcessingResources
processingResources_clusterConfig = (ProcessingResources -> ProcessingClusterConfig)
-> (ProcessingResources
    -> ProcessingClusterConfig -> ProcessingResources)
-> Lens
     ProcessingResources
     ProcessingResources
     ProcessingClusterConfig
     ProcessingClusterConfig
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProcessingResources' {ProcessingClusterConfig
clusterConfig :: ProcessingClusterConfig
$sel:clusterConfig:ProcessingResources' :: ProcessingResources -> ProcessingClusterConfig
clusterConfig} -> ProcessingClusterConfig
clusterConfig) (\s :: ProcessingResources
s@ProcessingResources' {} ProcessingClusterConfig
a -> ProcessingResources
s {$sel:clusterConfig:ProcessingResources' :: ProcessingClusterConfig
clusterConfig = ProcessingClusterConfig
a} :: ProcessingResources)

instance Core.FromJSON ProcessingResources where
  parseJSON :: Value -> Parser ProcessingResources
parseJSON =
    String
-> (Object -> Parser ProcessingResources)
-> Value
-> Parser ProcessingResources
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ProcessingResources"
      ( \Object
x ->
          ProcessingClusterConfig -> ProcessingResources
ProcessingResources'
            (ProcessingClusterConfig -> ProcessingResources)
-> Parser ProcessingClusterConfig -> Parser ProcessingResources
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser ProcessingClusterConfig
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ClusterConfig")
      )

instance Prelude.Hashable ProcessingResources

instance Prelude.NFData ProcessingResources

instance Core.ToJSON ProcessingResources where
  toJSON :: ProcessingResources -> Value
toJSON ProcessingResources' {ProcessingClusterConfig
clusterConfig :: ProcessingClusterConfig
$sel:clusterConfig:ProcessingResources' :: ProcessingResources -> ProcessingClusterConfig
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ClusterConfig" Text -> ProcessingClusterConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ProcessingClusterConfig
clusterConfig)
          ]
      )