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

import qualified Amazonka.Core as Core
import Amazonka.CostExplorer.Types.CoverageCost
import Amazonka.CostExplorer.Types.CoverageHours
import Amazonka.CostExplorer.Types.CoverageNormalizedUnits
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The amount of instance usage that a reservation covered.
--
-- /See:/ 'newCoverage' smart constructor.
data Coverage = Coverage'
  { -- | The amount of instance usage that the reservation covered, in normalized
    -- units.
    Coverage -> Maybe CoverageNormalizedUnits
coverageNormalizedUnits :: Prelude.Maybe CoverageNormalizedUnits,
    -- | The amount of instance usage that the reservation covered, in hours.
    Coverage -> Maybe CoverageHours
coverageHours :: Prelude.Maybe CoverageHours,
    -- | The amount of cost that the reservation covered.
    Coverage -> Maybe CoverageCost
coverageCost :: Prelude.Maybe CoverageCost
  }
  deriving (Coverage -> Coverage -> Bool
(Coverage -> Coverage -> Bool)
-> (Coverage -> Coverage -> Bool) -> Eq Coverage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Coverage -> Coverage -> Bool
$c/= :: Coverage -> Coverage -> Bool
== :: Coverage -> Coverage -> Bool
$c== :: Coverage -> Coverage -> Bool
Prelude.Eq, ReadPrec [Coverage]
ReadPrec Coverage
Int -> ReadS Coverage
ReadS [Coverage]
(Int -> ReadS Coverage)
-> ReadS [Coverage]
-> ReadPrec Coverage
-> ReadPrec [Coverage]
-> Read Coverage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Coverage]
$creadListPrec :: ReadPrec [Coverage]
readPrec :: ReadPrec Coverage
$creadPrec :: ReadPrec Coverage
readList :: ReadS [Coverage]
$creadList :: ReadS [Coverage]
readsPrec :: Int -> ReadS Coverage
$creadsPrec :: Int -> ReadS Coverage
Prelude.Read, Int -> Coverage -> ShowS
[Coverage] -> ShowS
Coverage -> String
(Int -> Coverage -> ShowS)
-> (Coverage -> String) -> ([Coverage] -> ShowS) -> Show Coverage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Coverage] -> ShowS
$cshowList :: [Coverage] -> ShowS
show :: Coverage -> String
$cshow :: Coverage -> String
showsPrec :: Int -> Coverage -> ShowS
$cshowsPrec :: Int -> Coverage -> ShowS
Prelude.Show, (forall x. Coverage -> Rep Coverage x)
-> (forall x. Rep Coverage x -> Coverage) -> Generic Coverage
forall x. Rep Coverage x -> Coverage
forall x. Coverage -> Rep Coverage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Coverage x -> Coverage
$cfrom :: forall x. Coverage -> Rep Coverage x
Prelude.Generic)

-- |
-- Create a value of 'Coverage' 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:
--
-- 'coverageNormalizedUnits', 'coverage_coverageNormalizedUnits' - The amount of instance usage that the reservation covered, in normalized
-- units.
--
-- 'coverageHours', 'coverage_coverageHours' - The amount of instance usage that the reservation covered, in hours.
--
-- 'coverageCost', 'coverage_coverageCost' - The amount of cost that the reservation covered.
newCoverage ::
  Coverage
newCoverage :: Coverage
newCoverage =
  Coverage' :: Maybe CoverageNormalizedUnits
-> Maybe CoverageHours -> Maybe CoverageCost -> Coverage
Coverage'
    { $sel:coverageNormalizedUnits:Coverage' :: Maybe CoverageNormalizedUnits
coverageNormalizedUnits =
        Maybe CoverageNormalizedUnits
forall a. Maybe a
Prelude.Nothing,
      $sel:coverageHours:Coverage' :: Maybe CoverageHours
coverageHours = Maybe CoverageHours
forall a. Maybe a
Prelude.Nothing,
      $sel:coverageCost:Coverage' :: Maybe CoverageCost
coverageCost = Maybe CoverageCost
forall a. Maybe a
Prelude.Nothing
    }

-- | The amount of instance usage that the reservation covered, in normalized
-- units.
coverage_coverageNormalizedUnits :: Lens.Lens' Coverage (Prelude.Maybe CoverageNormalizedUnits)
coverage_coverageNormalizedUnits :: (Maybe CoverageNormalizedUnits
 -> f (Maybe CoverageNormalizedUnits))
