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

import qualified Amazonka.Core as Core
import Amazonka.CostExplorer.Types.DateInterval
import Amazonka.CostExplorer.Types.SavingsPlansCoverageData
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The amount of Savings Plans eligible usage that is covered by Savings
-- Plans. All calculations consider the On-Demand equivalent of your
-- Savings Plans usage.
--
-- /See:/ 'newSavingsPlansCoverage' smart constructor.
data SavingsPlansCoverage = SavingsPlansCoverage'
  { SavingsPlansCoverage -> Maybe DateInterval
timePeriod :: Prelude.Maybe DateInterval,
    -- | The amount of Savings Plans eligible usage that the Savings Plans
    -- covered.
    SavingsPlansCoverage -> Maybe SavingsPlansCoverageData
coverage :: Prelude.Maybe SavingsPlansCoverageData,
    -- | The attribute that applies to a specific @Dimension@.
    SavingsPlansCoverage -> Maybe (HashMap Text Text)
attributes :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
  }
  deriving (SavingsPlansCoverage -> SavingsPlansCoverage -> Bool
(SavingsPlansCoverage -> SavingsPlansCoverage -> Bool)
-> (SavingsPlansCoverage -> SavingsPlansCoverage -> Bool)
-> Eq SavingsPlansCoverage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SavingsPlansCoverage -> SavingsPlansCoverage -> Bool
$c/= :: SavingsPlansCoverage -> SavingsPlansCoverage -> Bool
== :: SavingsPlansCoverage -> SavingsPlansCoverage -> Bool
$c== :: SavingsPlansCoverage -> SavingsPlansCoverage -> Bool
Prelude.Eq, ReadPrec [SavingsPlansCoverage]
ReadPrec SavingsPlansCoverage
Int -> ReadS SavingsPlansCoverage
ReadS [SavingsPlansCoverage]
(Int -> ReadS SavingsPlansCoverage)
-> ReadS [SavingsPlansCoverage]
-> ReadPrec SavingsPlansCoverage
-> ReadPrec [SavingsPlansCoverage]
-> Read SavingsPlansCoverage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SavingsPlansCoverage]
$creadListPrec :: ReadPrec [SavingsPlansCoverage]
readPrec :: ReadPrec SavingsPlansCoverage
$creadPrec :: ReadPrec SavingsPlansCoverage
readList :: ReadS [SavingsPlansCoverage]
$creadList :: ReadS [SavingsPlansCoverage]
readsPrec :: Int -> ReadS SavingsPlansCoverage
$creadsPrec :: Int -> ReadS SavingsPlansCoverage
Prelude.Read, Int -> SavingsPlansCoverage -> ShowS
[SavingsPlansCoverage] -> ShowS
SavingsPlansCoverage -> String
(Int -> SavingsPlansCoverage -> ShowS)
-> (SavingsPlansCoverage -> String)
-> ([SavingsPlansCoverage] -> ShowS)
-> Show SavingsPlansCoverage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SavingsPlansCoverage] -> ShowS
$cshowList :: [SavingsPlansCoverage] -> ShowS
show :: SavingsPlansCoverage -> String
$cshow :: SavingsPlansCoverage -> String
showsPrec :: Int -> SavingsPlansCoverage -> ShowS
$cshowsPrec :: Int -> SavingsPlansCoverage -> ShowS
Prelude.Show, (forall x. SavingsPlansCoverage -> Rep SavingsPlansCoverage x)
-> (forall x. Rep SavingsPlansCoverage x -> SavingsPlansCoverage)
-> Generic SavingsPlansCoverage
forall x. Rep SavingsPlansCoverage x -> SavingsPlansCoverage
forall x. SavingsPlansCoverage -> Rep SavingsPlansCoverage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SavingsPlansCoverage x -> SavingsPlansCoverage
$cfrom :: forall x. SavingsPlansCoverage -> Rep SavingsPlansCoverage x
Prelude.Generic)

-- |
-- Create a value of 'SavingsPlansCoverage' 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:
--
-- 'timePeriod', 'savingsPlansCoverage_timePeriod' - Undocumented member.
--
-- 'coverage', 'savingsPlansCoverage_coverage' - The amount of Savings Plans eligible usage that the Savings Plans
-- covered.
--
-- 'attributes', 'savingsPlansCoverage_attributes' - The attribute that applies to a specific @Dimension@.
newSavingsPlansCoverage ::
  SavingsPlansCoverage
newSavingsPlansCoverage :: SavingsPlansCoverage
newSavingsPlansCoverage =
  SavingsPlansCoverage' :: Maybe DateInterval
-> Maybe SavingsPlansCoverageData
-> Maybe (HashMap Text Text)
-> SavingsPlansCoverage
SavingsPlansCoverage'
    { $sel:timePeriod:SavingsPlansCoverage' :: Maybe DateInterval
timePeriod = Maybe DateInterval
forall a. Maybe a
Prelude.Nothing,
      $sel:coverage:SavingsPlansCoverage' :: Maybe SavingsPlansCoverageData
coverage = Maybe SavingsPlansCoverageData
forall a. Maybe a
Prelude.Nothing,
      $sel:attributes:SavingsPlansCoverage' :: Maybe (HashMap Text Text)
attributes = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing
    }

