{-# 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.RobOMaker.Types.Compute
-- 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.RobOMaker.Types.Compute where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.RobOMaker.Types.ComputeType

-- | Compute information for the simulation job.
--
-- /See:/ 'newCompute' smart constructor.
data Compute = Compute'
  { -- | The simulation unit limit. Your simulation is allocated CPU and memory
    -- proportional to the supplied simulation unit limit. A simulation unit is
    -- 1 vcpu and 2GB of memory. You are only billed for the SU utilization you
    -- consume up to the maximum value provided. The default is 15.
    Compute -> Maybe Natural
simulationUnitLimit :: Prelude.Maybe Prelude.Natural,
    -- | Compute GPU unit limit for the simulation job. It is the same as the
    -- number of GPUs allocated to the SimulationJob.
    Compute -> Maybe Natural
gpuUnitLimit :: Prelude.Maybe Prelude.Natural,
    -- | Compute type information for the simulation job.
    Compute -> Maybe ComputeType
computeType :: Prelude.Maybe ComputeType
  }
  deriving (Compute -> Compute -> Bool
(Compute -> Compute -> Bool)
-> (Compute -> Compute -> Bool) -> Eq Compute
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Compute -> Compute -> Bool
$c/= :: Compute -> Compute -> Bool
== :: Compute -> Compute -> Bool
$c== :: Compute -> Compute -> Bool
Prelude.Eq, ReadPrec [Compute]
ReadPrec Compute
Int -> ReadS Compute
ReadS [Compute]
(Int -> ReadS Compute)
-> ReadS [Compute]
-> ReadPrec Compute
-> ReadPrec [Compute]
-> Read Compute
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Compute]
$creadListPrec :: ReadPrec [Compute]
readPrec :: ReadPrec Compute
$creadPrec :: ReadPrec Compute
readList :: ReadS [Compute]
$creadList :: ReadS [Compute]
readsPrec :: Int -> ReadS Compute
$creadsPrec :: Int -> ReadS Compute
Prelude.Read, Int -> Compute -> ShowS
[Compute] -> ShowS
Compute -> String
(Int -> Compute -> ShowS)
-> (Compute -> String) -> ([Compute] -> ShowS) -> Show Compute
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Compute] -> ShowS
$cshowList :: [Compute] -> ShowS
show :: Compute -> String
$cshow :: Compute -> String
showsPrec :: Int -> Compute -> ShowS
$cshowsPrec :: Int -> Compute -> ShowS
Prelude.Show, (forall x. Compute -> Rep Compute x)
-> (forall x. Rep Compute x -> Compute) -> Generic Compute
forall x. Rep Compute x -> Compute
forall x. Compute -> Rep Compute x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Compute x -> Compute
$cfrom :: forall x. Compute -> Rep Compute x
Prelude.Generic)

-- |
-- Create a value of 'Compute' 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:
--
-- 'simulationUnitLimit', 'compute_simulationUnitLimit' - The simulation unit limit. Your simulation is allocated CPU and memory
-- proportional to the supplied simulation unit limit. A simulation unit is
-- 1 vcpu and 2GB of memory. You are only billed for the SU utilization you
-- consume up to the maximum value provided. The default is 15.
--
-- 'gpuUnitLimit', 'compute_gpuUnitLimit' - Compute GPU unit limit for the simulation job. It is the same as the
-- number of GPUs allocated to the SimulationJob.
--
-- 'computeType', 'compute_computeType' - Compute type information for the simulation job.
newCompute ::
  Compute
newCompute :: Compute
newCompute =
  Compute' :: Maybe Natural -> Maybe Natural -> Maybe ComputeType -> Compute
Compute'
    { $sel:simulationUnitLimit:Compute' :: Maybe Natural
simulationUnitLimit = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:gpuUnitLimit:Compute' :: Maybe Natural
gpuUnitLimit = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:computeType:Compute' :: Maybe ComputeType
computeType = Maybe ComputeType
forall a. Maybe a
Prelude.Nothing
    }

