{-# 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.CostExplorer.Types.CoverageNormalizedUnits
-- 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.CostExplorer.Types.CoverageNormalizedUnits where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The amount of instance usage, in normalized units. You can use
-- normalized units to see your EC2 usage for multiple sizes of instances
-- in a uniform way. For example, suppose that you run an xlarge instance
-- and a 2xlarge instance. If you run both instances for the same amount of
-- time, the 2xlarge instance uses twice as much of your reservation as the
-- xlarge instance, even though both instances show only one instance-hour.
-- When you use normalized units instead of instance-hours, the xlarge
-- instance used 8 normalized units, and the 2xlarge instance used 16
-- normalized units.
--
-- For more information, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ri-modifying.html Modifying Reserved Instances>
-- in the /Amazon Elastic Compute Cloud User Guide for Linux Instances/.
--
-- /See:/ 'newCoverageNormalizedUnits' smart constructor.
data CoverageNormalizedUnits = CoverageNormalizedUnits'
  { -- | The number of normalized units that a reservation covers.
    CoverageNormalizedUnits -> Maybe Text
reservedNormalizedUnits :: Prelude.Maybe Prelude.Text,
    -- | The total number of normalized units that you used.
    CoverageNormalizedUnits -> Maybe Text
totalRunningNormalizedUnits :: Prelude.Maybe Prelude.Text,
    -- | The percentage of your used instance normalized units that a reservation
    -- covers.
    CoverageNormalizedUnits -> Maybe Text
coverageNormalizedUnitsPercentage :: Prelude.Maybe Prelude.Text,
    -- | The number of normalized units that are covered by On-Demand Instances
    -- instead of a reservation.
    CoverageNormalizedUnits -> Maybe Text
onDemandNormalizedUnits :: Prelude.Maybe Prelude.Text
  }
  deriving (CoverageNormalizedUnits -> CoverageNormalizedUnits -> Bool
(CoverageNormalizedUnits -> CoverageNormalizedUnits -> Bool)
-> (CoverageNormalizedUnits -> CoverageNormalizedUnits -> Bool)
-> Eq CoverageNormalizedUnits
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CoverageNormalizedUnits -> CoverageNormalizedUnits -> Bool
$c/= :: CoverageNormalizedUnits -> CoverageNormalizedUnits -> Bool
== :: CoverageNormalizedUnits -> CoverageNormalizedUnits -> Bool
$c== :: CoverageNormalizedUnits -> CoverageNormalizedUnits -> Bool
Prelude.Eq, ReadPrec [CoverageNormalizedUnits]
ReadPrec CoverageNormalizedUnits
Int -> ReadS CoverageNormalizedUnits
ReadS [CoverageNormalizedUnits]
(Int -> ReadS CoverageNormalizedUnits)
-> ReadS [CoverageNormalizedUnits]
-> ReadPrec CoverageNormalizedUnits
-> ReadPrec [CoverageNormalizedUnits]
-> Read CoverageNormalizedUnits
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CoverageNormalizedUnits]
$creadListPrec :: ReadPrec [CoverageNormalizedUnits]
readPrec :: ReadPrec CoverageNormalizedUnits
$creadPrec :: ReadPrec CoverageNormalizedUnits
readList :: ReadS [CoverageNormalizedUnits]
$creadList :: ReadS [CoverageNormalizedUnits]
readsPrec :: Int -> ReadS CoverageNormalizedUnits
$creadsPrec :: Int -> ReadS CoverageNormalizedUnits
Prelude.Read, Int -> CoverageNormalizedUnits -> ShowS
[CoverageNormalizedUnits] -> ShowS
CoverageNormalizedUnits -> String
(Int -> CoverageNormalizedUnits -> ShowS)
-> (CoverageNormalizedUnits -> String)
-> ([CoverageNormalizedUnits] -> ShowS)
-> Show CoverageNormalizedUnits
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CoverageNormalizedUnits] -> ShowS
$cshowList :: [CoverageNormalizedUnits] -> ShowS
show :: CoverageNormalizedUnits -> String
$cshow :: CoverageNormalizedUnits -> String
showsPrec :: Int -> CoverageNormalizedUnits -> ShowS
$cshowsPrec :: Int -> CoverageNormalizedUnits -> ShowS
Prelude.Show, (forall x.
 CoverageNormalizedUnits -> Rep CoverageNormalizedUnits x)
-> (forall x.
    Rep CoverageNormalizedUnits x -> CoverageNormalizedUnits)
