{-# 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.ApplicationAutoScaling.Types.ScalableTargetAction
-- 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.ApplicationAutoScaling.Types.ScalableTargetAction 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

-- | Represents the minimum and maximum capacity for a scheduled action.
--
-- /See:/ 'newScalableTargetAction' smart constructor.
data ScalableTargetAction = ScalableTargetAction'
  { -- | The maximum capacity.
    --
    -- Although you can specify a large maximum capacity, note that service
    -- quotas may impose lower limits. Each service has its own default quotas
    -- for the maximum capacity of the resource. If you want to specify a
    -- higher limit, you can request an increase. For more information, consult
    -- the documentation for that service. For information about the default
    -- quotas for each service, see
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-service-information.html Service endpoints and quotas>
    -- in the /Amazon Web Services General Reference/.
    ScalableTargetAction -> Maybe Int
maxCapacity :: Prelude.Maybe Prelude.Int,
    -- | The minimum capacity.
    --
    -- When the scheduled action runs, the resource will have at least this
    -- much capacity, but it might have more depending on other settings, such
    -- as the target utilization level of a target tracking scaling policy.
    ScalableTargetAction -> Maybe Int
minCapacity :: Prelude.Maybe Prelude.Int
  }
  deriving (ScalableTargetAction -> ScalableTargetAction -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ScalableTargetAction -> ScalableTargetAction -> Bool
$c/= :: ScalableTargetAction -> ScalableTargetAction -> Bool
== :: ScalableTargetAction -> ScalableTargetAction -> Bool
$c== :: ScalableTargetAction -> ScalableTargetAction -> Bool
Prelude.Eq, ReadPrec [ScalableTargetAction]
ReadPrec ScalableTargetAction
Int -> ReadS ScalableTargetAction
ReadS [ScalableTargetAction]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ScalableTargetAction]
$creadListPrec :: ReadPrec [ScalableTargetAction]
readPrec :: ReadPrec ScalableTargetAction
$creadPrec :: ReadPrec ScalableTargetAction
readList :: ReadS [ScalableTargetAction]
$creadList :: ReadS [ScalableTargetAction]
readsPrec :: Int -> ReadS ScalableTargetAction
$creadsPrec :: Int -> ReadS ScalableTargetAction
Prelude.Read, Int -> ScalableTargetAction -> ShowS
[ScalableTargetAction] -> ShowS
ScalableTargetAction -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ScalableTargetAction] -> ShowS
$cshowList :: [ScalableTargetAction] -> ShowS
show :: ScalableTargetAction -> String
$cshow :: ScalableTargetAction -> String
showsPrec :: Int -> ScalableTargetAction -> ShowS
$cshowsPrec :: Int -> ScalableTargetAction -> ShowS
Prelude.Show, forall x. Rep ScalableTargetAction x -> ScalableTargetAction
forall x. ScalableTargetAction -> Rep ScalableTargetAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ScalableTargetAction x -> ScalableTargetAction
$cfrom :: forall x. ScalableTargetAction -> Rep ScalableTargetAction x
Prelude.Generic)

-- |
-- Create a value of 'ScalableTargetAction' 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:
--
-- 'maxCapacity', 'scalableTargetAction_maxCapacity' - The maximum capacity.
--
-- Although you can specify a large maximum capacity, note that service
-- quotas may impose lower limits. Each service has its own default quotas
-- for the maximum capacity of the resource. If you want to specify a
-- higher limit, you can request an increase. For more information, consult
-- the documentation for that service. For information about the default
-- quotas for each service, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-service-information.html Service endpoints and quotas>
-- in the /Amazon Web Services General Reference/.
--
-- 'minCapacity', 'scalableTargetAction_minCapacity' - The minimum capacity.
--
-- When the scheduled action runs, the resource will have at least this
-- much capacity, but it might have more depending on other settings, such
-- as the target utilization level of a target tracking scaling policy.
newScalableTargetAction ::
  ScalableTargetAction
