{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.GameLift.Types.EC2InstanceCounts 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

-- | Resource capacity settings. Fleet capacity is measured in Amazon 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.
--
-- /See:/ 'newEC2InstanceCounts' smart constructor.
data EC2InstanceCounts = EC2InstanceCounts'
  { -- | Actual number of instances that are ready to host game sessions.
    EC2InstanceCounts -> Maybe Natural
active :: 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,
    -- | Number of active instances that are not currently hosting a game
    -- session.
    EC2InstanceCounts -> Maybe Natural
idle :: Prelude.Maybe Prelude.Natural,
    -- | The maximum instance count value allowed.
    EC2InstanceCounts -> Maybe Natural
maximum :: Prelude.Maybe Prelude.Natural,
    -- | The minimum instance count value allowed.
    EC2InstanceCounts -> Maybe Natural
minimum :: Prelude.Maybe Prelude.Natural,
    -- | Number of instances that are starting but not yet active.
    EC2InstanceCounts -> Maybe Natural
pending :: 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
  }
  deriving (EC2InstanceCounts -> EC2InstanceCounts -> Bool
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]
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
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. 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:
--
-- 'active', 'eC2InstanceCounts_active' - Actual number of instances that are ready to host game sessions.
--
-- '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.
--
-- 'idle', 'eC2InstanceCounts_idle' - Number of active instances that are not currently hosting a game
-- session.
--
-- 'maximum', 'eC2InstanceCounts_maximum' - The maximum instance count value allowed.
--
-- 'minimum', 'eC2InstanceCounts_minimum' - The minimum instance count value allowed.
--
-- 'pending', 'eC2InstanceCounts_pending' - Number of instances that are starting but not yet active.
--
-- 'terminating', 'eC2InstanceCounts_terminating' - Number of instances that are no longer active but haven\'t yet been
-- terminated.
newEC2InstanceCounts ::
  EC2InstanceCounts
newEC2InstanceCounts :: EC2InstanceCounts
newEC2InstanceCounts =
  EC2InstanceCounts'
    { $sel:active:EC2InstanceCounts' :: Maybe Natural
active = forall a. Maybe a
Prelude.Nothing,
      $sel:desired:EC2InstanceCounts' :: Maybe Natural
desired = forall a. Maybe a
Prelude.Nothing,
      $sel:idle:EC2InstanceCounts' :: Maybe Natural
idle = forall a. Maybe a
Prelude.Nothing,
      $sel:maximum:EC2InstanceCounts' :: Maybe Natural
maximum = forall a. Maybe a
Prelude.Nothing,
      $sel:minimum:EC2InstanceCounts' :: Maybe Natural
minimum = forall a. Maybe a
Prelude.Nothing,
      $sel:pending:EC2InstanceCounts' :: Maybe Natural
pending = forall a. Maybe a
Prelude.Nothing,
      $sel:terminating:EC2InstanceCounts' :: Maybe Natural
terminating = forall a. Maybe a
Prelude.Nothing
    }

-- | Actual number of instances that are ready to host game sessions.
eC2InstanceCounts_active :: Lens.Lens' EC2InstanceCounts (Prelude.Maybe Prelude.Natural)
eC2InstanceCounts_active :: Lens' EC2InstanceCounts (Maybe Natural)
eC2InstanceCounts_active = 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)

-- | 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 :: Lens' EC2InstanceCounts (Maybe Natural)
eC2InstanceCounts_desired = 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)

-- | Number of active instances that are not currently hosting a game
-- session.
eC2InstanceCounts_idle :: Lens.Lens' EC2InstanceCounts (Prelude.Maybe Prelude.Natural)
eC2InstanceCounts_idle :: Lens' EC2InstanceCounts (Maybe Natural)
eC2InstanceCounts_idle = 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)

-- | The maximum instance count value allowed.
eC2InstanceCounts_maximum :: Lens.Lens' EC2InstanceCounts (Prelude.Maybe Prelude.Natural)
eC2InstanceCounts_maximum :: Lens' EC2InstanceCounts (Maybe Natural)
eC2InstanceCounts_maximum = 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)

-- | The minimum instance count value allowed.
eC2InstanceCounts_minimum :: Lens.Lens' EC2InstanceCounts (Prelude.Maybe Prelude.Natural)
eC2InstanceCounts_minimum :: Lens' EC2InstanceCounts (Maybe Natural)
eC2InstanceCounts_minimum = 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)

-- | Number of instances that are starting but not yet active.
eC2InstanceCounts_pending :: Lens.Lens' EC2InstanceCounts (Prelude.Maybe Prelude.Natural)
eC2InstanceCounts_pending :: Lens' EC2InstanceCounts (Maybe Natural)
eC2InstanceCounts_pending = 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)

-- | 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 :: Lens' EC2InstanceCounts (Maybe Natural)
eC2InstanceCounts_terminating = 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)

instance Data.FromJSON EC2InstanceCounts where
  parseJSON :: Value -> Parser EC2InstanceCounts
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EC2InstanceCounts"
      ( \Object
x ->
          Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> EC2InstanceCounts
EC2InstanceCounts'
            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
"ACTIVE")
            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
"DESIRED")
            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
"IDLE")
            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
"MAXIMUM")
            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
"MINIMUM")
            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
"PENDING")
            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
"TERMINATING")
      )

instance Prelude.Hashable EC2InstanceCounts where
  hashWithSalt :: Int -> EC2InstanceCounts -> Int
hashWithSalt Int
_salt EC2InstanceCounts' {Maybe Natural
terminating :: Maybe Natural
pending :: Maybe Natural
minimum :: Maybe Natural
maximum :: Maybe Natural
idle :: Maybe Natural
desired :: Maybe Natural
active :: Maybe Natural
$sel:terminating:EC2InstanceCounts' :: EC2InstanceCounts -> Maybe Natural
$sel:pending:EC2InstanceCounts' :: EC2InstanceCounts -> Maybe Natural
$sel:minimum:EC2InstanceCounts' :: EC2InstanceCounts -> Maybe Natural
$sel:maximum:EC2InstanceCounts' :: EC2InstanceCounts -> Maybe Natural
$sel:idle:EC2InstanceCounts' :: EC2InstanceCounts -> Maybe Natural
$sel:desired:EC2InstanceCounts' :: EC2InstanceCounts -> Maybe Natural
$sel:active:EC2InstanceCounts' :: EC2InstanceCounts -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
active
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
desired
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
idle
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maximum
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
minimum
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
pending
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
terminating

instance Prelude.NFData EC2InstanceCounts where
  rnf :: EC2InstanceCounts -> ()
rnf EC2InstanceCounts' {Maybe Natural
terminating :: Maybe Natural
pending :: Maybe Natural
minimum :: Maybe Natural
maximum :: Maybe Natural
idle :: Maybe Natural
desired :: Maybe Natural
active :: Maybe Natural
$sel:terminating:EC2InstanceCounts' :: EC2InstanceCounts -> Maybe Natural
$sel:pending:EC2InstanceCounts' :: EC2InstanceCounts -> Maybe Natural
$sel:minimum:EC2InstanceCounts' :: EC2InstanceCounts -> Maybe Natural
$sel:maximum:EC2InstanceCounts' :: EC2InstanceCounts -> Maybe Natural
$sel:idle:EC2InstanceCounts' :: EC2InstanceCounts -> Maybe Natural
$sel:desired:EC2InstanceCounts' :: EC2InstanceCounts -> Maybe Natural
$sel:active:EC2InstanceCounts' :: EC2InstanceCounts -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
active
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
desired
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
idle
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maximum
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
minimum
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
pending
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
terminating