{-# 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.EC2.Types.InstanceCapacity
-- 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.EC2.Types.InstanceCapacity where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Internal
import qualified Amazonka.Prelude as Prelude

-- | Information about the number of instances that can be launched onto the
-- Dedicated Host.
--
-- /See:/ 'newInstanceCapacity' smart constructor.
data InstanceCapacity = InstanceCapacity'
  { -- | The number of instances that can be launched onto the Dedicated Host
    -- based on the host\'s available capacity.
    InstanceCapacity -> Maybe Int
availableCapacity :: Prelude.Maybe Prelude.Int,
    -- | The instance type supported by the Dedicated Host.
    InstanceCapacity -> Maybe Text
instanceType :: Prelude.Maybe Prelude.Text,
    -- | The total number of instances that can be launched onto the Dedicated
    -- Host if there are no instances running on it.
    InstanceCapacity -> Maybe Int
totalCapacity :: Prelude.Maybe Prelude.Int
  }
  deriving (InstanceCapacity -> InstanceCapacity -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstanceCapacity -> InstanceCapacity -> Bool
$c/= :: InstanceCapacity -> InstanceCapacity -> Bool
== :: InstanceCapacity -> InstanceCapacity -> Bool
$c== :: InstanceCapacity -> InstanceCapacity -> Bool
Prelude.Eq, ReadPrec [InstanceCapacity]
ReadPrec InstanceCapacity
Int -> ReadS InstanceCapacity
ReadS [InstanceCapacity]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InstanceCapacity]
$creadListPrec :: ReadPrec [InstanceCapacity]
readPrec :: ReadPrec InstanceCapacity
$creadPrec :: ReadPrec InstanceCapacity
readList :: ReadS [InstanceCapacity]
$creadList :: ReadS [InstanceCapacity]
readsPrec :: Int -> ReadS InstanceCapacity
$creadsPrec :: Int -> ReadS InstanceCapacity
Prelude.Read, Int -> InstanceCapacity -> ShowS
[InstanceCapacity] -> ShowS
InstanceCapacity -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstanceCapacity] -> ShowS
$cshowList :: [InstanceCapacity] -> ShowS
show :: InstanceCapacity -> String
$cshow :: InstanceCapacity -> String
showsPrec :: Int -> InstanceCapacity -> ShowS
$cshowsPrec :: Int -> InstanceCapacity -> ShowS
Prelude.Show, forall x. Rep InstanceCapacity x -> InstanceCapacity
forall x. InstanceCapacity -> Rep InstanceCapacity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InstanceCapacity x -> InstanceCapacity
$cfrom :: forall x. InstanceCapacity -> Rep InstanceCapacity x
Prelude.Generic)

-- |
-- Create a value of 'InstanceCapacity' 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:
--
-- 'availableCapacity', 'instanceCapacity_availableCapacity' - The number of instances that can be launched onto the Dedicated Host
-- based on the host\'s available capacity.
--
-- 'instanceType', 'instanceCapacity_instanceType' - The instance type supported by the Dedicated Host.
--
-- 'totalCapacity', 'instanceCapacity_totalCapacity' - The total number of instances that can be launched onto the Dedicated
-- Host if there are no instances running on it.
newInstanceCapacity ::
  InstanceCapacity
newInstanceCapacity :: InstanceCapacity
newInstanceCapacity =
  InstanceCapacity'
    { $sel:availableCapacity:InstanceCapacity' :: Maybe Int
availableCapacity =
        forall a. Maybe a
Prelude.Nothing,
      $sel:instanceType:InstanceCapacity' :: Maybe Text
instanceType = forall a. Maybe a
Prelude.Nothing,
      $sel:totalCapacity:InstanceCapacity' :: Maybe Int
totalCapacity = forall a. Maybe a
Prelude.Nothing
    }

