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

import qualified Amazonka.Core as Core
import Amazonka.GameLift.Types.EC2InstanceType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The GameLift service limits for an EC2 instance type and current
-- utilization. GameLift allows AWS accounts a maximum number of instances,
-- per instance type, per AWS Region or location, for use with GameLift.
-- You can request an limit increase for your account by using the
-- __Service limits__ page in the GameLift console.
--
-- __Related actions__
--
-- DescribeEC2InstanceLimits
--
-- /See:/ 'newEC2InstanceLimit' smart constructor.
data EC2InstanceLimit = EC2InstanceLimit'
  { -- | An AWS Region code, such as @us-west-2@.
    EC2InstanceLimit -> Maybe Text
location :: Prelude.Maybe Prelude.Text,
    -- | The name of an EC2 instance type. See
    -- <http://aws.amazon.com/ec2/instance-types/ Amazon EC2 Instance Types>
    -- for detailed descriptions.
    EC2InstanceLimit -> Maybe EC2InstanceType
eC2InstanceType :: Prelude.Maybe EC2InstanceType,
    -- | The number of instances for the specified type and location that are
    -- currently being used by the AWS account.
    EC2InstanceLimit -> Maybe Natural
currentInstances :: Prelude.Maybe Prelude.Natural,
    -- | The number of instances that is allowed for the specified instance type
    -- and location.
    EC2InstanceLimit -> Maybe Natural
instanceLimit :: Prelude.Maybe Prelude.Natural
  }
  deriving (EC2InstanceLimit -> EC2InstanceLimit -> Bool
(EC2InstanceLimit -> EC2InstanceLimit -> Bool)
-> (EC2InstanceLimit -> EC2InstanceLimit -> Bool)
-> Eq EC2InstanceLimit
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EC2InstanceLimit -> EC2InstanceLimit -> Bool
$c/= :: EC2InstanceLimit -> EC2InstanceLimit -> Bool
== :: EC2InstanceLimit -> EC2InstanceLimit -> Bool
$c== :: EC2InstanceLimit -> EC2InstanceLimit -> Bool
Prelude.Eq, ReadPrec [EC2InstanceLimit]
ReadPrec EC2InstanceLimit
Int -> ReadS EC2InstanceLimit
ReadS [EC2InstanceLimit]
(Int -> ReadS EC2InstanceLimit)
-> ReadS [EC2InstanceLimit]
-> ReadPrec EC2InstanceLimit
-> ReadPrec [EC2InstanceLimit]
-> Read EC2InstanceLimit
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EC2InstanceLimit]
$creadListPrec :: ReadPrec [EC2InstanceLimit]
readPrec :: ReadPrec EC2InstanceLimit
$creadPrec :: ReadPrec EC2InstanceLimit
readList :: ReadS [EC2InstanceLimit]
$creadList :: ReadS [EC2InstanceLimit]
readsPrec :: Int -> ReadS EC2InstanceLimit
$creadsPrec :: Int -> ReadS EC2InstanceLimit
Prelude.Read, Int -> EC2InstanceLimit -> ShowS
[EC2InstanceLimit] -> ShowS
EC2InstanceLimit -> String
(Int -> EC2InstanceLimit -> ShowS)
-> (EC2InstanceLimit -> String)
-> ([EC2InstanceLimit] -> ShowS)
-> Show EC2InstanceLimit
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EC2InstanceLimit] -> ShowS
$cshowList :: [EC2InstanceLimit] -> ShowS
show :: EC2InstanceLimit -> String
$cshow :: EC2InstanceLimit -> String
showsPrec :: Int -> EC2InstanceLimit -> ShowS
$cshowsPrec :: Int -> EC2InstanceLimit -> ShowS
Prelude.Show, (forall x. EC2InstanceLimit -> Rep EC2InstanceLimit x)
-> (forall x. Rep EC2InstanceLimit x -> EC2InstanceLimit)
-> Generic EC2InstanceLimit
forall x. Rep EC2InstanceLimit x -> EC2InstanceLimit
forall x. EC2InstanceLimit -> Rep EC2InstanceLimit x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EC2InstanceLimit x -> EC2InstanceLimit
$cfrom :: forall x. EC2InstanceLimit -> Rep EC2InstanceLimit x
Prelude.Generic)

