{-# 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.CapacityAllocation
-- 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.CapacityAllocation 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 Amazonka.EC2.Types.AllocationType
import qualified Amazonka.Prelude as Prelude

-- | Information about instance capacity usage for a Capacity Reservation.
--
-- /See:/ 'newCapacityAllocation' smart constructor.
data CapacityAllocation = CapacityAllocation'
  { -- | The usage type. @used@ indicates that the instance capacity is in use by
    -- instances that are running in the Capacity Reservation.
    CapacityAllocation -> Maybe AllocationType
allocationType :: Prelude.Maybe AllocationType,
    -- | The amount of instance capacity associated with the usage. For example a
    -- value of @4@ indicates that instance capacity for 4 instances is
    -- currently in use.
    CapacityAllocation -> Maybe Int
count :: Prelude.Maybe Prelude.Int
  }
  deriving (CapacityAllocation -> CapacityAllocation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CapacityAllocation -> CapacityAllocation -> Bool
$c/= :: CapacityAllocation -> CapacityAllocation -> Bool
== :: CapacityAllocation -> CapacityAllocation -> Bool
$c== :: CapacityAllocation -> CapacityAllocation -> Bool
Prelude.Eq, ReadPrec [CapacityAllocation]
ReadPrec CapacityAllocation
Int -> ReadS CapacityAllocation
ReadS [CapacityAllocation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CapacityAllocation]
$creadListPrec :: ReadPrec [CapacityAllocation]
readPrec :: ReadPrec CapacityAllocation
$creadPrec :: ReadPrec CapacityAllocation
readList :: ReadS [CapacityAllocation]
$creadList :: ReadS [CapacityAllocation]
readsPrec :: Int -> ReadS CapacityAllocation
$creadsPrec :: Int -> ReadS CapacityAllocation
Prelude.Read, Int -> CapacityAllocation -> ShowS
[CapacityAllocation] -> ShowS
CapacityAllocation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CapacityAllocation] -> ShowS
$cshowList :: [CapacityAllocation] -> ShowS
show :: CapacityAllocation -> String
$cshow :: CapacityAllocation -> String
showsPrec :: Int -> CapacityAllocation -> ShowS
$cshowsPrec :: Int -> CapacityAllocation -> ShowS
Prelude.Show, forall x. Rep CapacityAllocation x -> CapacityAllocation
forall x. CapacityAllocation -> Rep CapacityAllocation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CapacityAllocation x -> CapacityAllocation
$cfrom :: forall x. CapacityAllocation -> Rep CapacityAllocation x
Prelude.Generic)

-- |
-- Create a value of 'CapacityAllocation' 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:
--
-- 'allocationType', 'capacityAllocation_allocationType' - The usage type. @used@ indicates that the instance capacity is in use by
-- instances that are running in the Capacity Reservation.
--
-- 'count', 'capacityAllocation_count' - The amount of instance capacity associated with the usage. For example a
-- value of @4@ indicates that instance capacity for 4 instances is
-- currently in use.
newCapacityAllocation ::
  CapacityAllocation
newCapacityAllocation :: CapacityAllocation
newCapacityAllocation =
  CapacityAllocation'
    { $sel:allocationType:CapacityAllocation' :: Maybe AllocationType
allocationType =
        forall a. Maybe a
Prelude.Nothing,
      $sel:count:CapacityAllocation' :: Maybe Int
count = forall a. Maybe a
Prelude.Nothing
    }

-- | The usage type. @used@ indicates that the instance capacity is in use by
-- instances that are running in the Capacity Reservation.
capacityAllocation_allocationType :: Lens.Lens' CapacityAllocation (Prelude.Maybe AllocationType)
capacityAllocation_allocationType :: Lens' CapacityAllocation (Maybe AllocationType)
capacityAllocation_allocationType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CapacityAllocation' {Maybe AllocationType
allocationType :: Maybe AllocationType
$sel:allocationType:CapacityAllocation' :: CapacityAllocation -> Maybe AllocationType
allocationType} -> Maybe AllocationType
allocationType) (\s :: CapacityAllocation
s@CapacityAllocation' {} Maybe AllocationType
a -> CapacityAllocation
s {$sel:allocationType:CapacityAllocation' :: Maybe AllocationType
allocationType = Maybe AllocationType
a} :: CapacityAllocation)

-- | The amount of instance capacity associated with the usage. For example a
-- value of @4@ indicates that instance capacity for 4 instances is
-- currently in use.
capacityAllocation_count :: Lens.Lens' CapacityAllocation (Prelude.Maybe Prelude.Int)
capacityAllocation_count :: Lens' CapacityAllocation (Maybe Int)
capacityAllocation_count = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CapacityAllocation' {Maybe Int
count :: Maybe Int
$sel:count:CapacityAllocation' :: CapacityAllocation -> Maybe Int
count} -> Maybe Int
count) (\s :: CapacityAllocation
s@CapacityAllocation' {} Maybe Int
a -> CapacityAllocation
s {$sel:count:CapacityAllocation' :: Maybe Int
count = Maybe Int
a} :: CapacityAllocation)

instance Data.FromXML CapacityAllocation where
  parseXML :: [Node] -> Either String CapacityAllocation
parseXML [Node]
x =
    Maybe AllocationType -> Maybe Int -> CapacityAllocation
CapacityAllocation'
      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
"allocationType")
      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
"count")

instance Prelude.Hashable CapacityAllocation where
  hashWithSalt :: Int -> CapacityAllocation -> Int
hashWithSalt Int
_salt CapacityAllocation' {Maybe Int
Maybe AllocationType
count :: Maybe Int
allocationType :: Maybe AllocationType
$sel:count:CapacityAllocation' :: CapacityAllocation -> Maybe Int
$sel:allocationType:CapacityAllocation' :: CapacityAllocation -> Maybe AllocationType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AllocationType
allocationType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
count

instance Prelude.NFData CapacityAllocation where
  rnf :: CapacityAllocation -> ()
rnf CapacityAllocation' {Maybe Int
Maybe AllocationType
count :: Maybe Int
allocationType :: Maybe AllocationType
$sel:count:CapacityAllocation' :: CapacityAllocation -> Maybe Int
$sel:allocationType:CapacityAllocation' :: CapacityAllocation -> Maybe AllocationType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AllocationType
allocationType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
count