{-# 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.EC2InstanceCounts
-- 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.EC2InstanceCounts where

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

-- | Resource capacity settings. Fleet capacity is measured in EC2 instances.
-- Pending and terminating counts are non-zero when the fleet capacity is
-- adjusting to a scaling event or if access to resources is temporarily
-- affected.
--
-- EC2 instance counts are part of FleetCapacity.
--
-- /See:/ 'newEC2InstanceCounts' smart constructor.
data EC2InstanceCounts = EC2InstanceCounts'
  { -- | Number of active instances that are not currently hosting a game
    -- session.
    EC2InstanceCounts -> Maybe Natural
idle :: Prelude.Maybe Prelude.Natural,
    -- | Number of instances that are no longer active but haven\'t yet been
    -- terminated.
    EC2InstanceCounts -> Maybe Natural
terminating :: Prelude.Maybe Prelude.Natural,
    -- | Number of instances that are starting but not yet active.
    EC2InstanceCounts -> Maybe Natural
pending :: Prelude.Maybe Prelude.Natural,
    -- | The maximum instance count value allowed.
    EC2InstanceCounts -> Maybe Natural
maximum :: Prelude.Maybe Prelude.Natural,
    -- | Ideal number of active instances. GameLift will always try to maintain
    -- the desired number of instances. Capacity is scaled up or down by
    -- changing the desired instances.
    EC2InstanceCounts -> Maybe Natural
desired :: Prelude.Maybe Prelude.Natural,
    -- | The minimum instance count value allowed.
    EC2InstanceCounts -> Maybe Natural
minimum :: Prelude.Maybe Prelude.Natural,
    -- | Actual number of instances that are ready to host game sessions.
    EC2InstanceCounts -> Maybe Natural
active :: Prelude.Maybe Prelude.Natural
  }
  deriving (EC2InstanceCounts -> EC2InstanceCounts -> Bool
(EC2InstanceCounts -> EC2InstanceCounts -> Bool)
-> (EC2InstanceCounts -> EC2InstanceCounts -> Bool)
-> Eq EC2InstanceCounts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EC2InstanceCounts -> EC2InstanceCounts -> Bool
$c/= :: EC2InstanceCounts -> EC2InstanceCounts -> Bool
== :: EC2InstanceCounts -> EC2InstanceCounts -> Bool
$c== :: EC2InstanceCounts -> EC2InstanceCounts -> Bool
Prelude.Eq, ReadPrec [EC2InstanceCounts]
ReadPrec EC2InstanceCounts
Int -> ReadS EC2InstanceCounts
ReadS [EC2InstanceCounts]
(Int -> ReadS EC2InstanceCounts)
-> ReadS [EC2InstanceCounts]
-> ReadPrec EC2InstanceCounts
-> ReadPrec [EC2InstanceCounts]
-> Read EC2InstanceCounts
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EC2InstanceCounts]
$creadListPrec :: ReadPrec [EC2InstanceCounts]
readPrec :: ReadPrec EC2InstanceCounts
$creadPrec :: ReadPrec EC2InstanceCounts
readList :: ReadS [EC2InstanceCounts]
$creadList :: ReadS [EC2InstanceCounts]
readsPrec :: Int -> ReadS EC2InstanceCounts
$creadsPrec :: Int -> ReadS EC2InstanceCounts
Prelude.Read, Int -> EC2InstanceCounts -> ShowS
[EC2InstanceCounts] -> ShowS
EC2InstanceCounts -> String
(Int -> EC2InstanceCounts -> ShowS)
-> (EC2InstanceCounts -> String)
-> ([EC2InstanceCounts] -> ShowS)
-> Show EC2InstanceCounts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EC2InstanceCounts] -> ShowS
$cshowList :: [EC2InstanceCounts] -> ShowS
show :: EC2InstanceCounts -> String
$cshow :: EC2InstanceCounts -> String
showsPrec :: Int -> EC2InstanceCounts -> ShowS
$cshowsPrec :: Int -> EC2InstanceCounts -> ShowS
Prelude.Show, (forall x. EC2InstanceCounts -> Rep EC2InstanceCounts x)
-> (forall x. Rep EC2InstanceCounts x -> EC2InstanceCounts)
-> Generic EC2InstanceCounts
forall x. Rep EC2InstanceCounts x -> EC2InstanceCounts
forall x. EC2InstanceCounts -> Rep EC2InstanceCounts x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EC2InstanceCounts x -> EC2InstanceCounts
$cfrom :: forall x. EC2InstanceCounts -> Rep EC2InstanceCounts x
Prelude.Generic)

