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

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

-- | The dollar value of the anomaly.
--
-- /See:/ 'newImpact' smart constructor.
data Impact = Impact'
  { -- | The cumulative dollar value that\'s observed for an anomaly.
    Impact -> Maybe Double
totalImpact :: Prelude.Maybe Prelude.Double,
    -- | The maximum dollar value that\'s observed for an anomaly.
    Impact -> Double
maxImpact :: Prelude.Double
  }
  deriving (Impact -> Impact -> Bool
(Impact -> Impact -> Bool)
-> (Impact -> Impact -> Bool) -> Eq Impact
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Impact -> Impact -> Bool
$c/= :: Impact -> Impact -> Bool
== :: Impact -> Impact -> Bool
$c== :: Impact -> Impact -> Bool
Prelude.Eq, ReadPrec [Impact]
ReadPrec Impact
Int -> ReadS Impact
ReadS [Impact]
(Int -> ReadS Impact)
-> ReadS [Impact]
-> ReadPrec Impact
-> ReadPrec [Impact]
-> Read Impact
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Impact]
$creadListPrec :: ReadPrec [Impact]
readPrec :: ReadPrec Impact
$creadPrec :: ReadPrec Impact
readList :: ReadS [Impact]
$creadList :: ReadS [Impact]
readsPrec :: Int -> ReadS Impact
$creadsPrec :: Int -> ReadS Impact
Prelude.Read, Int -> Impact -> ShowS
[Impact] -> ShowS
Impact -> String
(Int -> Impact -> ShowS)
-> (Impact -> String) -> ([Impact] -> ShowS) -> Show Impact
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Impact] -> ShowS
$cshowList :: [Impact] -> ShowS
show :: Impact -> String
$cshow :: Impact -> String
showsPrec :: Int -> Impact -> ShowS
$cshowsPrec :: Int -> Impact -> ShowS
Prelude.Show, (forall x. Impact -> Rep Impact x)
-> (forall x. Rep Impact x -> Impact) -> Generic Impact
forall x. Rep Impact x -> Impact
forall x. Impact -> Rep Impact x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Impact x -> Impact
$cfrom :: forall x. Impact -> Rep Impact x
Prelude.Generic)

-- |
-- Create a value of 'Impact' 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:
--
-- 'totalImpact', 'impact_totalImpact' - The cumulative dollar value that\'s observed for an anomaly.
--
-- 'maxImpact', 'impact_maxImpact' - The maximum dollar value that\'s observed for an anomaly.
newImpact ::
  -- | 'maxImpact'
  Prelude.Double ->
  Impact
newImpact :: Double -> Impact
newImpact Double
pMaxImpact_ =
  Impact' :: Maybe Double -> Double -> Impact
Impact'
    { $sel:totalImpact:Impact' :: Maybe Double
totalImpact = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:maxImpact:Impact' :: Double
maxImpact = Double
pMaxImpact_
    }

-- | The cumulative dollar value that\'s observed for an anomaly.
impact_totalImpact :: Lens.Lens' Impact (Prelude.Maybe Prelude.Double)
impact_totalImpact :: (Maybe Double -> f (Maybe Double)) -> Impact -> f Impact
impact_totalImpact = (Impact -> Maybe Double)
-> (Impact -> Maybe Double -> Impact)
-> Lens Impact Impact (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Impact' {Maybe Double
totalImpact :: Maybe Double
$sel:totalImpact:Impact' :: Impact -> Maybe Double
totalImpact} -> Maybe Double
totalImpact) (\s :: Impact
s@Impact' {} Maybe Double
a -> Impact
s {$sel:totalImpact:Impact' :: Maybe Double
totalImpact = Maybe Double
a} :: Impact)

-- | The maximum dollar value that\'s observed for an anomaly.
impact_maxImpact :: Lens.Lens' Impact Prelude.Double
impact_maxImpact :: (Double -> f Double) -> Impact -> f Impact
impact_maxImpact = (Impact -> Double)
-> (Impact -> Double -> Impact) -> Lens Impact Impact Double Double
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Impact' {Double
maxImpact :: Double
$sel:maxImpact:Impact' :: Impact -> Double
maxImpact} -> Double
maxImpact) (\s :: Impact
s@Impact' {} Double
a -> Impact
s {$sel:maxImpact:Impact' :: Double
maxImpact = Double
a} :: Impact)

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

instance Prelude.Hashable Impact

instance Prelude.NFData Impact