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

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

-- | How long a running instance either used a reservation or was On-Demand.
--
-- /See:/ 'newCoverageHours' smart constructor.
data CoverageHours = CoverageHours'
  { -- | The percentage of instance hours that a reservation covered.
    CoverageHours -> Maybe Text
coverageHoursPercentage :: Prelude.Maybe Prelude.Text,
    -- | The number of instance running hours that On-Demand Instances covered.
    CoverageHours -> Maybe Text
onDemandHours :: Prelude.Maybe Prelude.Text,
    -- | The number of instance running hours that reservations covered.
    CoverageHours -> Maybe Text
reservedHours :: Prelude.Maybe Prelude.Text,
    -- | The total instance usage, in hours.
    CoverageHours -> Maybe Text
totalRunningHours :: Prelude.Maybe Prelude.Text
  }
  deriving (CoverageHours -> CoverageHours -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CoverageHours -> CoverageHours -> Bool
$c/= :: CoverageHours -> CoverageHours -> Bool
== :: CoverageHours -> CoverageHours -> Bool
$c== :: CoverageHours -> CoverageHours -> Bool
Prelude.Eq, ReadPrec [CoverageHours]
ReadPrec CoverageHours
Int -> ReadS CoverageHours
ReadS [CoverageHours]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CoverageHours]
$creadListPrec :: ReadPrec [CoverageHours]
readPrec :: ReadPrec CoverageHours
$creadPrec :: ReadPrec CoverageHours
readList :: ReadS [CoverageHours]
$creadList :: ReadS [CoverageHours]
readsPrec :: Int -> ReadS CoverageHours
$creadsPrec :: Int -> ReadS CoverageHours
Prelude.Read, Int -> CoverageHours -> ShowS
[CoverageHours] -> ShowS
CoverageHours -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CoverageHours] -> ShowS
$cshowList :: [CoverageHours] -> ShowS
show :: CoverageHours -> String
$cshow :: CoverageHours -> String
showsPrec :: Int -> CoverageHours -> ShowS
$cshowsPrec :: Int -> CoverageHours -> ShowS
Prelude.Show, forall x. Rep CoverageHours x -> CoverageHours
forall x. CoverageHours -> Rep CoverageHours x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CoverageHours x -> CoverageHours
$cfrom :: forall x. CoverageHours -> Rep CoverageHours x
Prelude.Generic)

-- |
-- Create a value of 'CoverageHours' 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:
--
-- 'coverageHoursPercentage', 'coverageHours_coverageHoursPercentage' - The percentage of instance hours that a reservation covered.
--
-- 'onDemandHours', 'coverageHours_onDemandHours' - The number of instance running hours that On-Demand Instances covered.
--
-- 'reservedHours', 'coverageHours_reservedHours' - The number of instance running hours that reservations covered.
--
-- 'totalRunningHours', 'coverageHours_totalRunningHours' - The total instance usage, in hours.
newCoverageHours ::
  CoverageHours
newCoverageHours :: CoverageHours
newCoverageHours =
  CoverageHours'
    { $sel:coverageHoursPercentage:CoverageHours' :: Maybe Text
coverageHoursPercentage =
        forall a. Maybe a
Prelude.Nothing,
      $sel:onDemandHours:CoverageHours' :: Maybe Text
onDemandHours = forall a. Maybe a
Prelude.Nothing,
      $sel:reservedHours:CoverageHours' :: Maybe Text
reservedHours = forall a. Maybe a
Prelude.Nothing,
      $sel:totalRunningHours:CoverageHours' :: Maybe Text
totalRunningHours = forall a. Maybe a
Prelude.Nothing
    }

-- | The percentage of instance hours that a reservation covered.
coverageHours_coverageHoursPercentage :: Lens.Lens' CoverageHours (Prelude.Maybe Prelude.Text)
coverageHours_coverageHoursPercentage :: Lens' CoverageHours (Maybe Text)
coverageHours_coverageHoursPercentage = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CoverageHours' {Maybe Text
coverageHoursPercentage :: Maybe Text
$sel:coverageHoursPercentage:CoverageHours' :: CoverageHours -> Maybe Text
coverageHoursPercentage} -> Maybe Text
coverageHoursPercentage) (\s :: CoverageHours
s@CoverageHours' {} Maybe Text
a -> CoverageHours
s {$sel:coverageHoursPercentage:CoverageHours' :: Maybe Text
coverageHoursPercentage = Maybe Text
a} :: CoverageHours)

