{-# 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.NotScaledReason
-- 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.NotScaledReason 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

-- | Describes the reason for an activity that isn\'t scaled (/not scaled
-- activity/), in machine-readable format. For help interpreting the not
-- scaled reason details, see
-- <https://docs.aws.amazon.com/autoscaling/application/userguide/application-auto-scaling-scaling-activities.html Scaling activities for Application Auto Scaling>.
--
-- /See:/ 'newNotScaledReason' smart constructor.
data NotScaledReason = NotScaledReason'
  { -- | The current capacity.
    NotScaledReason -> Maybe Int
currentCapacity :: Prelude.Maybe Prelude.Int,
    -- | The maximum capacity.
    NotScaledReason -> Maybe Int
maxCapacity :: Prelude.Maybe Prelude.Int,
    -- | The minimum capacity.
    NotScaledReason -> Maybe Int
minCapacity :: Prelude.Maybe Prelude.Int,
    -- | A code that represents the reason for not scaling.
    --
    -- Valid values:
    --
    -- -   AutoScalingAnticipatedFlapping
    --
    -- -   TargetServicePutResourceAsUnscalable
    --
    -- -   AlreadyAtMaxCapacity
    --
    -- -   AlreadyAtMinCapacity
    --
    -- -   AlreadyAtDesiredCapacity
    NotScaledReason -> Text
code :: Prelude.Text
  }
  deriving (NotScaledReason -> NotScaledReason -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NotScaledReason -> NotScaledReason -> Bool
$c/= :: NotScaledReason -> NotScaledReason -> Bool
== :: NotScaledReason -> NotScaledReason -> Bool
$c== :: NotScaledReason -> NotScaledReason -> Bool
Prelude.Eq, ReadPrec [NotScaledReason]
ReadPrec NotScaledReason
Int -> ReadS NotScaledReason
ReadS [NotScaledReason]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NotScaledReason]
$creadListPrec :: ReadPrec [NotScaledReason]
readPrec :: ReadPrec NotScaledReason
$creadPrec :: ReadPrec NotScaledReason
readList :: ReadS [NotScaledReason]
$creadList :: ReadS [NotScaledReason]
readsPrec :: Int -> ReadS NotScaledReason
$creadsPrec :: Int -> ReadS NotScaledReason
Prelude.Read, Int -> NotScaledReason -> ShowS
[NotScaledReason] -> ShowS
NotScaledReason -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NotScaledReason] -> ShowS
$cshowList :: [NotScaledReason] -> ShowS
show :: NotScaledReason -> String
$cshow :: NotScaledReason -> String
showsPrec :: Int -> NotScaledReason -> ShowS
$cshowsPrec :: Int -> NotScaledReason -> ShowS
Prelude.Show, forall x. Rep NotScaledReason x -> NotScaledReason
forall x. NotScaledReason -> Rep NotScaledReason x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NotScaledReason x -> NotScaledReason
$cfrom :: forall x. NotScaledReason -> Rep NotScaledReason x
Prelude.Generic)

-- |
-- Create a value of 'NotScaledReason' 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:
--
-- 'currentCapacity', 'notScaledReason_currentCapacity' - The current capacity.
--
-- 'maxCapacity', 'notScaledReason_maxCapacity' - The maximum capacity.
--
-- 'minCapacity', 'notScaledReason_minCapacity' - The minimum capacity.
--
-- 'code', 'notScaledReason_code' - A code that represents the reason for not scaling.
--
-- Valid values:
--
-- -   AutoScalingAnticipatedFlapping
--
-- -   TargetServicePutResourceAsUnscalable
--
-- -   AlreadyAtMaxCapacity
--
-- -   AlreadyAtMinCapacity
--
-- -   AlreadyAtDesiredCapacity
newNotScaledReason ::
  -- | 'code'
  Prelude.Text ->
  NotScaledReason