-> Coverage -> f Coverage
coverage_coverageNormalizedUnits = (Coverage -> Maybe CoverageNormalizedUnits)
-> (Coverage -> Maybe CoverageNormalizedUnits -> Coverage)
-> Lens
     Coverage
     Coverage
     (Maybe CoverageNormalizedUnits)
     (Maybe CoverageNormalizedUnits)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Coverage' {Maybe CoverageNormalizedUnits
coverageNormalizedUnits :: Maybe CoverageNormalizedUnits
$sel:coverageNormalizedUnits:Coverage' :: Coverage -> Maybe CoverageNormalizedUnits
coverageNormalizedUnits} -> Maybe CoverageNormalizedUnits
coverageNormalizedUnits) (\s :: Coverage
s@Coverage' {} Maybe CoverageNormalizedUnits
a -> Coverage
s {$sel:coverageNormalizedUnits:Coverage' :: Maybe CoverageNormalizedUnits
coverageNormalizedUnits = Maybe CoverageNormalizedUnits
a} :: Coverage)

-- | The amount of instance usage that the reservation covered, in hours.
coverage_coverageHours :: Lens.Lens' Coverage (Prelude.Maybe CoverageHours)
coverage_coverageHours :: (Maybe CoverageHours -> f (Maybe CoverageHours))
-> Coverage -> f Coverage
coverage_coverageHours = (Coverage -> Maybe CoverageHours)
-> (Coverage -> Maybe CoverageHours -> Coverage)
-> Lens
     Coverage Coverage (Maybe CoverageHours) (Maybe CoverageHours)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Coverage' {Maybe CoverageHours
coverageHours :: Maybe CoverageHours
$sel:coverageHours:Coverage' :: Coverage -> Maybe CoverageHours
coverageHours} -> Maybe CoverageHours
coverageHours) (\s :: Coverage
s@Coverage' {} Maybe CoverageHours
a -> Coverage
s {$sel:coverageHours:Coverage' :: Maybe CoverageHours
coverageHours = Maybe CoverageHours
a} :: Coverage)

-- | The amount of cost that the reservation covered.
coverage_coverageCost :: Lens.Lens' Coverage (Prelude.Maybe CoverageCost)
coverage_coverageCost :: (Maybe CoverageCost -> f (Maybe CoverageCost))
-> Coverage -> f Coverage
coverage_coverageCost = (Coverage -> Maybe CoverageCost)
-> (Coverage -> Maybe CoverageCost -> Coverage)
-> Lens Coverage Coverage (Maybe CoverageCost) (Maybe CoverageCost)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Coverage' {Maybe CoverageCost
coverageCost :: Maybe CoverageCost
$sel:coverageCost:Coverage' :: Coverage -> Maybe CoverageCost
coverageCost} -> Maybe CoverageCost
coverageCost) (\s :: Coverage
s@Coverage' {} Maybe CoverageCost
a -> Coverage
s {$sel:coverageCost:Coverage' :: Maybe CoverageCost
coverageCost = Maybe CoverageCost
a} :: Coverage)

instance Core.FromJSON Coverage where
  parseJSON :: Value -> Parser Coverage
parseJSON =
    String -> (Object -> Parser Coverage) -> Value -> Parser Coverage
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Coverage"
      ( \Object
x ->
          Maybe CoverageNormalizedUnits
-> Maybe CoverageHours -> Maybe CoverageCost -> Coverage
Coverage'
            (Maybe CoverageNormalizedUnits
 -> Maybe CoverageHours -> Maybe CoverageCost -> Coverage)
-> Parser (Maybe CoverageNormalizedUnits)
-> Parser (Maybe CoverageHours -> Maybe CoverageCost -> Coverage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe CoverageNormalizedUnits)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CoverageNormalizedUnits")
            Parser (Maybe CoverageHours -> Maybe CoverageCost -> Coverage)
-> Parser (Maybe CoverageHours)
-> Parser (Maybe CoverageCost -> Coverage)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CoverageHours)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CoverageHours")
            Parser (Maybe CoverageCost -> Coverage)
-> Parser (Maybe CoverageCost) -> Parser Coverage
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CoverageCost)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CoverageCost")
      )

instance Prelude.Hashable Coverage

instance Prelude.NFData Coverage