-- | The number of instance running hours that On-Demand Instances covered.
coverageHours_onDemandHours :: Lens.Lens' CoverageHours (Prelude.Maybe Prelude.Text)
coverageHours_onDemandHours :: Lens' CoverageHours (Maybe Text)
coverageHours_onDemandHours = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CoverageHours' {Maybe Text
onDemandHours :: Maybe Text
$sel:onDemandHours:CoverageHours' :: CoverageHours -> Maybe Text
onDemandHours} -> Maybe Text
onDemandHours) (\s :: CoverageHours
s@CoverageHours' {} Maybe Text
a -> CoverageHours
s {$sel:onDemandHours:CoverageHours' :: Maybe Text
onDemandHours = Maybe Text
a} :: CoverageHours)

-- | The number of instance running hours that reservations covered.
coverageHours_reservedHours :: Lens.Lens' CoverageHours (Prelude.Maybe Prelude.Text)
coverageHours_reservedHours :: Lens' CoverageHours (Maybe Text)
coverageHours_reservedHours = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CoverageHours' {Maybe Text
reservedHours :: Maybe Text
$sel:reservedHours:CoverageHours' :: CoverageHours -> Maybe Text
reservedHours} -> Maybe Text
reservedHours) (\s :: CoverageHours
s@CoverageHours' {} Maybe Text
a -> CoverageHours
s {$sel:reservedHours:CoverageHours' :: Maybe Text
reservedHours = Maybe Text
a} :: CoverageHours)

-- | The total instance usage, in hours.
coverageHours_totalRunningHours :: Lens.Lens' CoverageHours (Prelude.Maybe Prelude.Text)
coverageHours_totalRunningHours :: Lens' CoverageHours (Maybe Text)
coverageHours_totalRunningHours = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CoverageHours' {Maybe Text
totalRunningHours :: Maybe Text
$sel:totalRunningHours:CoverageHours' :: CoverageHours -> Maybe Text
totalRunningHours} -> Maybe Text
totalRunningHours) (\s :: CoverageHours
s@CoverageHours' {} Maybe Text
a -> CoverageHours
s {$sel:totalRunningHours:CoverageHours' :: Maybe Text
totalRunningHours = Maybe Text
a} :: CoverageHours)

instance Data.FromJSON CoverageHours where
  parseJSON :: Value -> Parser CoverageHours
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CoverageHours"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> CoverageHours
CoverageHours'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"CoverageHoursPercentage")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"OnDemandHours")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ReservedHours")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"TotalRunningHours")
      )

instance Prelude.Hashable CoverageHours where
  hashWithSalt :: Int -> CoverageHours -> Int
hashWithSalt Int
_salt CoverageHours' {Maybe Text
totalRunningHours :: Maybe Text
reservedHours :: Maybe Text
onDemandHours :: Maybe Text
coverageHoursPercentage :: Maybe Text
$sel:totalRunningHours:CoverageHours' :: CoverageHours -> Maybe Text
$sel:reservedHours:CoverageHours' :: CoverageHours -> Maybe Text
$sel:onDemandHours:CoverageHours' :: CoverageHours -> Maybe Text
$sel:coverageHoursPercentage:CoverageHours' :: CoverageHours -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
coverageHoursPercentage
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
onDemandHours
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
reservedHours
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
totalRunningHours

instance Prelude.NFData CoverageHours where
  rnf :: CoverageHours -> ()
rnf CoverageHours' {Maybe Text
totalRunningHours :: Maybe Text
reservedHours :: Maybe Text
onDemandHours :: Maybe Text
coverageHoursPercentage :: Maybe Text
$sel:totalRunningHours:CoverageHours' :: CoverageHours -> Maybe Text
$sel:reservedHours:CoverageHours' :: CoverageHours -> Maybe Text
$sel:onDemandHours:CoverageHours' :: CoverageHours -> Maybe Text
$sel:coverageHoursPercentage:CoverageHours' :: CoverageHours -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
coverageHoursPercentage
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
onDemandHours
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
reservedHours
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
totalRunningHours