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

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

-- | The aggregated value for a metric.
--
-- /See:/ 'newMetricValue' smart constructor.
data MetricValue = MetricValue'
  { -- | The actual number that represents the metric.
    MetricValue -> Maybe Text
amount :: Prelude.Maybe Prelude.Text,
    -- | The unit that the metric is given in.
    MetricValue -> Maybe Text
unit :: Prelude.Maybe Prelude.Text
  }
  deriving (MetricValue -> MetricValue -> Bool
(MetricValue -> MetricValue -> Bool)
-> (MetricValue -> MetricValue -> Bool) -> Eq MetricValue
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetricValue -> MetricValue -> Bool
$c/= :: MetricValue -> MetricValue -> Bool
== :: MetricValue -> MetricValue -> Bool
$c== :: MetricValue -> MetricValue -> Bool
Prelude.Eq, ReadPrec [MetricValue]
ReadPrec MetricValue
Int -> ReadS MetricValue
ReadS [MetricValue]
(Int -> ReadS MetricValue)
-> ReadS [MetricValue]
-> ReadPrec MetricValue
-> ReadPrec [MetricValue]
-> Read MetricValue
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MetricValue]
$creadListPrec :: ReadPrec [MetricValue]
readPrec :: ReadPrec MetricValue
$creadPrec :: ReadPrec MetricValue
readList :: ReadS [MetricValue]
$creadList :: ReadS [MetricValue]
readsPrec :: Int -> ReadS MetricValue
$creadsPrec :: Int -> ReadS MetricValue
Prelude.Read, Int -> MetricValue -> ShowS
[MetricValue] -> ShowS
MetricValue -> String
(Int -> MetricValue -> ShowS)
-> (MetricValue -> String)
-> ([MetricValue] -> ShowS)
-> Show MetricValue
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MetricValue] -> ShowS
$cshowList :: [MetricValue] -> ShowS
show :: MetricValue -> String
$cshow :: MetricValue -> String
showsPrec :: Int -> MetricValue -> ShowS
$cshowsPrec :: Int -> MetricValue -> ShowS
Prelude.Show, (forall x. MetricValue -> Rep MetricValue x)
-> (forall x. Rep MetricValue x -> MetricValue)
-> Generic MetricValue
forall x. Rep MetricValue x -> MetricValue
forall x. MetricValue -> Rep MetricValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MetricValue x -> MetricValue
$cfrom :: forall x. MetricValue -> Rep MetricValue x
Prelude.Generic)

-- |
-- Create a value of 'MetricValue' 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:
--
-- 'amount', 'metricValue_amount' - The actual number that represents the metric.
--
-- 'unit', 'metricValue_unit' - The unit that the metric is given in.
newMetricValue ::
  MetricValue
newMetricValue :: MetricValue
newMetricValue =
  MetricValue' :: Maybe Text -> Maybe Text -> MetricValue
MetricValue'
    { $sel:amount:MetricValue' :: Maybe Text
amount = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:unit:MetricValue' :: Maybe Text
unit = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The actual number that represents the metric.
metricValue_amount :: Lens.Lens' MetricValue (Prelude.Maybe Prelude.Text)
metricValue_amount :: (Maybe Text -> f (Maybe Text)) -> MetricValue -> f MetricValue
metricValue_amount = (MetricValue -> Maybe Text)
-> (MetricValue -> Maybe Text -> MetricValue)
-> Lens MetricValue MetricValue (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricValue' {Maybe Text
amount :: Maybe Text
$sel:amount:MetricValue' :: MetricValue -> Maybe Text
amount} -> Maybe Text
amount) (\s :: MetricValue
s@MetricValue' {} Maybe Text
a -> MetricValue
s {$sel:amount:MetricValue' :: Maybe Text
amount = Maybe Text
a} :: MetricValue)

-- | The unit that the metric is given in.
metricValue_unit :: Lens.Lens' MetricValue (Prelude.Maybe Prelude.Text)
metricValue_unit :: (Maybe Text -> f (Maybe Text)) -> MetricValue -> f MetricValue
metricValue_unit = (MetricValue -> Maybe Text)
-> (MetricValue -> Maybe Text -> MetricValue)
-> Lens MetricValue MetricValue (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricValue' {Maybe Text
unit :: Maybe Text
$sel:unit:MetricValue' :: MetricValue -> Maybe Text
unit} -> Maybe Text
unit) (\s :: MetricValue
s@MetricValue' {} Maybe Text
a -> MetricValue
s {$sel:unit:MetricValue' :: Maybe Text
unit = Maybe Text
a} :: MetricValue)

instance Core.FromJSON MetricValue where
  parseJSON :: Value -> Parser MetricValue
parseJSON =
    String
-> (Object -> Parser MetricValue) -> Value -> Parser MetricValue
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MetricValue"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> MetricValue
MetricValue'
            (Maybe Text -> Maybe Text -> MetricValue)
-> Parser (Maybe Text) -> Parser (Maybe Text -> MetricValue)
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
"Amount")
            Parser (Maybe Text -> MetricValue)
-> Parser (Maybe Text) -> Parser MetricValue
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
"Unit")
      )

instance Prelude.Hashable MetricValue

instance Prelude.NFData MetricValue