{-# 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.DynamoDB.Types.AutoScalingPolicyDescription
-- 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.DynamoDB.Types.AutoScalingPolicyDescription where

import qualified Amazonka.Core as Core
import Amazonka.DynamoDB.Types.AutoScalingTargetTrackingScalingPolicyConfigurationDescription
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents the properties of the scaling policy.
--
-- /See:/ 'newAutoScalingPolicyDescription' smart constructor.
data AutoScalingPolicyDescription = AutoScalingPolicyDescription'
  { -- | The name of the scaling policy.
    AutoScalingPolicyDescription -> Maybe Text
policyName :: Prelude.Maybe Prelude.Text,
    -- | Represents a target tracking scaling policy configuration.
    AutoScalingPolicyDescription
-> Maybe
     AutoScalingTargetTrackingScalingPolicyConfigurationDescription
targetTrackingScalingPolicyConfiguration :: Prelude.Maybe AutoScalingTargetTrackingScalingPolicyConfigurationDescription
  }
  deriving (AutoScalingPolicyDescription
-> AutoScalingPolicyDescription -> Bool
(AutoScalingPolicyDescription
 -> AutoScalingPolicyDescription -> Bool)
-> (AutoScalingPolicyDescription
    -> AutoScalingPolicyDescription -> Bool)
-> Eq AutoScalingPolicyDescription
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AutoScalingPolicyDescription
-> AutoScalingPolicyDescription -> Bool
$c/= :: AutoScalingPolicyDescription
-> AutoScalingPolicyDescription -> Bool
== :: AutoScalingPolicyDescription
-> AutoScalingPolicyDescription -> Bool
$c== :: AutoScalingPolicyDescription
-> AutoScalingPolicyDescription -> Bool
Prelude.Eq, ReadPrec [AutoScalingPolicyDescription]
ReadPrec AutoScalingPolicyDescription
Int -> ReadS AutoScalingPolicyDescription
ReadS [AutoScalingPolicyDescription]
(Int -> ReadS AutoScalingPolicyDescription)
-> ReadS [AutoScalingPolicyDescription]
-> ReadPrec AutoScalingPolicyDescription
-> ReadPrec [AutoScalingPolicyDescription]
-> Read AutoScalingPolicyDescription
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AutoScalingPolicyDescription]
$creadListPrec :: ReadPrec [AutoScalingPolicyDescription]
readPrec :: ReadPrec AutoScalingPolicyDescription
$creadPrec :: ReadPrec AutoScalingPolicyDescription
readList :: ReadS [AutoScalingPolicyDescription]
$creadList :: ReadS [AutoScalingPolicyDescription]
readsPrec :: Int -> ReadS AutoScalingPolicyDescription
$creadsPrec :: Int -> ReadS AutoScalingPolicyDescription
Prelude.Read, Int -> AutoScalingPolicyDescription -> ShowS
[AutoScalingPolicyDescription] -> ShowS
AutoScalingPolicyDescription -> String
(Int -> AutoScalingPolicyDescription -> ShowS)
-> (AutoScalingPolicyDescription -> String)
-> ([AutoScalingPolicyDescription] -> ShowS)
-> Show AutoScalingPolicyDescription
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AutoScalingPolicyDescription] -> ShowS
$cshowList :: [AutoScalingPolicyDescription] -> ShowS
show :: AutoScalingPolicyDescription -> String
$cshow :: AutoScalingPolicyDescription -> String
showsPrec :: Int -> AutoScalingPolicyDescription -> ShowS
$cshowsPrec :: Int -> AutoScalingPolicyDescription -> ShowS
Prelude.Show, (forall x.
 AutoScalingPolicyDescription -> Rep AutoScalingPolicyDescription x)
-> (forall x.
    Rep AutoScalingPolicyDescription x -> AutoScalingPolicyDescription)
-> Generic AutoScalingPolicyDescription
forall x.
Rep AutoScalingPolicyDescription x -> AutoScalingPolicyDescription
forall x.
AutoScalingPolicyDescription -> Rep AutoScalingPolicyDescription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AutoScalingPolicyDescription x -> AutoScalingPolicyDescription
$cfrom :: forall x.
AutoScalingPolicyDescription -> Rep AutoScalingPolicyDescription x
Prelude.Generic)

-- |
-- Create a value of 'AutoScalingPolicyDescription' 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:
--
-- 'policyName', 'autoScalingPolicyDescription_policyName' - The name of the scaling policy.
--
-- 'targetTrackingScalingPolicyConfiguration', 'autoScalingPolicyDescription_targetTrackingScalingPolicyConfiguration' - Represents a target tracking scaling policy configuration.
newAutoScalingPolicyDescription ::
  AutoScalingPolicyDescription
newAutoScalingPolicyDescription :: AutoScalingPolicyDescription
newAutoScalingPolicyDescription =
  AutoScalingPolicyDescription' :: Maybe Text
-> Maybe
     AutoScalingTargetTrackingScalingPolicyConfigurationDescription