-> Generic CoverageNormalizedUnits
forall x. Rep CoverageNormalizedUnits x -> CoverageNormalizedUnits
forall x. CoverageNormalizedUnits -> Rep CoverageNormalizedUnits x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CoverageNormalizedUnits x -> CoverageNormalizedUnits
$cfrom :: forall x. CoverageNormalizedUnits -> Rep CoverageNormalizedUnits x
Prelude.Generic)

-- |
-- Create a value of 'CoverageNormalizedUnits' 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:
--
-- 'reservedNormalizedUnits', 'coverageNormalizedUnits_reservedNormalizedUnits' - The number of normalized units that a reservation covers.
--
-- 'totalRunningNormalizedUnits', 'coverageNormalizedUnits_totalRunningNormalizedUnits' - The total number of normalized units that you used.
--
-- 'coverageNormalizedUnitsPercentage', 'coverageNormalizedUnits_coverageNormalizedUnitsPercentage' - The percentage of your used instance normalized units that a reservation
-- covers.
--
-- 'onDemandNormalizedUnits', 'coverageNormalizedUnits_onDemandNormalizedUnits' - The number of normalized units that are covered by On-Demand Instances
-- instead of a reservation.
newCoverageNormalizedUnits ::
  CoverageNormalizedUnits
newCoverageNormalizedUnits :: CoverageNormalizedUnits
newCoverageNormalizedUnits =
  CoverageNormalizedUnits' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> CoverageNormalizedUnits
CoverageNormalizedUnits'
    { $sel:reservedNormalizedUnits:CoverageNormalizedUnits' :: Maybe Text
reservedNormalizedUnits =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:totalRunningNormalizedUnits:CoverageNormalizedUnits' :: Maybe Text
totalRunningNormalizedUnits = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:coverageNormalizedUnitsPercentage:CoverageNormalizedUnits' :: Maybe Text
coverageNormalizedUnitsPercentage =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:onDemandNormalizedUnits:CoverageNormalizedUnits' :: Maybe Text
onDemandNormalizedUnits = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The number of normalized units that a reservation covers.
coverageNormalizedUnits_reservedNormalizedUnits :: Lens.Lens' CoverageNormalizedUnits (Prelude.Maybe Prelude.Text)
coverageNormalizedUnits_reservedNormalizedUnits :: (Maybe Text -> f (Maybe Text))
-> CoverageNormalizedUnits -> f CoverageNormalizedUnits
coverageNormalizedUnits_reservedNormalizedUnits = (CoverageNormalizedUnits -> Maybe Text)
-> (CoverageNormalizedUnits
    -> Maybe Text -> CoverageNormalizedUnits)
-> Lens
     CoverageNormalizedUnits
     CoverageNormalizedUnits
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CoverageNormalizedUnits' {Maybe Text
reservedNormalizedUnits :: Maybe Text
$sel:reservedNormalizedUnits:CoverageNormalizedUnits' :: CoverageNormalizedUnits -> Maybe Text
reservedNormalizedUnits} -> Maybe Text
reservedNormalizedUnits) (\s :: CoverageNormalizedUnits
s@CoverageNormalizedUnits' {} Maybe Text
a -> CoverageNormalizedUnits
s {$sel:reservedNormalizedUnits:CoverageNormalizedUnits' :: Maybe Text
reservedNormalizedUnits = Maybe Text
a} :: CoverageNormalizedUnits)

-- | The total number of normalized units that you used.
coverageNormalizedUnits_totalRunningNormalizedUnits :: Lens.Lens' CoverageNormalizedUnits (Prelude.Maybe Prelude.Text)
coverageNormalizedUnits_totalRunningNormalizedUnits :: (Maybe Text -> f (Maybe Text))
-> CoverageNormalizedUnits -> f CoverageNormalizedUnits
coverageNormalizedUnits_totalRunningNormalizedUnits = (CoverageNormalizedUnits -> Maybe Text)
-> (CoverageNormalizedUnits
    -> Maybe Text -> CoverageNormalizedUnits)
-> Lens
     CoverageNormalizedUnits
     CoverageNormalizedUnits
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CoverageNormalizedUnits' {Maybe Text
totalRunningNormalizedUnits :: Maybe Text
$sel:totalRunningNormalizedUnits:CoverageNormalizedUnits' :: CoverageNormalizedUnits -> Maybe Text
totalRunningNormalizedUnits} -> Maybe Text
totalRunningNormalizedUnits) (\s :: CoverageNormalizedUnits
s@CoverageNormalizedUnits' {} Maybe Text
a -> CoverageNormalizedUnits
s {$sel:totalRunningNormalizedUnits:CoverageNormalizedUnits' :: Maybe Text
totalRunningNormalizedUnits = Maybe Text
a} :: CoverageNormalizedUnits)

