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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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.
    --
    -- For certain resources, the minimum value allowed is 0. This includes
    -- Lambda provisioned concurrency, Spot Fleet, ECS services, Aurora DB
    -- clusters, EMR clusters, and custom resources. For all other resources,
    -- the minimum value allowed is 1.
    ScalableTargetAction -> Maybe Int
minCapacity :: Prelude.Maybe Prelude.Int
  }
  deriving (ScalableTargetAction -> ScalableTargetAction -> Bool
(ScalableTargetAction -> ScalableTargetAction -> Bool)
-> (ScalableTargetAction -> ScalableTargetAction -> Bool)
-> Eq ScalableTargetAction
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]
(Int -> ReadS ScalableTargetAction)
-> ReadS [ScalableTargetAction]
-> ReadPrec ScalableTargetAction
-> ReadPrec [ScalableTargetAction]
-> Read 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
(Int -> ScalableTargetAction -> ShowS)
-> (ScalableTargetAction -> String)
-> ([ScalableTargetAction] -> ShowS)
-> Show ScalableTargetAction
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. ScalableTargetAction -> Rep ScalableTargetAction x)
-> (forall x. Rep ScalableTargetAction x -> ScalableTargetAction)
-> Generic ScalableTargetAction
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.
--
-- For certain resources, the minimum value allowed is 0. This includes
-- Lambda provisioned concurrency, Spot Fleet, ECS services, Aurora DB
-- clusters, EMR clusters, and custom resources. For all other resources,
-- the minimum value allowed is 1.
newScalableTargetAction ::
  ScalableTargetAction
newScalableTargetAction :: ScalableTargetAction
newScalableTargetAction =
  ScalableTargetAction' :: Maybe Int -> Maybe Int -> ScalableTargetAction
ScalableTargetAction'
    { $sel:maxCapacity:ScalableTargetAction' :: Maybe Int
maxCapacity =
        Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:minCapacity:ScalableTargetAction' :: Maybe Int
minCapacity = Maybe Int
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 :: (Maybe Int -> f (Maybe Int))
-> ScalableTargetAction -> f ScalableTargetAction
scalableTargetAction_maxCapacity = (ScalableTargetAction -> Maybe Int)
-> (ScalableTargetAction -> Maybe Int -> ScalableTargetAction)
-> Lens
     ScalableTargetAction ScalableTargetAction (Maybe Int) (Maybe Int)
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.
--
-- For certain resources, the minimum value allowed is 0. This includes
-- Lambda provisioned concurrency, Spot Fleet, ECS services, Aurora DB
-- clusters, EMR clusters, and custom resources. For all other resources,
-- the minimum value allowed is 1.
scalableTargetAction_minCapacity :: Lens.Lens' ScalableTargetAction (Prelude.Maybe Prelude.Int)
scalableTargetAction_minCapacity :: (Maybe Int -> f (Maybe Int))
-> ScalableTargetAction -> f ScalableTargetAction
scalableTargetAction_minCapacity = (ScalableTargetAction -> Maybe Int)
-> (ScalableTargetAction -> Maybe Int -> ScalableTargetAction)
-> Lens
     ScalableTargetAction ScalableTargetAction (Maybe Int) (Maybe Int)
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 Core.FromJSON ScalableTargetAction where
  parseJSON :: Value -> Parser ScalableTargetAction
parseJSON =
    String
-> (Object -> Parser ScalableTargetAction)
-> Value
-> Parser ScalableTargetAction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ScalableTargetAction"
      ( \Object
x ->
          Maybe Int -> Maybe Int -> ScalableTargetAction
ScalableTargetAction'
            (Maybe Int -> Maybe Int -> ScalableTargetAction)
-> Parser (Maybe Int) -> Parser (Maybe Int -> ScalableTargetAction)
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
"MaxCapacity")
            Parser (Maybe Int -> ScalableTargetAction)
-> Parser (Maybe Int) -> Parser ScalableTargetAction
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
"MinCapacity")
      )

instance Prelude.Hashable ScalableTargetAction

instance Prelude.NFData ScalableTargetAction

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"MaxCapacity" 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
maxCapacity,
            (Text
"MinCapacity" 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
minCapacity
          ]
      )