-> AutoScalingPolicyDescription
AutoScalingPolicyDescription'
    { $sel:policyName:AutoScalingPolicyDescription' :: Maybe Text
policyName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:targetTrackingScalingPolicyConfiguration:AutoScalingPolicyDescription' :: Maybe
  AutoScalingTargetTrackingScalingPolicyConfigurationDescription
targetTrackingScalingPolicyConfiguration =
        Maybe
  AutoScalingTargetTrackingScalingPolicyConfigurationDescription
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the scaling policy.
autoScalingPolicyDescription_policyName :: Lens.Lens' AutoScalingPolicyDescription (Prelude.Maybe Prelude.Text)
autoScalingPolicyDescription_policyName :: (Maybe Text -> f (Maybe Text))
-> AutoScalingPolicyDescription -> f AutoScalingPolicyDescription
autoScalingPolicyDescription_policyName = (AutoScalingPolicyDescription -> Maybe Text)
-> (AutoScalingPolicyDescription
    -> Maybe Text -> AutoScalingPolicyDescription)
-> Lens
     AutoScalingPolicyDescription
     AutoScalingPolicyDescription
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoScalingPolicyDescription' {Maybe Text
policyName :: Maybe Text
$sel:policyName:AutoScalingPolicyDescription' :: AutoScalingPolicyDescription -> Maybe Text
policyName} -> Maybe Text
policyName) (\s :: AutoScalingPolicyDescription
s@AutoScalingPolicyDescription' {} Maybe Text
a -> AutoScalingPolicyDescription
s {$sel:policyName:AutoScalingPolicyDescription' :: Maybe Text
policyName = Maybe Text
a} :: AutoScalingPolicyDescription)

-- | Represents a target tracking scaling policy configuration.
autoScalingPolicyDescription_targetTrackingScalingPolicyConfiguration :: Lens.Lens' AutoScalingPolicyDescription (Prelude.Maybe AutoScalingTargetTrackingScalingPolicyConfigurationDescription)
autoScalingPolicyDescription_targetTrackingScalingPolicyConfiguration :: (Maybe
   AutoScalingTargetTrackingScalingPolicyConfigurationDescription
 -> f (Maybe
         AutoScalingTargetTrackingScalingPolicyConfigurationDescription))
-> AutoScalingPolicyDescription -> f AutoScalingPolicyDescription
autoScalingPolicyDescription_targetTrackingScalingPolicyConfiguration = (AutoScalingPolicyDescription
 -> Maybe
      AutoScalingTargetTrackingScalingPolicyConfigurationDescription)
-> (AutoScalingPolicyDescription
    -> Maybe
         AutoScalingTargetTrackingScalingPolicyConfigurationDescription
    -> AutoScalingPolicyDescription)
-> Lens
     AutoScalingPolicyDescription
     AutoScalingPolicyDescription
     (Maybe
        AutoScalingTargetTrackingScalingPolicyConfigurationDescription)
     (Maybe
        AutoScalingTargetTrackingScalingPolicyConfigurationDescription)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoScalingPolicyDescription' {Maybe
  AutoScalingTargetTrackingScalingPolicyConfigurationDescription
targetTrackingScalingPolicyConfiguration :: Maybe
  AutoScalingTargetTrackingScalingPolicyConfigurationDescription
$sel:targetTrackingScalingPolicyConfiguration:AutoScalingPolicyDescription' :: AutoScalingPolicyDescription
-> Maybe
     AutoScalingTargetTrackingScalingPolicyConfigurationDescription
targetTrackingScalingPolicyConfiguration} -> Maybe
  AutoScalingTargetTrackingScalingPolicyConfigurationDescription
targetTrackingScalingPolicyConfiguration) (\s :: AutoScalingPolicyDescription
s@AutoScalingPolicyDescription' {} Maybe
  AutoScalingTargetTrackingScalingPolicyConfigurationDescription
a -> AutoScalingPolicyDescription
s {$sel:targetTrackingScalingPolicyConfiguration:AutoScalingPolicyDescription' :: Maybe
  AutoScalingTargetTrackingScalingPolicyConfigurationDescription
targetTrackingScalingPolicyConfiguration = Maybe
  AutoScalingTargetTrackingScalingPolicyConfigurationDescription
a} :: AutoScalingPolicyDescription)

instance Core.FromJSON AutoScalingPolicyDescription where
  parseJSON :: Value -> Parser AutoScalingPolicyDescription
parseJSON =
    String
-> (Object -> Parser AutoScalingPolicyDescription)
-> Value
-> Parser AutoScalingPolicyDescription
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AutoScalingPolicyDescription"
      ( \Object
x ->
          Maybe Text
-> Maybe
     AutoScalingTargetTrackingScalingPolicyConfigurationDescription
-> AutoScalingPolicyDescription
AutoScalingPolicyDescription'
            (Maybe Text
 -> Maybe
      AutoScalingTargetTrackingScalingPolicyConfigurationDescription
 -> AutoScalingPolicyDescription)
-> Parser (Maybe Text)
-> Parser
     (Maybe
        AutoScalingTargetTrackingScalingPolicyConfigurationDescription
      -> AutoScalingPolicyDescription)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"PolicyName")
            Parser
  (Maybe
     AutoScalingTargetTrackingScalingPolicyConfigurationDescription
   -> AutoScalingPolicyDescription)
-> Parser
     (Maybe
        AutoScalingTargetTrackingScalingPolicyConfigurationDescription)
-> Parser AutoScalingPolicyDescription
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x
                            Object
-> Text
-> Parser
     (Maybe
        AutoScalingTargetTrackingScalingPolicyConfigurationDescription)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TargetTrackingScalingPolicyConfiguration"
                        )
      )

instance
  Prelude.Hashable
    AutoScalingPolicyDescription

instance Prelude.NFData AutoScalingPolicyDescription