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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 total instance usage, in hours.
    CoverageHours -> Maybe Text
totalRunningHours :: Prelude.Maybe Prelude.Text,
    -- | The number of instance running hours that reservations covered.
    CoverageHours -> Maybe Text
reservedHours :: Prelude.Maybe Prelude.Text
  }
  deriving (CoverageHours -> CoverageHours -> Bool
(CoverageHours -> CoverageHours -> Bool)
-> (CoverageHours -> CoverageHours -> Bool) -> Eq CoverageHours
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]
(Int -> ReadS CoverageHours)
-> ReadS [CoverageHours]
-> ReadPrec CoverageHours
-> ReadPrec [CoverageHours]
-> Read 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
(Int -> CoverageHours -> ShowS)
-> (CoverageHours -> String)
-> ([CoverageHours] -> ShowS)
-> Show CoverageHours
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. CoverageHours -> Rep CoverageHours x)
-> (forall x. Rep CoverageHours x -> CoverageHours)
-> Generic CoverageHours
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.
--
-- 'totalRunningHours', 'coverageHours_totalRunningHours' - The total instance usage, in hours.
--
-- 'reservedHours', 'coverageHours_reservedHours' - The number of instance running hours that reservations covered.
newCoverageHours ::
  CoverageHours
newCoverageHours :: CoverageHours
newCoverageHours =
  CoverageHours' :: Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> CoverageHours
CoverageHours'
    { $sel:coverageHoursPercentage:CoverageHours' :: Maybe Text
coverageHoursPercentage =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:onDemandHours:CoverageHours' :: Maybe Text
onDemandHours = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:totalRunningHours:CoverageHours' :: Maybe Text
totalRunningHours = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:reservedHours:CoverageHours' :: Maybe Text
reservedHours = Maybe Text
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 :: (Maybe Text -> f (Maybe Text)) -> CoverageHours -> f CoverageHours
coverageHours_coverageHoursPercentage = (CoverageHours -> Maybe Text)
-> (CoverageHours -> Maybe Text -> CoverageHours)
-> Lens CoverageHours CoverageHours (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text)) -> CoverageHours -> f CoverageHours
coverageHours_onDemandHours = (CoverageHours -> Maybe Text)
-> (CoverageHours -> Maybe Text -> CoverageHours)
-> Lens CoverageHours CoverageHours (Maybe Text) (Maybe Text)
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 total instance usage, in hours.
coverageHours_totalRunningHours :: Lens.Lens' CoverageHours (Prelude.Maybe Prelude.Text)
coverageHours_totalRunningHours :: (Maybe Text -> f (Maybe Text)) -> CoverageHours -> f CoverageHours
coverageHours_totalRunningHours = (CoverageHours -> Maybe Text)
-> (CoverageHours -> Maybe Text -> CoverageHours)
-> Lens CoverageHours CoverageHours (Maybe Text) (Maybe Text)
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)

-- | The number of instance running hours that reservations covered.
coverageHours_reservedHours :: Lens.Lens' CoverageHours (Prelude.Maybe Prelude.Text)
coverageHours_reservedHours :: (Maybe Text -> f (Maybe Text)) -> CoverageHours -> f CoverageHours
coverageHours_reservedHours = (CoverageHours -> Maybe Text)
-> (CoverageHours -> Maybe Text -> CoverageHours)
-> Lens CoverageHours CoverageHours (Maybe Text) (Maybe Text)
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)

instance Core.FromJSON CoverageHours where
  parseJSON :: Value -> Parser CoverageHours
parseJSON =
    String
-> (Object -> Parser CoverageHours)
-> Value
-> Parser CoverageHours
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CoverageHours"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> CoverageHours
CoverageHours'
            (Maybe Text
 -> Maybe Text -> Maybe Text -> Maybe Text -> CoverageHours)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Maybe Text -> CoverageHours)
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
"CoverageHoursPercentage")
            Parser (Maybe Text -> Maybe Text -> Maybe Text -> CoverageHours)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> CoverageHours)
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
"OnDemandHours")
            Parser (Maybe Text -> Maybe Text -> CoverageHours)
-> Parser (Maybe Text) -> Parser (Maybe Text -> CoverageHours)
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
"TotalRunningHours")
            Parser (Maybe Text -> CoverageHours)
-> Parser (Maybe Text) -> Parser CoverageHours
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
"ReservedHours")
      )

instance Prelude.Hashable CoverageHours

instance Prelude.NFData CoverageHours