{-# 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.EMR.Types.ComputeLimits
-- 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.EMR.Types.ComputeLimits where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EMR.Types.ComputeLimitsUnitType
import qualified Amazonka.Prelude as Prelude

-- | The EC2 unit limits for a managed scaling policy. The managed scaling
-- activity of a cluster can not be above or below these limits. The limit
-- only applies to the core and task nodes. The master node cannot be
-- scaled after initial configuration.
--
-- /See:/ 'newComputeLimits' smart constructor.
data ComputeLimits = ComputeLimits'
  { -- | The upper boundary of EC2 units for core node type in a cluster. It is
    -- measured through vCPU cores or instances for instance groups and
    -- measured through units for instance fleets. The core units are not
    -- allowed to scale beyond this boundary. The parameter is used to split
    -- capacity allocation between core and task nodes.
    ComputeLimits -> Maybe Int
maximumCoreCapacityUnits :: Prelude.Maybe Prelude.Int,
    -- | The upper boundary of On-Demand EC2 units. It is measured through vCPU
    -- cores or instances for instance groups and measured through units for
    -- instance fleets. The On-Demand units are not allowed to scale beyond
    -- this boundary. The parameter is used to split capacity allocation
    -- between On-Demand and Spot Instances.
    ComputeLimits -> Maybe Int
maximumOnDemandCapacityUnits :: Prelude.Maybe Prelude.Int,
    -- | The unit type used for specifying a managed scaling policy.
    ComputeLimits -> ComputeLimitsUnitType
unitType :: ComputeLimitsUnitType,
    -- | The lower boundary of EC2 units. It is measured through vCPU cores or
    -- instances for instance groups and measured through units for instance
    -- fleets. Managed scaling activities are not allowed beyond this boundary.
    -- The limit only applies to the core and task nodes. The master node
    -- cannot be scaled after initial configuration.
    ComputeLimits -> Int
minimumCapacityUnits :: Prelude.Int,
    -- | The upper boundary of EC2 units. It is measured through vCPU cores or
    -- instances for instance groups and measured through units for instance
    -- fleets. Managed scaling activities are not allowed beyond this boundary.
    -- The limit only applies to the core and task nodes. The master node
    -- cannot be scaled after initial configuration.
    ComputeLimits -> Int
maximumCapacityUnits :: Prelude.Int
  }
  deriving (ComputeLimits -> ComputeLimits -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ComputeLimits -> ComputeLimits -> Bool
$c/= :: ComputeLimits -> ComputeLimits -> Bool
== :: ComputeLimits -> ComputeLimits -> Bool
$c== :: ComputeLimits -> ComputeLimits -> Bool
Prelude.Eq, ReadPrec [ComputeLimits]
ReadPrec ComputeLimits
Int -> ReadS ComputeLimits
ReadS [ComputeLimits]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ComputeLimits]
$creadListPrec :: ReadPrec [ComputeLimits]
readPrec :: ReadPrec ComputeLimits
$creadPrec :: ReadPrec ComputeLimits
readList :: ReadS [ComputeLimits]
$creadList :: ReadS [ComputeLimits]
readsPrec :: Int -> ReadS ComputeLimits
$creadsPrec :: Int -> ReadS ComputeLimits
Prelude.Read, Int -> ComputeLimits -> ShowS
[ComputeLimits] -> ShowS
ComputeLimits -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ComputeLimits] -> ShowS
$cshowList :: [ComputeLimits] -> ShowS
show :: ComputeLimits -> String
$cshow :: ComputeLimits -> String
showsPrec :: Int -> ComputeLimits -> ShowS
$cshowsPrec :: Int -> ComputeLimits -> ShowS
Prelude.Show, forall x. Rep ComputeLimits x -> ComputeLimits
forall x. ComputeLimits -> Rep ComputeLimits x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ComputeLimits x -> ComputeLimits
$cfrom :: forall x. ComputeLimits -> Rep ComputeLimits x
Prelude.Generic)