-- | The percentage of your used instance normalized units that a reservation
-- covers.
coverageNormalizedUnits_coverageNormalizedUnitsPercentage :: Lens.Lens' CoverageNormalizedUnits (Prelude.Maybe Prelude.Text)
coverageNormalizedUnits_coverageNormalizedUnitsPercentage :: (Maybe Text -> f (Maybe Text))
-> CoverageNormalizedUnits -> f CoverageNormalizedUnits
coverageNormalizedUnits_coverageNormalizedUnitsPercentage = (CoverageNormalizedUnits -> Maybe Text)
-> (CoverageNormalizedUnits
    -> Maybe Text -> CoverageNormalizedUnits)
-> Lens
     CoverageNormalizedUnits
     CoverageNormalizedUnits
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CoverageNormalizedUnits' {Maybe Text
coverageNormalizedUnitsPercentage :: Maybe Text
$sel:coverageNormalizedUnitsPercentage:CoverageNormalizedUnits' :: CoverageNormalizedUnits -> Maybe Text
coverageNormalizedUnitsPercentage} -> Maybe Text
coverageNormalizedUnitsPercentage) (\s :: CoverageNormalizedUnits
s@CoverageNormalizedUnits' {} Maybe Text
a -> CoverageNormalizedUnits
s {$sel:coverageNormalizedUnitsPercentage:CoverageNormalizedUnits' :: Maybe Text
coverageNormalizedUnitsPercentage = Maybe Text
a} :: CoverageNormalizedUnits)

-- | The number of normalized units that are covered by On-Demand Instances
-- instead of a reservation.
coverageNormalizedUnits_onDemandNormalizedUnits :: Lens.Lens' CoverageNormalizedUnits (Prelude.Maybe Prelude.Text)
coverageNormalizedUnits_onDemandNormalizedUnits :: (Maybe Text -> f (Maybe Text))
-> CoverageNormalizedUnits -> f CoverageNormalizedUnits
coverageNormalizedUnits_onDemandNormalizedUnits = (CoverageNormalizedUnits -> Maybe Text)
-> (CoverageNormalizedUnits
    -> Maybe Text -> CoverageNormalizedUnits)
-> Lens
     CoverageNormalizedUnits
     CoverageNormalizedUnits
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CoverageNormalizedUnits' {Maybe Text
onDemandNormalizedUnits :: Maybe Text
$sel:onDemandNormalizedUnits:CoverageNormalizedUnits' :: CoverageNormalizedUnits -> Maybe Text
onDemandNormalizedUnits} -> Maybe Text
onDemandNormalizedUnits) (\s :: CoverageNormalizedUnits
s@CoverageNormalizedUnits' {} Maybe Text
a -> CoverageNormalizedUnits
s {$sel:onDemandNormalizedUnits:CoverageNormalizedUnits' :: Maybe Text
onDemandNormalizedUnits = Maybe Text
a} :: CoverageNormalizedUnits)

instance Core.FromJSON CoverageNormalizedUnits where
  parseJSON :: Value -> Parser CoverageNormalizedUnits
parseJSON =
    String
-> (Object -> Parser CoverageNormalizedUnits)
-> Value
-> Parser CoverageNormalizedUnits
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CoverageNormalizedUnits"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> CoverageNormalizedUnits
CoverageNormalizedUnits'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> CoverageNormalizedUnits)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe Text -> CoverageNormalizedUnits)
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
"ReservedNormalizedUnits")
            Parser
  (Maybe Text -> Maybe Text -> Maybe Text -> CoverageNormalizedUnits)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> CoverageNormalizedUnits)
forall (f :: * -> *) a b. Applicative f => 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
"TotalRunningNormalizedUnits")
            Parser (Maybe Text -> Maybe Text -> CoverageNormalizedUnits)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> CoverageNormalizedUnits)
forall (f :: * -> *) a b. Applicative f => 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
"CoverageNormalizedUnitsPercentage")
            Parser (Maybe Text -> CoverageNormalizedUnits)
-> Parser (Maybe Text) -> Parser CoverageNormalizedUnits
forall (f :: * -> *) a b. Applicative f => 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
"OnDemandNormalizedUnits")
      )

instance Prelude.Hashable CoverageNormalizedUnits

instance Prelude.NFData CoverageNormalizedUnits