-- |
-- Create a value of 'EC2InstanceCounts' 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:
--
-- 'idle', 'eC2InstanceCounts_idle' - Number of active instances that are not currently hosting a game
-- session.
--
-- 'terminating', 'eC2InstanceCounts_terminating' - Number of instances that are no longer active but haven\'t yet been
-- terminated.
--
-- 'pending', 'eC2InstanceCounts_pending' - Number of instances that are starting but not yet active.
--
-- 'maximum', 'eC2InstanceCounts_maximum' - The maximum instance count value allowed.
--
-- 'desired', 'eC2InstanceCounts_desired' - Ideal number of active instances. GameLift will always try to maintain
-- the desired number of instances. Capacity is scaled up or down by
-- changing the desired instances.
--
-- 'minimum', 'eC2InstanceCounts_minimum' - The minimum instance count value allowed.
--
-- 'active', 'eC2InstanceCounts_active' - Actual number of instances that are ready to host game sessions.
newEC2InstanceCounts ::
  EC2InstanceCounts
newEC2InstanceCounts :: EC2InstanceCounts
newEC2InstanceCounts =
  EC2InstanceCounts' :: Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> EC2InstanceCounts
EC2InstanceCounts'
    { $sel:idle:EC2InstanceCounts' :: Maybe Natural
idle = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:terminating:EC2InstanceCounts' :: Maybe Natural
terminating = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:pending:EC2InstanceCounts' :: Maybe Natural
pending = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:maximum:EC2InstanceCounts' :: Maybe Natural
maximum = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:desired:EC2InstanceCounts' :: Maybe Natural
desired = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:minimum:EC2InstanceCounts' :: Maybe Natural
minimum = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:active:EC2InstanceCounts' :: Maybe Natural
active = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | Number of active instances that are not currently hosting a game
-- session.
eC2InstanceCounts_idle :: Lens.Lens' EC2InstanceCounts (Prelude.Maybe Prelude.Natural)
eC2InstanceCounts_idle :: (Maybe Natural -> f (Maybe Natural))
-> EC2InstanceCounts -> f EC2InstanceCounts
eC2InstanceCounts_idle = (EC2InstanceCounts -> Maybe Natural)
-> (EC2InstanceCounts -> Maybe Natural -> EC2InstanceCounts)
-> Lens
     EC2InstanceCounts EC2InstanceCounts (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EC2InstanceCounts' {Maybe Natural
idle :: Maybe Natural
$sel:idle:EC2InstanceCounts' :: EC2InstanceCounts -> Maybe Natural
idle} -> Maybe Natural
idle) (\s :: EC2InstanceCounts
s@EC2InstanceCounts' {} Maybe Natural
a -> EC2InstanceCounts
s {$sel:idle:EC2InstanceCounts' :: Maybe Natural
idle = Maybe Natural
a} :: EC2InstanceCounts)

