{-# 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.GameLift.Types.TargetTrackingConfiguration
-- 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.GameLift.Types.TargetTrackingConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | __This data type is used with the GameLift FleetIQ and game server
-- groups.__
--
-- Settings for a target-based scaling policy as part of a
-- GameServerGroupAutoScalingPolicy. These settings are used to create a
-- target-based policy that tracks the GameLift FleetIQ metric
-- @\"PercentUtilizedGameServers\"@ and specifies a target value for the
-- metric. As player usage changes, the policy triggers to adjust the game
-- server group capacity so that the metric returns to the target value.
--
-- /See:/ 'newTargetTrackingConfiguration' smart constructor.
data TargetTrackingConfiguration = TargetTrackingConfiguration'
  { -- | Desired value to use with a game server group target-based scaling
    -- policy.
    TargetTrackingConfiguration -> Double
targetValue :: Prelude.Double
  }
  deriving (TargetTrackingConfiguration -> TargetTrackingConfiguration -> Bool
(TargetTrackingConfiguration
 -> TargetTrackingConfiguration -> Bool)
-> (TargetTrackingConfiguration
    -> TargetTrackingConfiguration -> Bool)
-> Eq TargetTrackingConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TargetTrackingConfiguration -> TargetTrackingConfiguration -> Bool
$c/= :: TargetTrackingConfiguration -> TargetTrackingConfiguration -> Bool
== :: TargetTrackingConfiguration -> TargetTrackingConfiguration -> Bool
$c== :: TargetTrackingConfiguration -> TargetTrackingConfiguration -> Bool
Prelude.Eq, ReadPrec [TargetTrackingConfiguration]
ReadPrec TargetTrackingConfiguration
Int -> ReadS TargetTrackingConfiguration
ReadS [TargetTrackingConfiguration]
(Int -> ReadS TargetTrackingConfiguration)
-> ReadS [TargetTrackingConfiguration]
-> ReadPrec TargetTrackingConfiguration
-> ReadPrec [TargetTrackingConfiguration]
-> Read TargetTrackingConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TargetTrackingConfiguration]
$creadListPrec :: ReadPrec [TargetTrackingConfiguration]
readPrec :: ReadPrec TargetTrackingConfiguration
$creadPrec :: ReadPrec TargetTrackingConfiguration
readList :: ReadS [TargetTrackingConfiguration]
$creadList :: ReadS [TargetTrackingConfiguration]
readsPrec :: Int -> ReadS TargetTrackingConfiguration
$creadsPrec :: Int -> ReadS TargetTrackingConfiguration
Prelude.Read, Int -> TargetTrackingConfiguration -> ShowS
[TargetTrackingConfiguration] -> ShowS
TargetTrackingConfiguration -> String
(Int -> TargetTrackingConfiguration -> ShowS)
-> (TargetTrackingConfiguration -> String)
-> ([TargetTrackingConfiguration] -> ShowS)
-> Show TargetTrackingConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TargetTrackingConfiguration] -> ShowS
$cshowList :: [TargetTrackingConfiguration] -> ShowS
show :: TargetTrackingConfiguration -> String
$cshow :: TargetTrackingConfiguration -> String
showsPrec :: Int -> TargetTrackingConfiguration -> ShowS
$cshowsPrec :: Int -> TargetTrackingConfiguration -> ShowS
Prelude.Show, (forall x.
 TargetTrackingConfiguration -> Rep TargetTrackingConfiguration x)
-> (forall x.
    Rep TargetTrackingConfiguration x -> TargetTrackingConfiguration)
-> Generic TargetTrackingConfiguration
forall x.
Rep TargetTrackingConfiguration x -> TargetTrackingConfiguration
forall x.
TargetTrackingConfiguration -> Rep TargetTrackingConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep TargetTrackingConfiguration x -> TargetTrackingConfiguration
$cfrom :: forall x.
TargetTrackingConfiguration -> Rep TargetTrackingConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'TargetTrackingConfiguration' 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:
--
-- 'targetValue', 'targetTrackingConfiguration_targetValue' - Desired value to use with a game server group target-based scaling
-- policy.
newTargetTrackingConfiguration ::
  -- | 'targetValue'
  Prelude.Double ->
  TargetTrackingConfiguration
newTargetTrackingConfiguration :: Double -> TargetTrackingConfiguration
newTargetTrackingConfiguration Double
pTargetValue_ =
  TargetTrackingConfiguration' :: Double -> TargetTrackingConfiguration
TargetTrackingConfiguration'
    { $sel:targetValue:TargetTrackingConfiguration' :: Double
targetValue =
        Double
pTargetValue_
    }

-- | Desired value to use with a game server group target-based scaling
-- policy.
targetTrackingConfiguration_targetValue :: Lens.Lens' TargetTrackingConfiguration Prelude.Double
targetTrackingConfiguration_targetValue :: (Double -> f Double)
-> TargetTrackingConfiguration -> f TargetTrackingConfiguration
targetTrackingConfiguration_targetValue = (TargetTrackingConfiguration -> Double)
-> (TargetTrackingConfiguration
    -> Double -> TargetTrackingConfiguration)
-> Lens
     TargetTrackingConfiguration
     TargetTrackingConfiguration
     Double
     Double
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetTrackingConfiguration' {Double
targetValue :: Double
$sel:targetValue:TargetTrackingConfiguration' :: TargetTrackingConfiguration -> Double
targetValue} -> Double
targetValue) (\s :: TargetTrackingConfiguration
s@TargetTrackingConfiguration' {} Double
a -> TargetTrackingConfiguration
s {$sel:targetValue:TargetTrackingConfiguration' :: Double
targetValue = Double
a} :: TargetTrackingConfiguration)

instance Prelude.Hashable TargetTrackingConfiguration

instance Prelude.NFData TargetTrackingConfiguration

instance Core.ToJSON TargetTrackingConfiguration where
  toJSON :: TargetTrackingConfiguration -> Value
toJSON TargetTrackingConfiguration' {Double
targetValue :: Double
$sel:targetValue:TargetTrackingConfiguration' :: TargetTrackingConfiguration -> Double
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"TargetValue" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Double
targetValue)]
      )