-- |
-- Create a value of 'ComputeLimits' 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:
--
-- 'maximumCoreCapacityUnits', 'computeLimits_maximumCoreCapacityUnits' - The upper boundary of EC2 units for core node type in a cluster. It is
-- measured through vCPU cores or instances for instance groups and
-- measured through units for instance fleets. The core units are not
-- allowed to scale beyond this boundary. The parameter is used to split
-- capacity allocation between core and task nodes.
--
-- 'maximumOnDemandCapacityUnits', 'computeLimits_maximumOnDemandCapacityUnits' - The upper boundary of On-Demand EC2 units. It is measured through vCPU
-- cores or instances for instance groups and measured through units for
-- instance fleets. The On-Demand units are not allowed to scale beyond
-- this boundary. The parameter is used to split capacity allocation
-- between On-Demand and Spot Instances.
--
-- 'unitType', 'computeLimits_unitType' - The unit type used for specifying a managed scaling policy.
--
-- 'minimumCapacityUnits', 'computeLimits_minimumCapacityUnits' - The lower boundary of EC2 units. It is measured through vCPU cores or
-- instances for instance groups and measured through units for instance
-- fleets. Managed scaling activities are not allowed beyond this boundary.
-- The limit only applies to the core and task nodes. The master node
-- cannot be scaled after initial configuration.
--
-- 'maximumCapacityUnits', 'computeLimits_maximumCapacityUnits' - The upper boundary of EC2 units. It is measured through vCPU cores or
-- instances for instance groups and measured through units for instance
-- fleets. Managed scaling activities are not allowed beyond this boundary.
-- The limit only applies to the core and task nodes. The master node
-- cannot be scaled after initial configuration.
newComputeLimits ::
  -- | 'unitType'
  ComputeLimitsUnitType ->
  -- | 'minimumCapacityUnits'
  Prelude.Int ->
  -- | 'maximumCapacityUnits'
  Prelude.Int ->
  ComputeLimits
newComputeLimits :: ComputeLimitsUnitType -> Int -> Int -> ComputeLimits
newComputeLimits
  ComputeLimitsUnitType
pUnitType_
  Int
pMinimumCapacityUnits_
  Int
pMaximumCapacityUnits_ =
    ComputeLimits'
      { $sel:maximumCoreCapacityUnits:ComputeLimits' :: Maybe Int
maximumCoreCapacityUnits =
          forall a. Maybe a
Prelude.Nothing,
        $sel:maximumOnDemandCapacityUnits:ComputeLimits' :: Maybe Int
maximumOnDemandCapacityUnits = forall a. Maybe a
Prelude.Nothing,
        $sel:unitType:ComputeLimits' :: ComputeLimitsUnitType
unitType = ComputeLimitsUnitType
pUnitType_,
        $sel:minimumCapacityUnits:ComputeLimits' :: Int
minimumCapacityUnits = Int
pMinimumCapacityUnits_,
        $sel:maximumCapacityUnits:ComputeLimits' :: Int
maximumCapacityUnits = Int
pMaximumCapacityUnits_
      }

-- | The upper boundary of EC2 units for core node type in a cluster. It is
-- measured through vCPU cores or instances for instance groups and
-- measured through units for instance fleets. The core units are not
-- allowed to scale beyond this boundary. The parameter is used to split
-- capacity allocation between core and task nodes.
computeLimits_maximumCoreCapacityUnits :: Lens.Lens' ComputeLimits (Prelude.Maybe Prelude.Int)
computeLimits_maximumCoreCapacityUnits :: Lens' ComputeLimits (Maybe Int)
computeLimits_maximumCoreCapacityUnits = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComputeLimits' {Maybe Int
maximumCoreCapacityUnits :: Maybe Int
$sel:maximumCoreCapacityUnits:ComputeLimits' :: ComputeLimits -> Maybe Int
maximumCoreCapacityUnits} -> Maybe Int
maximumCoreCapacityUnits) (\s :: ComputeLimits
s@ComputeLimits' {} Maybe Int
a -> ComputeLimits
s {$sel:maximumCoreCapacityUnits:ComputeLimits' :: Maybe Int
maximumCoreCapacityUnits = Maybe Int
a} :: ComputeLimits)

