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

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

-- | Quantifies the anomaly. The higher score means that it\'s more
-- anomalous.
--
-- /See:/ 'newAnomalyScore' smart constructor.
data AnomalyScore = AnomalyScore'
  { -- | The maximum score that\'s observed during the @AnomalyDateInterval@.
    AnomalyScore -> Double
maxScore :: Prelude.Double,
    -- | The last observed score.
    AnomalyScore -> Double
currentScore :: Prelude.Double
  }
  deriving (AnomalyScore -> AnomalyScore -> Bool
(AnomalyScore -> AnomalyScore -> Bool)
-> (AnomalyScore -> AnomalyScore -> Bool) -> Eq AnomalyScore
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AnomalyScore -> AnomalyScore -> Bool
$c/= :: AnomalyScore -> AnomalyScore -> Bool
== :: AnomalyScore -> AnomalyScore -> Bool
$c== :: AnomalyScore -> AnomalyScore -> Bool
Prelude.Eq, ReadPrec [AnomalyScore]
ReadPrec AnomalyScore
Int -> ReadS AnomalyScore
ReadS [AnomalyScore]
(Int -> ReadS AnomalyScore)
-> ReadS [AnomalyScore]
-> ReadPrec AnomalyScore
-> ReadPrec [AnomalyScore]
-> Read AnomalyScore
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AnomalyScore]
$creadListPrec :: ReadPrec [AnomalyScore]
readPrec :: ReadPrec AnomalyScore
$creadPrec :: ReadPrec AnomalyScore
readList :: ReadS [AnomalyScore]
$creadList :: ReadS [AnomalyScore]
readsPrec :: Int -> ReadS AnomalyScore
$creadsPrec :: Int -> ReadS AnomalyScore
Prelude.Read, Int -> AnomalyScore -> ShowS
[AnomalyScore] -> ShowS
AnomalyScore -> String
(Int -> AnomalyScore -> ShowS)
-> (AnomalyScore -> String)
-> ([AnomalyScore] -> ShowS)
-> Show AnomalyScore
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AnomalyScore] -> ShowS
$cshowList :: [AnomalyScore] -> ShowS
show :: AnomalyScore -> String
$cshow :: AnomalyScore -> String
showsPrec :: Int -> AnomalyScore -> ShowS
$cshowsPrec :: Int -> AnomalyScore -> ShowS
Prelude.Show, (forall x. AnomalyScore -> Rep AnomalyScore x)
-> (forall x. Rep AnomalyScore x -> AnomalyScore)
-> Generic AnomalyScore
forall x. Rep AnomalyScore x -> AnomalyScore
forall x. AnomalyScore -> Rep AnomalyScore x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AnomalyScore x -> AnomalyScore
$cfrom :: forall x. AnomalyScore -> Rep AnomalyScore x
Prelude.Generic)

-- |
-- Create a value of 'AnomalyScore' 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:
--
-- 'maxScore', 'anomalyScore_maxScore' - The maximum score that\'s observed during the @AnomalyDateInterval@.
--
-- 'currentScore', 'anomalyScore_currentScore' - The last observed score.
newAnomalyScore ::
  -- | 'maxScore'
  Prelude.Double ->
  -- | 'currentScore'
  Prelude.Double ->
  AnomalyScore
newAnomalyScore :: Double -> Double -> AnomalyScore
newAnomalyScore Double
pMaxScore_ Double
pCurrentScore_ =
  AnomalyScore' :: Double -> Double -> AnomalyScore
AnomalyScore'
    { $sel:maxScore:AnomalyScore' :: Double
maxScore = Double
pMaxScore_,
      $sel:currentScore:AnomalyScore' :: Double
currentScore = Double
pCurrentScore_
    }

-- | The maximum score that\'s observed during the @AnomalyDateInterval@.
anomalyScore_maxScore :: Lens.Lens' AnomalyScore Prelude.Double
anomalyScore_maxScore :: (Double -> f Double) -> AnomalyScore -> f AnomalyScore
anomalyScore_maxScore = (AnomalyScore -> Double)
-> (AnomalyScore -> Double -> AnomalyScore)
-> Lens AnomalyScore AnomalyScore Double Double
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnomalyScore' {Double
maxScore :: Double
$sel:maxScore:AnomalyScore' :: AnomalyScore -> Double
maxScore} -> Double
maxScore) (\s :: AnomalyScore
s@AnomalyScore' {} Double
a -> AnomalyScore
s {$sel:maxScore:AnomalyScore' :: Double
maxScore = Double
a} :: AnomalyScore)

-- | The last observed score.
anomalyScore_currentScore :: Lens.Lens' AnomalyScore Prelude.Double
anomalyScore_currentScore :: (Double -> f Double) -> AnomalyScore -> f AnomalyScore
anomalyScore_currentScore = (AnomalyScore -> Double)
-> (AnomalyScore -> Double -> AnomalyScore)
-> Lens AnomalyScore AnomalyScore Double Double
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnomalyScore' {Double
currentScore :: Double
$sel:currentScore:AnomalyScore' :: AnomalyScore -> Double
currentScore} -> Double
currentScore) (\s :: AnomalyScore
s@AnomalyScore' {} Double
a -> AnomalyScore
s {$sel:currentScore:AnomalyScore' :: Double
currentScore = Double
a} :: AnomalyScore)

instance Core.FromJSON AnomalyScore where
  parseJSON :: Value -> Parser AnomalyScore
parseJSON =
    String
-> (Object -> Parser AnomalyScore) -> Value -> Parser AnomalyScore
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AnomalyScore"
      ( \Object
x ->
          Double -> Double -> AnomalyScore
AnomalyScore'
            (Double -> Double -> AnomalyScore)
-> Parser Double -> Parser (Double -> AnomalyScore)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Double
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"MaxScore")
            Parser (Double -> AnomalyScore)
-> Parser Double -> Parser AnomalyScore
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
"CurrentScore")
      )

instance Prelude.Hashable AnomalyScore

instance Prelude.NFData AnomalyScore