{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.RobOMaker.Types.Compute 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.RobOMaker.Types.ComputeType

-- | Compute information for the simulation job.
--
-- /See:/ 'newCompute' smart constructor.
data Compute = Compute'
  { -- | Compute type information for the simulation job.
    Compute -> Maybe ComputeType
computeType :: Prelude.Maybe ComputeType,
    -- | 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,
    -- | 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
  }
  deriving (Compute -> Compute -> Bool
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]
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
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. 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:
--
-- 'computeType', 'compute_computeType' - Compute type information for the simulation job.
--
-- 'gpuUnitLimit', 'compute_gpuUnitLimit' - Compute GPU unit limit for the simulation job. It is the same as the
-- number of GPUs allocated to the SimulationJob.
--
-- '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.
newCompute ::
  Compute
newCompute :: Compute
newCompute =
  Compute'
    { $sel:computeType:Compute' :: Maybe ComputeType
computeType = forall a. Maybe a
Prelude.Nothing,
      $sel:gpuUnitLimit:Compute' :: Maybe Natural
gpuUnitLimit = forall a. Maybe a
Prelude.Nothing,
      $sel:simulationUnitLimit:Compute' :: Maybe Natural
simulationUnitLimit = forall a. Maybe a
Prelude.Nothing
    }

-- | Compute type information for the simulation job.
compute_computeType :: Lens.Lens' Compute (Prelude.Maybe ComputeType)
compute_computeType :: Lens' Compute (Maybe ComputeType)
compute_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)

-- | 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 :: Lens' Compute (Maybe Natural)
compute_gpuUnitLimit = 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)

-- | 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 :: Lens' Compute (Maybe Natural)
compute_simulationUnitLimit = 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)

instance Data.FromJSON Compute where
  parseJSON :: Value -> Parser Compute
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Compute"
      ( \Object
x ->
          Maybe ComputeType -> Maybe Natural -> Maybe Natural -> Compute
Compute'
            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
"computeType")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"gpuUnitLimit")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"simulationUnitLimit")
      )

instance Prelude.Hashable Compute where
  hashWithSalt :: Int -> Compute -> Int
hashWithSalt Int
_salt Compute' {Maybe Natural
Maybe ComputeType
simulationUnitLimit :: Maybe Natural
gpuUnitLimit :: Maybe Natural
computeType :: Maybe ComputeType
$sel:simulationUnitLimit:Compute' :: Compute -> Maybe Natural
$sel:gpuUnitLimit:Compute' :: Compute -> Maybe Natural
$sel:computeType:Compute' :: Compute -> Maybe ComputeType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ComputeType
computeType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
gpuUnitLimit
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
simulationUnitLimit

instance Prelude.NFData Compute where
  rnf :: Compute -> ()
rnf Compute' {Maybe Natural
Maybe ComputeType
simulationUnitLimit :: Maybe Natural
gpuUnitLimit :: Maybe Natural
computeType :: Maybe ComputeType
$sel:simulationUnitLimit:Compute' :: Compute -> Maybe Natural
$sel:gpuUnitLimit:Compute' :: Compute -> Maybe Natural
$sel:computeType:Compute' :: Compute -> Maybe ComputeType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ComputeType
computeType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
gpuUnitLimit
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
simulationUnitLimit

instance Data.ToJSON Compute where
  toJSON :: Compute -> Value
toJSON Compute' {Maybe Natural
Maybe ComputeType
simulationUnitLimit :: Maybe Natural
gpuUnitLimit :: Maybe Natural
computeType :: Maybe ComputeType
$sel:simulationUnitLimit:Compute' :: Compute -> Maybe Natural
$sel:gpuUnitLimit:Compute' :: Compute -> Maybe Natural
$sel:computeType:Compute' :: Compute -> Maybe ComputeType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"computeType" 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 ComputeType
computeType,
            (Key
"gpuUnitLimit" 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 Natural
gpuUnitLimit,
            (Key
"simulationUnitLimit" 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 Natural
simulationUnitLimit
          ]
      )