-- | Number of instances that are no longer active but haven\'t yet been
-- terminated.
eC2InstanceCounts_terminating :: Lens.Lens' EC2InstanceCounts (Prelude.Maybe Prelude.Natural)
eC2InstanceCounts_terminating :: (Maybe Natural -> f (Maybe Natural))
-> EC2InstanceCounts -> f EC2InstanceCounts
eC2InstanceCounts_terminating = (EC2InstanceCounts -> Maybe Natural)
-> (EC2InstanceCounts -> Maybe Natural -> EC2InstanceCounts)
-> Lens
     EC2InstanceCounts EC2InstanceCounts (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EC2InstanceCounts' {Maybe Natural
terminating :: Maybe Natural
$sel:terminating:EC2InstanceCounts' :: EC2InstanceCounts -> Maybe Natural
terminating} -> Maybe Natural
terminating) (\s :: EC2InstanceCounts
s@EC2InstanceCounts' {} Maybe Natural
a -> EC2InstanceCounts
s {$sel:terminating:EC2InstanceCounts' :: Maybe Natural
terminating = Maybe Natural
a} :: EC2InstanceCounts)

-- | Number of instances that are starting but not yet active.
eC2InstanceCounts_pending :: Lens.Lens' EC2InstanceCounts (Prelude.Maybe Prelude.Natural)
eC2InstanceCounts_pending :: (Maybe Natural -> f (Maybe Natural))
-> EC2InstanceCounts -> f EC2InstanceCounts
eC2InstanceCounts_pending = (EC2InstanceCounts -> Maybe Natural)
-> (EC2InstanceCounts -> Maybe Natural -> EC2InstanceCounts)
-> Lens
     EC2InstanceCounts EC2InstanceCounts (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EC2InstanceCounts' {Maybe Natural
pending :: Maybe Natural
$sel:pending:EC2InstanceCounts' :: EC2InstanceCounts -> Maybe Natural
pending} -> Maybe Natural
pending) (\s :: EC2InstanceCounts
s@EC2InstanceCounts' {} Maybe Natural
a -> EC2InstanceCounts
s {$sel:pending:EC2InstanceCounts' :: Maybe Natural
pending = Maybe Natural
a} :: EC2InstanceCounts)

-- | The maximum instance count value allowed.
eC2InstanceCounts_maximum :: Lens.Lens' EC2InstanceCounts (Prelude.Maybe Prelude.Natural)
eC2InstanceCounts_maximum :: (Maybe Natural -> f (Maybe Natural))
-> EC2InstanceCounts -> f EC2InstanceCounts
eC2InstanceCounts_maximum = (EC2InstanceCounts -> Maybe Natural)
-> (EC2InstanceCounts -> Maybe Natural -> EC2InstanceCounts)
-> Lens
     EC2InstanceCounts EC2InstanceCounts (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EC2InstanceCounts' {Maybe Natural
maximum :: Maybe Natural
$sel:maximum:EC2InstanceCounts' :: EC2InstanceCounts -> Maybe Natural
maximum} -> Maybe Natural
maximum) (\s :: EC2InstanceCounts
s@EC2InstanceCounts' {} Maybe Natural
a -> EC2InstanceCounts
s {$sel:maximum:EC2InstanceCounts' :: Maybe Natural
maximum = Maybe Natural
a} :: EC2InstanceCounts)

-- | Ideal number of active instances. GameLift will always try to maintain
-- the desired number of instances. Capacity is scaled up or down by
-- changing the desired instances.
eC2InstanceCounts_desired :: Lens.Lens' EC2InstanceCounts (Prelude.Maybe Prelude.Natural)
eC2InstanceCounts_desired :: (Maybe Natural -> f (Maybe Natural))
-> EC2InstanceCounts -> f EC2InstanceCounts
eC2InstanceCounts_desired = (EC2InstanceCounts -> Maybe Natural)
-> (EC2InstanceCounts -> Maybe Natural -> EC2InstanceCounts)
-> Lens
     EC2InstanceCounts EC2InstanceCounts (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EC2InstanceCounts' {Maybe Natural
desired :: Maybe Natural
$sel:desired:EC2InstanceCounts' :: EC2InstanceCounts -> Maybe Natural
desired} -> Maybe Natural
desired) (\s :: EC2InstanceCounts
s@EC2InstanceCounts' {} Maybe Natural
a -> EC2InstanceCounts
s {$sel:desired:EC2InstanceCounts' :: Maybe Natural
desired = Maybe Natural
a} :: EC2InstanceCounts)