-- | The upper boundary of On-Demand EC2 units. It is measured through vCPU
-- cores or instances for instance groups and measured through units for
-- instance fleets. The On-Demand units are not allowed to scale beyond
-- this boundary. The parameter is used to split capacity allocation
-- between On-Demand and Spot Instances.
computeLimits_maximumOnDemandCapacityUnits :: Lens.Lens' ComputeLimits (Prelude.Maybe Prelude.Int)
computeLimits_maximumOnDemandCapacityUnits :: Lens' ComputeLimits (Maybe Int)
computeLimits_maximumOnDemandCapacityUnits = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComputeLimits' {Maybe Int
maximumOnDemandCapacityUnits :: Maybe Int
$sel:maximumOnDemandCapacityUnits:ComputeLimits' :: ComputeLimits -> Maybe Int
maximumOnDemandCapacityUnits} -> Maybe Int
maximumOnDemandCapacityUnits) (\s :: ComputeLimits
s@ComputeLimits' {} Maybe Int
a -> ComputeLimits
s {$sel:maximumOnDemandCapacityUnits:ComputeLimits' :: Maybe Int
maximumOnDemandCapacityUnits = Maybe Int
a} :: ComputeLimits)

-- | The unit type used for specifying a managed scaling policy.
computeLimits_unitType :: Lens.Lens' ComputeLimits ComputeLimitsUnitType
computeLimits_unitType :: Lens' ComputeLimits ComputeLimitsUnitType
computeLimits_unitType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComputeLimits' {ComputeLimitsUnitType
unitType :: ComputeLimitsUnitType
$sel:unitType:ComputeLimits' :: ComputeLimits -> ComputeLimitsUnitType
unitType} -> ComputeLimitsUnitType
unitType) (\s :: ComputeLimits
s@ComputeLimits' {} ComputeLimitsUnitType
a -> ComputeLimits
s {$sel:unitType:ComputeLimits' :: ComputeLimitsUnitType
unitType = ComputeLimitsUnitType
a} :: ComputeLimits)

-- | The lower boundary of EC2 units. It is measured through vCPU cores or
-- instances for instance groups and measured through units for instance
-- fleets. Managed scaling activities are not allowed beyond this boundary.
-- The limit only applies to the core and task nodes. The master node
-- cannot be scaled after initial configuration.
computeLimits_minimumCapacityUnits :: Lens.Lens' ComputeLimits Prelude.Int
computeLimits_minimumCapacityUnits :: Lens' ComputeLimits Int
computeLimits_minimumCapacityUnits = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComputeLimits' {Int
minimumCapacityUnits :: Int
$sel:minimumCapacityUnits:ComputeLimits' :: ComputeLimits -> Int
minimumCapacityUnits} -> Int
minimumCapacityUnits) (\s :: ComputeLimits
s@ComputeLimits' {} Int
a -> ComputeLimits
s {$sel:minimumCapacityUnits:ComputeLimits' :: Int
minimumCapacityUnits = Int
a} :: ComputeLimits)

-- | The upper boundary of EC2 units. It is measured through vCPU cores or
-- instances for instance groups and measured through units for instance
-- fleets. Managed scaling activities are not allowed beyond this boundary.
-- The limit only applies to the core and task nodes. The master node
-- cannot be scaled after initial configuration.
computeLimits_maximumCapacityUnits :: Lens.Lens' ComputeLimits Prelude.Int
computeLimits_maximumCapacityUnits :: Lens' ComputeLimits Int
computeLimits_maximumCapacityUnits = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComputeLimits' {Int
maximumCapacityUnits :: Int
$sel:maximumCapacityUnits:ComputeLimits' :: ComputeLimits -> Int
maximumCapacityUnits} -> Int
maximumCapacityUnits) (\s :: ComputeLimits
s@ComputeLimits' {} Int
a -> ComputeLimits
s {$sel:maximumCapacityUnits:ComputeLimits' :: Int
maximumCapacityUnits = Int
a} :: ComputeLimits)