-- | The number of instances that can be launched onto the Dedicated Host
-- based on the host\'s available capacity.
instanceCapacity_availableCapacity :: Lens.Lens' InstanceCapacity (Prelude.Maybe Prelude.Int)
instanceCapacity_availableCapacity :: Lens' InstanceCapacity (Maybe Int)
instanceCapacity_availableCapacity = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceCapacity' {Maybe Int
availableCapacity :: Maybe Int
$sel:availableCapacity:InstanceCapacity' :: InstanceCapacity -> Maybe Int
availableCapacity} -> Maybe Int
availableCapacity) (\s :: InstanceCapacity
s@InstanceCapacity' {} Maybe Int
a -> InstanceCapacity
s {$sel:availableCapacity:InstanceCapacity' :: Maybe Int
availableCapacity = Maybe Int
a} :: InstanceCapacity)

-- | The instance type supported by the Dedicated Host.
instanceCapacity_instanceType :: Lens.Lens' InstanceCapacity (Prelude.Maybe Prelude.Text)
instanceCapacity_instanceType :: Lens' InstanceCapacity (Maybe Text)
instanceCapacity_instanceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceCapacity' {Maybe Text
instanceType :: Maybe Text
$sel:instanceType:InstanceCapacity' :: InstanceCapacity -> Maybe Text
instanceType} -> Maybe Text
instanceType) (\s :: InstanceCapacity
s@InstanceCapacity' {} Maybe Text
a -> InstanceCapacity
s {$sel:instanceType:InstanceCapacity' :: Maybe Text
instanceType = Maybe Text
a} :: InstanceCapacity)

-- | The total number of instances that can be launched onto the Dedicated
-- Host if there are no instances running on it.
instanceCapacity_totalCapacity :: Lens.Lens' InstanceCapacity (Prelude.Maybe Prelude.Int)
instanceCapacity_totalCapacity :: Lens' InstanceCapacity (Maybe Int)
instanceCapacity_totalCapacity = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceCapacity' {Maybe Int
totalCapacity :: Maybe Int
$sel:totalCapacity:InstanceCapacity' :: InstanceCapacity -> Maybe Int
totalCapacity} -> Maybe Int
totalCapacity) (\s :: InstanceCapacity
s@InstanceCapacity' {} Maybe Int
a -> InstanceCapacity
s {$sel:totalCapacity:InstanceCapacity' :: Maybe Int
totalCapacity = Maybe Int
a} :: InstanceCapacity)

instance Data.FromXML InstanceCapacity where
  parseXML :: [Node] -> Either String InstanceCapacity
parseXML [Node]
x =
    Maybe Int -> Maybe Text -> Maybe Int -> InstanceCapacity
InstanceCapacity'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"availableCapacity")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"instanceType")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"totalCapacity")

instance Prelude.Hashable InstanceCapacity where
  hashWithSalt :: Int -> InstanceCapacity -> Int
hashWithSalt Int
_salt InstanceCapacity' {Maybe Int
Maybe Text
totalCapacity :: Maybe Int
instanceType :: Maybe Text
availableCapacity :: Maybe Int
$sel:totalCapacity:InstanceCapacity' :: InstanceCapacity -> Maybe Int
$sel:instanceType:InstanceCapacity' :: InstanceCapacity -> Maybe Text
$sel:availableCapacity:InstanceCapacity' :: InstanceCapacity -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
availableCapacity
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
instanceType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
totalCapacity

instance Prelude.NFData InstanceCapacity where
  rnf :: InstanceCapacity -> ()
rnf InstanceCapacity' {Maybe Int
Maybe Text
totalCapacity :: Maybe Int
instanceType :: Maybe Text
availableCapacity :: Maybe Int
$sel:totalCapacity:InstanceCapacity' :: InstanceCapacity -> Maybe Int
$sel:instanceType:InstanceCapacity' :: InstanceCapacity -> Maybe Text
$sel:availableCapacity:InstanceCapacity' :: InstanceCapacity -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
availableCapacity
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
instanceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
totalCapacity