-- | The minimum instance count value allowed.
eC2InstanceCounts_minimum :: Lens.Lens' EC2InstanceCounts (Prelude.Maybe Prelude.Natural)
eC2InstanceCounts_minimum :: (Maybe Natural -> f (Maybe Natural))
-> EC2InstanceCounts -> f EC2InstanceCounts
eC2InstanceCounts_minimum = (EC2InstanceCounts -> Maybe Natural)
-> (EC2InstanceCounts -> Maybe Natural -> EC2InstanceCounts)
-> Lens
     EC2InstanceCounts EC2InstanceCounts (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EC2InstanceCounts' {Maybe Natural
minimum :: Maybe Natural
$sel:minimum:EC2InstanceCounts' :: EC2InstanceCounts -> Maybe Natural
minimum} -> Maybe Natural
minimum) (\s :: EC2InstanceCounts
s@EC2InstanceCounts' {} Maybe Natural
a -> EC2InstanceCounts
s {$sel:minimum:EC2InstanceCounts' :: Maybe Natural
minimum = Maybe Natural
a} :: EC2InstanceCounts)

-- | Actual number of instances that are ready to host game sessions.
eC2InstanceCounts_active :: Lens.Lens' EC2InstanceCounts (Prelude.Maybe Prelude.Natural)
eC2InstanceCounts_active :: (Maybe Natural -> f (Maybe Natural))
-> EC2InstanceCounts -> f EC2InstanceCounts
eC2InstanceCounts_active = (EC2InstanceCounts -> Maybe Natural)
-> (EC2InstanceCounts -> Maybe Natural -> EC2InstanceCounts)
-> Lens
     EC2InstanceCounts EC2InstanceCounts (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EC2InstanceCounts' {Maybe Natural
active :: Maybe Natural
$sel:active:EC2InstanceCounts' :: EC2InstanceCounts -> Maybe Natural
active} -> Maybe Natural
active) (\s :: EC2InstanceCounts
s@EC2InstanceCounts' {} Maybe Natural
a -> EC2InstanceCounts
s {$sel:active:EC2InstanceCounts' :: Maybe Natural
active = Maybe Natural
a} :: EC2InstanceCounts)

instance Core.FromJSON EC2InstanceCounts where
  parseJSON :: Value -> Parser EC2InstanceCounts
parseJSON =
    String
-> (Object -> Parser EC2InstanceCounts)
-> Value
-> Parser EC2InstanceCounts
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EC2InstanceCounts"
      ( \Object
x ->
          Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> EC2InstanceCounts
EC2InstanceCounts'
            (Maybe Natural
 -> Maybe Natural
 -> Maybe Natural
 -> Maybe Natural
 -> Maybe Natural
 -> Maybe Natural
 -> Maybe Natural
 -> EC2InstanceCounts)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> EC2InstanceCounts)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"IDLE")
            Parser
  (Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> EC2InstanceCounts)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> EC2InstanceCounts)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TERMINATING")
            Parser
  (Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> EC2InstanceCounts)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> EC2InstanceCounts)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"PENDING")
            Parser
  (Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> EC2InstanceCounts)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Natural
      -> Maybe Natural -> Maybe Natural -> EC2InstanceCounts)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MAXIMUM")
            Parser
  (Maybe Natural
   -> Maybe Natural -> Maybe Natural -> EC2InstanceCounts)
-> Parser (Maybe Natural)
-> Parser (Maybe Natural -> Maybe Natural -> EC2InstanceCounts)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DESIRED")
            Parser (Maybe Natural -> Maybe Natural -> EC2InstanceCounts)
-> Parser (Maybe Natural)
-> Parser (Maybe Natural -> EC2InstanceCounts)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MINIMUM")
            Parser (Maybe Natural -> EC2InstanceCounts)
-> Parser (Maybe Natural) -> Parser EC2InstanceCounts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ACTIVE")
      )

instance Prelude.Hashable EC2InstanceCounts

instance Prelude.NFData EC2InstanceCounts