-- |
-- Create a value of 'EC2InstanceLimit' 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:
--
-- 'location', 'eC2InstanceLimit_location' - An AWS Region code, such as @us-west-2@.
--
-- 'eC2InstanceType', 'eC2InstanceLimit_eC2InstanceType' - The name of an EC2 instance type. See
-- <http://aws.amazon.com/ec2/instance-types/ Amazon EC2 Instance Types>
-- for detailed descriptions.
--
-- 'currentInstances', 'eC2InstanceLimit_currentInstances' - The number of instances for the specified type and location that are
-- currently being used by the AWS account.
--
-- 'instanceLimit', 'eC2InstanceLimit_instanceLimit' - The number of instances that is allowed for the specified instance type
-- and location.
newEC2InstanceLimit ::
  EC2InstanceLimit
newEC2InstanceLimit :: EC2InstanceLimit
newEC2InstanceLimit =
  EC2InstanceLimit' :: Maybe Text
-> Maybe EC2InstanceType
-> Maybe Natural
-> Maybe Natural
-> EC2InstanceLimit
EC2InstanceLimit'
    { $sel:location:EC2InstanceLimit' :: Maybe Text
location = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:eC2InstanceType:EC2InstanceLimit' :: Maybe EC2InstanceType
eC2InstanceType = Maybe EC2InstanceType
forall a. Maybe a
Prelude.Nothing,
      $sel:currentInstances:EC2InstanceLimit' :: Maybe Natural
currentInstances = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:instanceLimit:EC2InstanceLimit' :: Maybe Natural
instanceLimit = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | An AWS Region code, such as @us-west-2@.
eC2InstanceLimit_location :: Lens.Lens' EC2InstanceLimit (Prelude.Maybe Prelude.Text)
eC2InstanceLimit_location :: (Maybe Text -> f (Maybe Text))
-> EC2InstanceLimit -> f EC2InstanceLimit
eC2InstanceLimit_location = (EC2InstanceLimit -> Maybe Text)
-> (EC2InstanceLimit -> Maybe Text -> EC2InstanceLimit)
-> Lens EC2InstanceLimit EC2InstanceLimit (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EC2InstanceLimit' {Maybe Text
location :: Maybe Text
$sel:location:EC2InstanceLimit' :: EC2InstanceLimit -> Maybe Text
location} -> Maybe Text
location) (\s :: EC2InstanceLimit
s@EC2InstanceLimit' {} Maybe Text
a -> EC2InstanceLimit
s {$sel:location:EC2InstanceLimit' :: Maybe Text
location = Maybe Text
a} :: EC2InstanceLimit)

-- | The name of an EC2 instance type. See
-- <http://aws.amazon.com/ec2/instance-types/ Amazon EC2 Instance Types>
-- for detailed descriptions.
eC2InstanceLimit_eC2InstanceType :: Lens.Lens' EC2InstanceLimit (Prelude.Maybe EC2InstanceType)
eC2InstanceLimit_eC2InstanceType :: (Maybe EC2InstanceType -> f (Maybe EC2InstanceType))
-> EC2InstanceLimit -> f EC2InstanceLimit
eC2InstanceLimit_eC2InstanceType = (EC2InstanceLimit -> Maybe EC2InstanceType)
-> (EC2InstanceLimit -> Maybe EC2InstanceType -> EC2InstanceLimit)
-> Lens
     EC2InstanceLimit
     EC2InstanceLimit
     (Maybe EC2InstanceType)
     (Maybe EC2InstanceType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EC2InstanceLimit' {Maybe EC2InstanceType
eC2InstanceType :: Maybe EC2InstanceType
$sel:eC2InstanceType:EC2InstanceLimit' :: EC2InstanceLimit -> Maybe EC2InstanceType
eC2InstanceType} -> Maybe EC2InstanceType
eC2InstanceType) (\s :: EC2InstanceLimit
s@EC2InstanceLimit' {} Maybe EC2InstanceType
a -> EC2InstanceLimit
s {$sel:eC2InstanceType:EC2InstanceLimit' :: Maybe EC2InstanceType
eC2InstanceType = Maybe EC2InstanceType
a} :: EC2InstanceLimit)

