{-# 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.InstanceUsage
-- 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.InstanceUsage 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 Capacity Reservation usage.
--
-- /See:/ 'newInstanceUsage' smart constructor.
data InstanceUsage = InstanceUsage'
  { -- | The ID of the Amazon Web Services account that is making use of the
    -- Capacity Reservation.
    InstanceUsage -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text,
    -- | The number of instances the Amazon Web Services account currently has in
    -- the Capacity Reservation.
    InstanceUsage -> Maybe Int
usedInstanceCount :: Prelude.Maybe Prelude.Int
  }
  deriving (InstanceUsage -> InstanceUsage -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstanceUsage -> InstanceUsage -> Bool
$c/= :: InstanceUsage -> InstanceUsage -> Bool
== :: InstanceUsage -> InstanceUsage -> Bool
$c== :: InstanceUsage -> InstanceUsage -> Bool
Prelude.Eq, ReadPrec [InstanceUsage]
ReadPrec InstanceUsage
Int -> ReadS InstanceUsage
ReadS [InstanceUsage]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InstanceUsage]
$creadListPrec :: ReadPrec [InstanceUsage]
readPrec :: ReadPrec InstanceUsage
$creadPrec :: ReadPrec InstanceUsage
readList :: ReadS [InstanceUsage]
$creadList :: ReadS [InstanceUsage]
readsPrec :: Int -> ReadS InstanceUsage
$creadsPrec :: Int -> ReadS InstanceUsage
Prelude.Read, Int -> InstanceUsage -> ShowS
[InstanceUsage] -> ShowS
InstanceUsage -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstanceUsage] -> ShowS
$cshowList :: [InstanceUsage] -> ShowS
show :: InstanceUsage -> String
$cshow :: InstanceUsage -> String
showsPrec :: Int -> InstanceUsage -> ShowS
$cshowsPrec :: Int -> InstanceUsage -> ShowS
Prelude.Show, forall x. Rep InstanceUsage x -> InstanceUsage
forall x. InstanceUsage -> Rep InstanceUsage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InstanceUsage x -> InstanceUsage
$cfrom :: forall x. InstanceUsage -> Rep InstanceUsage x
Prelude.Generic)

-- |
-- Create a value of 'InstanceUsage' 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:
--
-- 'accountId', 'instanceUsage_accountId' - The ID of the Amazon Web Services account that is making use of the
-- Capacity Reservation.
--
-- 'usedInstanceCount', 'instanceUsage_usedInstanceCount' - The number of instances the Amazon Web Services account currently has in
-- the Capacity Reservation.
newInstanceUsage ::
  InstanceUsage
newInstanceUsage :: InstanceUsage
newInstanceUsage =
  InstanceUsage'
    { $sel:accountId:InstanceUsage' :: Maybe Text
accountId = forall a. Maybe a
Prelude.Nothing,
      $sel:usedInstanceCount:InstanceUsage' :: Maybe Int
usedInstanceCount = forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the Amazon Web Services account that is making use of the
-- Capacity Reservation.
instanceUsage_accountId :: Lens.Lens' InstanceUsage (Prelude.Maybe Prelude.Text)
instanceUsage_accountId :: Lens' InstanceUsage (Maybe Text)
instanceUsage_accountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceUsage' {Maybe Text
accountId :: Maybe Text
$sel:accountId:InstanceUsage' :: InstanceUsage -> Maybe Text
accountId} -> Maybe Text
accountId) (\s :: InstanceUsage
s@InstanceUsage' {} Maybe Text
a -> InstanceUsage
s {$sel:accountId:InstanceUsage' :: Maybe Text
accountId = Maybe Text
a} :: InstanceUsage)

-- | The number of instances the Amazon Web Services account currently has in
-- the Capacity Reservation.
instanceUsage_usedInstanceCount :: Lens.Lens' InstanceUsage (Prelude.Maybe Prelude.Int)
instanceUsage_usedInstanceCount :: Lens' InstanceUsage (Maybe Int)
instanceUsage_usedInstanceCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceUsage' {Maybe Int
usedInstanceCount :: Maybe Int
$sel:usedInstanceCount:InstanceUsage' :: InstanceUsage -> Maybe Int
usedInstanceCount} -> Maybe Int
usedInstanceCount) (\s :: InstanceUsage
s@InstanceUsage' {} Maybe Int
a -> InstanceUsage
s {$sel:usedInstanceCount:InstanceUsage' :: Maybe Int
usedInstanceCount = Maybe Int
a} :: InstanceUsage)

instance Data.FromXML InstanceUsage where
  parseXML :: [Node] -> Either String InstanceUsage
parseXML [Node]
x =
    Maybe Text -> Maybe Int -> InstanceUsage
InstanceUsage'
      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
"accountId")
      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
"usedInstanceCount")

instance Prelude.Hashable InstanceUsage where
  hashWithSalt :: Int -> InstanceUsage -> Int
hashWithSalt Int
_salt InstanceUsage' {Maybe Int
Maybe Text
usedInstanceCount :: Maybe Int
accountId :: Maybe Text
$sel:usedInstanceCount:InstanceUsage' :: InstanceUsage -> Maybe Int
$sel:accountId:InstanceUsage' :: InstanceUsage -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
accountId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
usedInstanceCount

instance Prelude.NFData InstanceUsage where
  rnf :: InstanceUsage -> ()
rnf InstanceUsage' {Maybe Int
Maybe Text
usedInstanceCount :: Maybe Int
accountId :: Maybe Text
$sel:usedInstanceCount:InstanceUsage' :: InstanceUsage -> Maybe Int
$sel:accountId:InstanceUsage' :: InstanceUsage -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
accountId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
usedInstanceCount