newNotScaledReason :: Text -> NotScaledReason
newNotScaledReason Text
pCode_ =
  NotScaledReason'
    { $sel:currentCapacity:NotScaledReason' :: Maybe Int
currentCapacity = forall a. Maybe a
Prelude.Nothing,
      $sel:maxCapacity:NotScaledReason' :: Maybe Int
maxCapacity = forall a. Maybe a
Prelude.Nothing,
      $sel:minCapacity:NotScaledReason' :: Maybe Int
minCapacity = forall a. Maybe a
Prelude.Nothing,
      $sel:code:NotScaledReason' :: Text
code = Text
pCode_
    }

-- | The current capacity.
notScaledReason_currentCapacity :: Lens.Lens' NotScaledReason (Prelude.Maybe Prelude.Int)
notScaledReason_currentCapacity :: Lens' NotScaledReason (Maybe Int)
notScaledReason_currentCapacity = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotScaledReason' {Maybe Int
currentCapacity :: Maybe Int
$sel:currentCapacity:NotScaledReason' :: NotScaledReason -> Maybe Int
currentCapacity} -> Maybe Int
currentCapacity) (\s :: NotScaledReason
s@NotScaledReason' {} Maybe Int
a -> NotScaledReason
s {$sel:currentCapacity:NotScaledReason' :: Maybe Int
currentCapacity = Maybe Int
a} :: NotScaledReason)

-- | The maximum capacity.
notScaledReason_maxCapacity :: Lens.Lens' NotScaledReason (Prelude.Maybe Prelude.Int)
notScaledReason_maxCapacity :: Lens' NotScaledReason (Maybe Int)
notScaledReason_maxCapacity = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotScaledReason' {Maybe Int
maxCapacity :: Maybe Int
$sel:maxCapacity:NotScaledReason' :: NotScaledReason -> Maybe Int
maxCapacity} -> Maybe Int
maxCapacity) (\s :: NotScaledReason
s@NotScaledReason' {} Maybe Int
a -> NotScaledReason
s {$sel:maxCapacity:NotScaledReason' :: Maybe Int
maxCapacity = Maybe Int
a} :: NotScaledReason)

-- | The minimum capacity.
notScaledReason_minCapacity :: Lens.Lens' NotScaledReason (Prelude.Maybe Prelude.Int)
notScaledReason_minCapacity :: Lens' NotScaledReason (Maybe Int)
notScaledReason_minCapacity = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotScaledReason' {Maybe Int
minCapacity :: Maybe Int
$sel:minCapacity:NotScaledReason' :: NotScaledReason -> Maybe Int
minCapacity} -> Maybe Int
minCapacity) (\s :: NotScaledReason
s@NotScaledReason' {} Maybe Int
a -> NotScaledReason
s {$sel:minCapacity:NotScaledReason' :: Maybe Int
minCapacity = Maybe Int
a} :: NotScaledReason)

-- | A code that represents the reason for not scaling.
--
-- Valid values:
--
-- -   AutoScalingAnticipatedFlapping
--
-- -   TargetServicePutResourceAsUnscalable
--
-- -   AlreadyAtMaxCapacity
--
-- -   AlreadyAtMinCapacity
--
-- -   AlreadyAtDesiredCapacity
notScaledReason_code :: Lens.Lens' NotScaledReason Prelude.Text
notScaledReason_code :: Lens' NotScaledReason Text
notScaledReason_code = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotScaledReason' {Text
code :: Text
$sel:code:NotScaledReason' :: NotScaledReason -> Text
code} -> Text
code) (\s :: NotScaledReason
s@NotScaledReason' {} Text
a -> NotScaledReason
s {$sel:code:NotScaledReason' :: Text
code = Text
a} :: NotScaledReason)

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

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

instance Prelude.NFData NotScaledReason where
  rnf :: NotScaledReason -> ()
rnf NotScaledReason' {Maybe Int
Text
code :: Text
minCapacity :: Maybe Int
maxCapacity :: Maybe Int
currentCapacity :: Maybe Int
$sel:code:NotScaledReason' :: NotScaledReason -> Text
$sel:minCapacity:NotScaledReason' :: NotScaledReason -> Maybe Int
$sel:maxCapacity:NotScaledReason' :: NotScaledReason -> Maybe Int
$sel:currentCapacity:NotScaledReason' :: NotScaledReason -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
currentCapacity
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
code