-- | Undocumented member.
savingsPlansCoverage_timePeriod :: Lens.Lens' SavingsPlansCoverage (Prelude.Maybe DateInterval)
savingsPlansCoverage_timePeriod :: (Maybe DateInterval -> f (Maybe DateInterval))
-> SavingsPlansCoverage -> f SavingsPlansCoverage
savingsPlansCoverage_timePeriod = (SavingsPlansCoverage -> Maybe DateInterval)
-> (SavingsPlansCoverage
    -> Maybe DateInterval -> SavingsPlansCoverage)
-> Lens
     SavingsPlansCoverage
     SavingsPlansCoverage
     (Maybe DateInterval)
     (Maybe DateInterval)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SavingsPlansCoverage' {Maybe DateInterval
timePeriod :: Maybe DateInterval
$sel:timePeriod:SavingsPlansCoverage' :: SavingsPlansCoverage -> Maybe DateInterval
timePeriod} -> Maybe DateInterval
timePeriod) (\s :: SavingsPlansCoverage
s@SavingsPlansCoverage' {} Maybe DateInterval
a -> SavingsPlansCoverage
s {$sel:timePeriod:SavingsPlansCoverage' :: Maybe DateInterval
timePeriod = Maybe DateInterval
a} :: SavingsPlansCoverage)

-- | The amount of Savings Plans eligible usage that the Savings Plans
-- covered.
savingsPlansCoverage_coverage :: Lens.Lens' SavingsPlansCoverage (Prelude.Maybe SavingsPlansCoverageData)
savingsPlansCoverage_coverage :: (Maybe SavingsPlansCoverageData
 -> f (Maybe SavingsPlansCoverageData))
-> SavingsPlansCoverage -> f SavingsPlansCoverage
savingsPlansCoverage_coverage = (SavingsPlansCoverage -> Maybe SavingsPlansCoverageData)
-> (SavingsPlansCoverage
    -> Maybe SavingsPlansCoverageData -> SavingsPlansCoverage)
-> Lens
     SavingsPlansCoverage
     SavingsPlansCoverage
     (Maybe SavingsPlansCoverageData)
     (Maybe SavingsPlansCoverageData)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SavingsPlansCoverage' {Maybe SavingsPlansCoverageData
coverage :: Maybe SavingsPlansCoverageData
$sel:coverage:SavingsPlansCoverage' :: SavingsPlansCoverage -> Maybe SavingsPlansCoverageData
coverage} -> Maybe SavingsPlansCoverageData
coverage) (\s :: SavingsPlansCoverage
s@SavingsPlansCoverage' {} Maybe SavingsPlansCoverageData
a -> SavingsPlansCoverage
s {$sel:coverage:SavingsPlansCoverage' :: Maybe SavingsPlansCoverageData
coverage = Maybe SavingsPlansCoverageData
a} :: SavingsPlansCoverage)

-- | The attribute that applies to a specific @Dimension@.
savingsPlansCoverage_attributes :: Lens.Lens' SavingsPlansCoverage (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
savingsPlansCoverage_attributes :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> SavingsPlansCoverage -> f SavingsPlansCoverage
savingsPlansCoverage_attributes = (SavingsPlansCoverage -> Maybe (HashMap Text Text))
-> (SavingsPlansCoverage
    -> Maybe (HashMap Text Text) -> SavingsPlansCoverage)
-> Lens
     SavingsPlansCoverage
     SavingsPlansCoverage
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SavingsPlansCoverage' {Maybe (HashMap Text Text)
attributes :: Maybe (HashMap Text Text)
$sel:attributes:SavingsPlansCoverage' :: SavingsPlansCoverage -> Maybe (HashMap Text Text)
attributes} -> Maybe (HashMap Text Text)
attributes) (\s :: SavingsPlansCoverage
s@SavingsPlansCoverage' {} Maybe (HashMap Text Text)
a -> SavingsPlansCoverage
s {$sel:attributes:SavingsPlansCoverage' :: Maybe (HashMap Text Text)
attributes = Maybe (HashMap Text Text)
a} :: SavingsPlansCoverage) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> SavingsPlansCoverage -> f SavingsPlansCoverage)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> SavingsPlansCoverage
-> f SavingsPlansCoverage
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON SavingsPlansCoverage where
  parseJSON :: Value -> Parser SavingsPlansCoverage
parseJSON =
    String
-> (Object -> Parser SavingsPlansCoverage)
-> Value
-> Parser SavingsPlansCoverage
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SavingsPlansCoverage"
      ( \Object
x ->
          Maybe DateInterval
-> Maybe SavingsPlansCoverageData
-> Maybe (HashMap Text Text)
-> SavingsPlansCoverage
SavingsPlansCoverage'
            (Maybe DateInterval
 -> Maybe SavingsPlansCoverageData
 -> Maybe (HashMap Text Text)
 -> SavingsPlansCoverage)
-> Parser (Maybe DateInterval)
-> Parser
     (Maybe SavingsPlansCoverageData
      -> Maybe (HashMap Text Text) -> SavingsPlansCoverage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe DateInterval)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TimePeriod")
            Parser
  (Maybe SavingsPlansCoverageData
   -> Maybe (HashMap Text Text) -> SavingsPlansCoverage)
-> Parser (Maybe SavingsPlansCoverageData)
-> Parser (Maybe (HashMap Text Text) -> SavingsPlansCoverage)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe SavingsPlansCoverageData)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Coverage")
            Parser (Maybe (HashMap Text Text) -> SavingsPlansCoverage)
-> Parser (Maybe (HashMap Text Text))
-> Parser SavingsPlansCoverage
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Attributes" Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable SavingsPlansCoverage

instance Prelude.NFData SavingsPlansCoverage