instance Data.FromJSON ComputeLimits where
  parseJSON :: Value -> Parser ComputeLimits
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ComputeLimits"
      ( \Object
x ->
          Maybe Int
-> Maybe Int
-> ComputeLimitsUnitType
-> Int
-> Int
-> ComputeLimits
ComputeLimits'
            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
"MaximumCoreCapacityUnits")
            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
"MaximumOnDemandCapacityUnits")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"UnitType")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"MinimumCapacityUnits")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"MaximumCapacityUnits")
      )

instance Prelude.Hashable ComputeLimits where
  hashWithSalt :: Int -> ComputeLimits -> Int
hashWithSalt Int
_salt ComputeLimits' {Int
Maybe Int
ComputeLimitsUnitType
maximumCapacityUnits :: Int
minimumCapacityUnits :: Int
unitType :: ComputeLimitsUnitType
maximumOnDemandCapacityUnits :: Maybe Int
maximumCoreCapacityUnits :: Maybe Int
$sel:maximumCapacityUnits:ComputeLimits' :: ComputeLimits -> Int
$sel:minimumCapacityUnits:ComputeLimits' :: ComputeLimits -> Int
$sel:unitType:ComputeLimits' :: ComputeLimits -> ComputeLimitsUnitType
$sel:maximumOnDemandCapacityUnits:ComputeLimits' :: ComputeLimits -> Maybe Int
$sel:maximumCoreCapacityUnits:ComputeLimits' :: ComputeLimits -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
maximumCoreCapacityUnits
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
maximumOnDemandCapacityUnits
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ComputeLimitsUnitType
unitType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
minimumCapacityUnits
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
maximumCapacityUnits

instance Prelude.NFData ComputeLimits where
  rnf :: ComputeLimits -> ()
rnf ComputeLimits' {Int
Maybe Int
ComputeLimitsUnitType
maximumCapacityUnits :: Int
minimumCapacityUnits :: Int
unitType :: ComputeLimitsUnitType
maximumOnDemandCapacityUnits :: Maybe Int
maximumCoreCapacityUnits :: Maybe Int
$sel:maximumCapacityUnits:ComputeLimits' :: ComputeLimits -> Int
$sel:minimumCapacityUnits:ComputeLimits' :: ComputeLimits -> Int
$sel:unitType:ComputeLimits' :: ComputeLimits -> ComputeLimitsUnitType
$sel:maximumOnDemandCapacityUnits:ComputeLimits' :: ComputeLimits -> Maybe Int
$sel:maximumCoreCapacityUnits:ComputeLimits' :: ComputeLimits -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
maximumCoreCapacityUnits
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
maximumOnDemandCapacityUnits
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ComputeLimitsUnitType
unitType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
minimumCapacityUnits
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
maximumCapacityUnits

instance Data.ToJSON ComputeLimits where
  toJSON :: ComputeLimits -> Value
toJSON ComputeLimits' {Int
Maybe Int
ComputeLimitsUnitType
maximumCapacityUnits :: Int
minimumCapacityUnits :: Int
unitType :: ComputeLimitsUnitType
maximumOnDemandCapacityUnits :: Maybe Int
maximumCoreCapacityUnits :: Maybe Int
$sel:maximumCapacityUnits:ComputeLimits' :: ComputeLimits -> Int
$sel:minimumCapacityUnits:ComputeLimits' :: ComputeLimits -> Int
$sel:unitType:ComputeLimits' :: ComputeLimits -> ComputeLimitsUnitType
$sel:maximumOnDemandCapacityUnits:ComputeLimits' :: ComputeLimits -> Maybe Int
$sel:maximumCoreCapacityUnits:ComputeLimits' :: ComputeLimits -> Maybe Int
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"MaximumCoreCapacityUnits" 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 Int
maximumCoreCapacityUnits,
            (Key
"MaximumOnDemandCapacityUnits" 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 Int
maximumOnDemandCapacityUnits,
            forall a. a -> Maybe a
Prelude.Just (Key
"UnitType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ComputeLimitsUnitType
unitType),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"MinimumCapacityUnits"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Int
minimumCapacityUnits
              ),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"MaximumCapacityUnits"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Int
maximumCapacityUnits
              )
          ]
      )