-- | The number of instances for the specified type and location that are
-- currently being used by the AWS account.
eC2InstanceLimit_currentInstances :: Lens.Lens' EC2InstanceLimit (Prelude.Maybe Prelude.Natural)
eC2InstanceLimit_currentInstances :: (Maybe Natural -> f (Maybe Natural))
-> EC2InstanceLimit -> f EC2InstanceLimit
eC2InstanceLimit_currentInstances = (EC2InstanceLimit -> Maybe Natural)
-> (EC2InstanceLimit -> Maybe Natural -> EC2InstanceLimit)
-> Lens
     EC2InstanceLimit EC2InstanceLimit (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EC2InstanceLimit' {Maybe Natural
currentInstances :: Maybe Natural
$sel:currentInstances:EC2InstanceLimit' :: EC2InstanceLimit -> Maybe Natural
currentInstances} -> Maybe Natural
currentInstances) (\s :: EC2InstanceLimit
s@EC2InstanceLimit' {} Maybe Natural
a -> EC2InstanceLimit
s {$sel:currentInstances:EC2InstanceLimit' :: Maybe Natural
currentInstances = Maybe Natural
a} :: EC2InstanceLimit)

-- | The number of instances that is allowed for the specified instance type
-- and location.
eC2InstanceLimit_instanceLimit :: Lens.Lens' EC2InstanceLimit (Prelude.Maybe Prelude.Natural)
eC2InstanceLimit_instanceLimit :: (Maybe Natural -> f (Maybe Natural))
-> EC2InstanceLimit -> f EC2InstanceLimit
eC2InstanceLimit_instanceLimit = (EC2InstanceLimit -> Maybe Natural)
-> (EC2InstanceLimit -> Maybe Natural -> EC2InstanceLimit)
-> Lens
     EC2InstanceLimit EC2InstanceLimit (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EC2InstanceLimit' {Maybe Natural
instanceLimit :: Maybe Natural
$sel:instanceLimit:EC2InstanceLimit' :: EC2InstanceLimit -> Maybe Natural
instanceLimit} -> Maybe Natural
instanceLimit) (\s :: EC2InstanceLimit
s@EC2InstanceLimit' {} Maybe Natural
a -> EC2InstanceLimit
s {$sel:instanceLimit:EC2InstanceLimit' :: Maybe Natural
instanceLimit = Maybe Natural
a} :: EC2InstanceLimit)

instance Core.FromJSON EC2InstanceLimit where
  parseJSON :: Value -> Parser EC2InstanceLimit
parseJSON =
    String
-> (Object -> Parser EC2InstanceLimit)
-> Value
-> Parser EC2InstanceLimit
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EC2InstanceLimit"
      ( \Object
x ->
          Maybe Text
-> Maybe EC2InstanceType
-> Maybe Natural
-> Maybe Natural
-> EC2InstanceLimit
EC2InstanceLimit'
            (Maybe Text
 -> Maybe EC2InstanceType
 -> Maybe Natural
 -> Maybe Natural
 -> EC2InstanceLimit)
-> Parser (Maybe Text)
-> Parser
     (Maybe EC2InstanceType
      -> Maybe Natural -> Maybe Natural -> EC2InstanceLimit)
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
"Location")
            Parser
  (Maybe EC2InstanceType
   -> Maybe Natural -> Maybe Natural -> EC2InstanceLimit)
-> Parser (Maybe EC2InstanceType)
-> Parser (Maybe Natural -> Maybe Natural -> EC2InstanceLimit)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe EC2InstanceType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EC2InstanceType")
            Parser (Maybe Natural -> Maybe Natural -> EC2InstanceLimit)
-> Parser (Maybe Natural)
-> Parser (Maybe Natural -> EC2InstanceLimit)
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
"CurrentInstances")
            Parser (Maybe Natural -> EC2InstanceLimit)
-> Parser (Maybe Natural) -> Parser EC2InstanceLimit
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
"InstanceLimit")
      )

instance Prelude.Hashable EC2InstanceLimit

instance Prelude.NFData EC2InstanceLimit