-- | The simulation unit limit. Your simulation is allocated CPU and memory
-- proportional to the supplied simulation unit limit. A simulation unit is
-- 1 vcpu and 2GB of memory. You are only billed for the SU utilization you
-- consume up to the maximum value provided. The default is 15.
compute_simulationUnitLimit :: Lens.Lens' Compute (Prelude.Maybe Prelude.Natural)
compute_simulationUnitLimit :: (Maybe Natural -> f (Maybe Natural)) -> Compute -> f Compute
compute_simulationUnitLimit = (Compute -> Maybe Natural)
-> (Compute -> Maybe Natural -> Compute)
-> Lens Compute Compute (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Compute' {Maybe Natural
simulationUnitLimit :: Maybe Natural
$sel:simulationUnitLimit:Compute' :: Compute -> Maybe Natural
simulationUnitLimit} -> Maybe Natural
simulationUnitLimit) (\s :: Compute
s@Compute' {} Maybe Natural
a -> Compute
s {$sel:simulationUnitLimit:Compute' :: Maybe Natural
simulationUnitLimit = Maybe Natural
a} :: Compute)

-- | Compute GPU unit limit for the simulation job. It is the same as the
-- number of GPUs allocated to the SimulationJob.
compute_gpuUnitLimit :: Lens.Lens' Compute (Prelude.Maybe Prelude.Natural)
compute_gpuUnitLimit :: (Maybe Natural -> f (Maybe Natural)) -> Compute -> f Compute
compute_gpuUnitLimit = (Compute -> Maybe Natural)
-> (Compute -> Maybe Natural -> Compute)
-> Lens Compute Compute (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Compute' {Maybe Natural
gpuUnitLimit :: Maybe Natural
$sel:gpuUnitLimit:Compute' :: Compute -> Maybe Natural
gpuUnitLimit} -> Maybe Natural
gpuUnitLimit) (\s :: Compute
s@Compute' {} Maybe Natural
a -> Compute
s {$sel:gpuUnitLimit:Compute' :: Maybe Natural
gpuUnitLimit = Maybe Natural
a} :: Compute)

-- | Compute type information for the simulation job.
compute_computeType :: Lens.Lens' Compute (Prelude.Maybe ComputeType)
compute_computeType :: (Maybe ComputeType -> f (Maybe ComputeType))
-> Compute -> f Compute
compute_computeType = (Compute -> Maybe ComputeType)
-> (Compute -> Maybe ComputeType -> Compute)
-> Lens Compute Compute (Maybe ComputeType) (Maybe ComputeType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Compute' {Maybe ComputeType
computeType :: Maybe ComputeType
$sel:computeType:Compute' :: Compute -> Maybe ComputeType
computeType} -> Maybe ComputeType
computeType) (\s :: Compute
s@Compute' {} Maybe ComputeType
a -> Compute
s {$sel:computeType:Compute' :: Maybe ComputeType
computeType = Maybe ComputeType
a} :: Compute)

instance Core.FromJSON Compute where
  parseJSON :: Value -> Parser Compute
parseJSON =
    String -> (Object -> Parser Compute) -> Value -> Parser Compute
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Compute"
      ( \Object
x ->
          Maybe Natural -> Maybe Natural -> Maybe ComputeType -> Compute
Compute'
            (Maybe Natural -> Maybe Natural -> Maybe ComputeType -> Compute)
-> Parser (Maybe Natural)
-> Parser (Maybe Natural -> Maybe ComputeType -> Compute)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"simulationUnitLimit")
            Parser (Maybe Natural -> Maybe ComputeType -> Compute)
-> Parser (Maybe Natural) -> Parser (Maybe ComputeType -> Compute)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"gpuUnitLimit")
            Parser (Maybe ComputeType -> Compute)
-> Parser (Maybe ComputeType) -> Parser Compute
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ComputeType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"computeType")
      )

instance Prelude.Hashable Compute

instance Prelude.NFData Compute

instance Core.ToJSON Compute where
  toJSON :: Compute -> Value
toJSON Compute' {Maybe Natural
Maybe ComputeType
computeType :: Maybe ComputeType
gpuUnitLimit :: Maybe Natural
simulationUnitLimit :: Maybe Natural
$sel:computeType:Compute' :: Compute -> Maybe ComputeType
$sel:gpuUnitLimit:Compute' :: Compute -> Maybe Natural
$sel:simulationUnitLimit:Compute' :: Compute -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"simulationUnitLimit" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
simulationUnitLimit,
            (Text
"gpuUnitLimit" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
gpuUnitLimit,
            (Text
"computeType" Text -> ComputeType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ComputeType -> Pair) -> Maybe ComputeType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ComputeType
computeType
          ]
      )