newScalableTargetAction :: ScalableTargetAction
newScalableTargetAction =
  ScalableTargetAction'
    { $sel:maxCapacity:ScalableTargetAction' :: Maybe Int
maxCapacity =
        forall a. Maybe a
Prelude.Nothing,
      $sel:minCapacity:ScalableTargetAction' :: Maybe Int
minCapacity = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum capacity.
--
-- Although you can specify a large maximum capacity, note that service
-- quotas may impose lower limits. Each service has its own default quotas
-- for the maximum capacity of the resource. If you want to specify a
-- higher limit, you can request an increase. For more information, consult
-- the documentation for that service. For information about the default
-- quotas for each service, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-service-information.html Service endpoints and quotas>
-- in the /Amazon Web Services General Reference/.
scalableTargetAction_maxCapacity :: Lens.Lens' ScalableTargetAction (Prelude.Maybe Prelude.Int)
scalableTargetAction_maxCapacity :: Lens' ScalableTargetAction (Maybe Int)
scalableTargetAction_maxCapacity = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalableTargetAction' {Maybe Int
maxCapacity :: Maybe Int
$sel:maxCapacity:ScalableTargetAction' :: ScalableTargetAction -> Maybe Int
maxCapacity} -> Maybe Int
maxCapacity) (\s :: ScalableTargetAction
s@ScalableTargetAction' {} Maybe Int
a -> ScalableTargetAction
s {$sel:maxCapacity:ScalableTargetAction' :: Maybe Int
maxCapacity = Maybe Int
a} :: ScalableTargetAction)

-- | The minimum capacity.
--
-- When the scheduled action runs, the resource will have at least this
-- much capacity, but it might have more depending on other settings, such
-- as the target utilization level of a target tracking scaling policy.
scalableTargetAction_minCapacity :: Lens.Lens' ScalableTargetAction (Prelude.Maybe Prelude.Int)
scalableTargetAction_minCapacity :: Lens' ScalableTargetAction (Maybe Int)
scalableTargetAction_minCapacity = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalableTargetAction' {Maybe Int
minCapacity :: Maybe Int
$sel:minCapacity:ScalableTargetAction' :: ScalableTargetAction -> Maybe Int
minCapacity} -> Maybe Int
minCapacity) (\s :: ScalableTargetAction
s@ScalableTargetAction' {} Maybe Int
a -> ScalableTargetAction
s {$sel:minCapacity:ScalableTargetAction' :: Maybe Int
minCapacity = Maybe Int
a} :: ScalableTargetAction)

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

instance Prelude.Hashable ScalableTargetAction where
  hashWithSalt :: Int -> ScalableTargetAction -> Int
hashWithSalt Int
_salt ScalableTargetAction' {Maybe Int
minCapacity :: Maybe Int
maxCapacity :: Maybe Int
$sel:minCapacity:ScalableTargetAction' :: ScalableTargetAction -> Maybe Int
$sel:maxCapacity:ScalableTargetAction' :: ScalableTargetAction -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
maxCapacity
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
minCapacity

instance Prelude.NFData ScalableTargetAction where
  rnf :: ScalableTargetAction -> ()
rnf ScalableTargetAction' {Maybe Int
minCapacity :: Maybe Int
maxCapacity :: Maybe Int
$sel:minCapacity:ScalableTargetAction' :: ScalableTargetAction -> Maybe Int
$sel:maxCapacity:ScalableTargetAction' :: ScalableTargetAction -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
maxCapacity
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
minCapacity

instance Data.ToJSON ScalableTargetAction where
  toJSON :: ScalableTargetAction -> Value
toJSON ScalableTargetAction' {Maybe Int
minCapacity :: Maybe Int
maxCapacity :: Maybe Int
$sel:minCapacity:ScalableTargetAction' :: ScalableTargetAction -> Maybe Int
$sel:maxCapacity:ScalableTargetAction' :: ScalableTargetAction -> Maybe Int
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"MaxCapacity" 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
maxCapacity,
            (Key
"MinCapacity" 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
minCapacity
          ]
      )