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

import qualified Amazonka.Core as Core
import Amazonka.EMR.Types.ComputeLimitsUnitType
import qualified Amazonka.Lens as Lens
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 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 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 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
(ComputeLimits -> ComputeLimits -> Bool)
-> (ComputeLimits -> ComputeLimits -> Bool) -> Eq ComputeLimits
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]
(Int -> ReadS ComputeLimits)
-> ReadS [ComputeLimits]
-> ReadPrec ComputeLimits
-> ReadPrec [ComputeLimits]
-> Read 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
(Int -> ComputeLimits -> ShowS)
-> (ComputeLimits -> String)
-> ([ComputeLimits] -> ShowS)
-> Show ComputeLimits
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. ComputeLimits -> Rep ComputeLimits x)
-> (forall x. Rep ComputeLimits x -> ComputeLimits)
-> Generic ComputeLimits
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:
--
-- '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.
--
-- '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.
--
-- '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' :: Maybe Int
-> Maybe Int
-> ComputeLimitsUnitType
-> Int
-> Int
-> ComputeLimits
ComputeLimits'
      { $sel:maximumOnDemandCapacityUnits:ComputeLimits' :: Maybe Int
maximumOnDemandCapacityUnits =
          Maybe Int
forall a. Maybe a
Prelude.Nothing,
        $sel:maximumCoreCapacityUnits:ComputeLimits' :: Maybe Int
maximumCoreCapacityUnits = Maybe Int
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 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 :: (Maybe Int -> f (Maybe Int)) -> ComputeLimits -> f ComputeLimits
computeLimits_maximumOnDemandCapacityUnits = (ComputeLimits -> Maybe Int)
-> (ComputeLimits -> Maybe Int -> ComputeLimits)
-> Lens ComputeLimits ComputeLimits (Maybe Int) (Maybe Int)
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 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 :: (Maybe Int -> f (Maybe Int)) -> ComputeLimits -> f ComputeLimits
computeLimits_maximumCoreCapacityUnits = (ComputeLimits -> Maybe Int)
-> (ComputeLimits -> Maybe Int -> ComputeLimits)
-> Lens ComputeLimits ComputeLimits (Maybe Int) (Maybe Int)
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 unit type used for specifying a managed scaling policy.
computeLimits_unitType :: Lens.Lens' ComputeLimits ComputeLimitsUnitType
computeLimits_unitType :: (ComputeLimitsUnitType -> f ComputeLimitsUnitType)
-> ComputeLimits -> f ComputeLimits
computeLimits_unitType = (ComputeLimits -> ComputeLimitsUnitType)
-> (ComputeLimits -> ComputeLimitsUnitType -> ComputeLimits)
-> Lens
     ComputeLimits
     ComputeLimits
     ComputeLimitsUnitType
     ComputeLimitsUnitType
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 :: (Int -> f Int) -> ComputeLimits -> f ComputeLimits
computeLimits_minimumCapacityUnits = (ComputeLimits -> Int)
-> (ComputeLimits -> Int -> ComputeLimits)
-> Lens ComputeLimits ComputeLimits Int Int
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 :: (Int -> f Int) -> ComputeLimits -> f ComputeLimits
computeLimits_maximumCapacityUnits = (ComputeLimits -> Int)
-> (ComputeLimits -> Int -> ComputeLimits)
-> Lens ComputeLimits ComputeLimits Int Int
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 Core.FromJSON ComputeLimits where
  parseJSON :: Value -> Parser ComputeLimits
parseJSON =
    String
-> (Object -> Parser ComputeLimits)
-> Value
-> Parser ComputeLimits
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ComputeLimits"
      ( \Object
x ->
          Maybe Int
-> Maybe Int
-> ComputeLimitsUnitType
-> Int
-> Int
-> ComputeLimits
ComputeLimits'
            (Maybe Int
 -> Maybe Int
 -> ComputeLimitsUnitType
 -> Int
 -> Int
 -> ComputeLimits)
-> Parser (Maybe Int)
-> Parser
     (Maybe Int -> ComputeLimitsUnitType -> Int -> Int -> ComputeLimits)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MaximumOnDemandCapacityUnits")
            Parser
  (Maybe Int -> ComputeLimitsUnitType -> Int -> Int -> ComputeLimits)
-> Parser (Maybe Int)
-> Parser (ComputeLimitsUnitType -> Int -> Int -> ComputeLimits)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MaximumCoreCapacityUnits")
            Parser (ComputeLimitsUnitType -> Int -> Int -> ComputeLimits)
-> Parser ComputeLimitsUnitType
-> Parser (Int -> Int -> ComputeLimits)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ComputeLimitsUnitType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"UnitType")
            Parser (Int -> Int -> ComputeLimits)
-> Parser Int -> Parser (Int -> ComputeLimits)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Int
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"MinimumCapacityUnits")
            Parser (Int -> ComputeLimits) -> Parser Int -> Parser ComputeLimits
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Int
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"MaximumCapacityUnits")
      )

instance Prelude.Hashable ComputeLimits

instance Prelude.NFData ComputeLimits

instance Core.ToJSON ComputeLimits where
  toJSON :: ComputeLimits -> Value
toJSON ComputeLimits' {Int
Maybe Int
ComputeLimitsUnitType
maximumCapacityUnits :: Int
minimumCapacityUnits :: Int
unitType :: ComputeLimitsUnitType
maximumCoreCapacityUnits :: Maybe Int
maximumOnDemandCapacityUnits :: Maybe Int
$sel:maximumCapacityUnits:ComputeLimits' :: ComputeLimits -> Int
$sel:minimumCapacityUnits:ComputeLimits' :: ComputeLimits -> Int
$sel:unitType:ComputeLimits' :: ComputeLimits -> ComputeLimitsUnitType
$sel:maximumCoreCapacityUnits:ComputeLimits' :: ComputeLimits -> Maybe Int
$sel:maximumOnDemandCapacityUnits:ComputeLimits' :: ComputeLimits -> Maybe Int
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"MaximumOnDemandCapacityUnits" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
maximumOnDemandCapacityUnits,
            (Text
"MaximumCoreCapacityUnits" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
maximumCoreCapacityUnits,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"UnitType" Text -> ComputeLimitsUnitType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ComputeLimitsUnitType
unitType),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"MinimumCapacityUnits"
                  Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Int
minimumCapacityUnits
              ),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"MaximumCapacityUnits"
                  Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Int
maximumCapacityUnits
              )
          ]
      )