{-# 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.ManagedScalingPolicy
-- 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.ManagedScalingPolicy 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.ComputeLimits
import qualified Amazonka.Prelude as Prelude

-- | Managed scaling policy for an Amazon EMR cluster. The policy specifies
-- the limits for resources that can be added or terminated from a cluster.
-- The policy only applies to the core and task nodes. The master node
-- cannot be scaled after initial configuration.
--
-- /See:/ 'newManagedScalingPolicy' smart constructor.
data ManagedScalingPolicy = ManagedScalingPolicy'
  { -- | The EC2 unit limits for a managed scaling policy. The managed scaling
    -- activity of a cluster is not allowed to go above or below these limits.
    -- The limit only applies to the core and task nodes. The master node
    -- cannot be scaled after initial configuration.
    ManagedScalingPolicy -> Maybe ComputeLimits
computeLimits :: Prelude.Maybe ComputeLimits
  }
  deriving (ManagedScalingPolicy -> ManagedScalingPolicy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ManagedScalingPolicy -> ManagedScalingPolicy -> Bool
$c/= :: ManagedScalingPolicy -> ManagedScalingPolicy -> Bool
== :: ManagedScalingPolicy -> ManagedScalingPolicy -> Bool
$c== :: ManagedScalingPolicy -> ManagedScalingPolicy -> Bool
Prelude.Eq, ReadPrec [ManagedScalingPolicy]
ReadPrec ManagedScalingPolicy
Int -> ReadS ManagedScalingPolicy
ReadS [ManagedScalingPolicy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ManagedScalingPolicy]
$creadListPrec :: ReadPrec [ManagedScalingPolicy]
readPrec :: ReadPrec ManagedScalingPolicy
$creadPrec :: ReadPrec ManagedScalingPolicy
readList :: ReadS [ManagedScalingPolicy]
$creadList :: ReadS [ManagedScalingPolicy]
readsPrec :: Int -> ReadS ManagedScalingPolicy
$creadsPrec :: Int -> ReadS ManagedScalingPolicy
Prelude.Read, Int -> ManagedScalingPolicy -> ShowS
[ManagedScalingPolicy] -> ShowS
ManagedScalingPolicy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ManagedScalingPolicy] -> ShowS
$cshowList :: [ManagedScalingPolicy] -> ShowS
show :: ManagedScalingPolicy -> String
$cshow :: ManagedScalingPolicy -> String
showsPrec :: Int -> ManagedScalingPolicy -> ShowS
$cshowsPrec :: Int -> ManagedScalingPolicy -> ShowS
Prelude.Show, forall x. Rep ManagedScalingPolicy x -> ManagedScalingPolicy
forall x. ManagedScalingPolicy -> Rep ManagedScalingPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ManagedScalingPolicy x -> ManagedScalingPolicy
$cfrom :: forall x. ManagedScalingPolicy -> Rep ManagedScalingPolicy x
Prelude.Generic)

-- |
-- Create a value of 'ManagedScalingPolicy' 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:
--
-- 'computeLimits', 'managedScalingPolicy_computeLimits' - The EC2 unit limits for a managed scaling policy. The managed scaling
-- activity of a cluster is not allowed to go above or below these limits.
-- The limit only applies to the core and task nodes. The master node
-- cannot be scaled after initial configuration.
newManagedScalingPolicy ::
  ManagedScalingPolicy
newManagedScalingPolicy :: ManagedScalingPolicy
newManagedScalingPolicy =
  ManagedScalingPolicy'
    { $sel:computeLimits:ManagedScalingPolicy' :: Maybe ComputeLimits
computeLimits =
        forall a. Maybe a
Prelude.Nothing
    }

-- | The EC2 unit limits for a managed scaling policy. The managed scaling
-- activity of a cluster is not allowed to go above or below these limits.
-- The limit only applies to the core and task nodes. The master node
-- cannot be scaled after initial configuration.
managedScalingPolicy_computeLimits :: Lens.Lens' ManagedScalingPolicy (Prelude.Maybe ComputeLimits)
managedScalingPolicy_computeLimits :: Lens' ManagedScalingPolicy (Maybe ComputeLimits)
managedScalingPolicy_computeLimits = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ManagedScalingPolicy' {Maybe ComputeLimits
computeLimits :: Maybe ComputeLimits
$sel:computeLimits:ManagedScalingPolicy' :: ManagedScalingPolicy -> Maybe ComputeLimits
computeLimits} -> Maybe ComputeLimits
computeLimits) (\s :: ManagedScalingPolicy
s@ManagedScalingPolicy' {} Maybe ComputeLimits
a -> ManagedScalingPolicy
s {$sel:computeLimits:ManagedScalingPolicy' :: Maybe ComputeLimits
computeLimits = Maybe ComputeLimits
a} :: ManagedScalingPolicy)

instance Data.FromJSON ManagedScalingPolicy where
  parseJSON :: Value -> Parser ManagedScalingPolicy
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ManagedScalingPolicy"
      ( \Object
x ->
          Maybe ComputeLimits -> ManagedScalingPolicy
ManagedScalingPolicy'
            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
"ComputeLimits")
      )

instance Prelude.Hashable ManagedScalingPolicy where
  hashWithSalt :: Int -> ManagedScalingPolicy -> Int
hashWithSalt Int
_salt ManagedScalingPolicy' {Maybe ComputeLimits
computeLimits :: Maybe ComputeLimits
$sel:computeLimits:ManagedScalingPolicy' :: ManagedScalingPolicy -> Maybe ComputeLimits
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ComputeLimits
computeLimits

instance Prelude.NFData ManagedScalingPolicy where
  rnf :: ManagedScalingPolicy -> ()
rnf ManagedScalingPolicy' {Maybe ComputeLimits
computeLimits :: Maybe ComputeLimits
$sel:computeLimits:ManagedScalingPolicy' :: ManagedScalingPolicy -> Maybe ComputeLimits
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ComputeLimits
computeLimits

instance Data.ToJSON ManagedScalingPolicy where
  toJSON :: ManagedScalingPolicy -> Value
toJSON ManagedScalingPolicy' {Maybe ComputeLimits
computeLimits :: Maybe ComputeLimits
$sel:computeLimits:ManagedScalingPolicy' :: ManagedScalingPolicy -> Maybe ComputeLimits
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ComputeLimits" 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 ComputeLimits
computeLimits
          ]
      )