{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CostExplorer.Types.AnomalyScore where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $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 :: Lens' AnomalyScore Double
anomalyScore_maxScore = 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 :: Lens' AnomalyScore Double
anomalyScore_currentScore = 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 Data.FromJSON AnomalyScore where
  parseJSON :: Value -> Parser AnomalyScore
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AnomalyScore"
      ( \Object
x ->
          Double -> Double -> AnomalyScore
AnomalyScore'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"MaxScore")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"CurrentScore")
      )

instance Prelude.Hashable AnomalyScore where
  hashWithSalt :: Int -> AnomalyScore -> Int
hashWithSalt Int
_salt AnomalyScore' {Double
currentScore :: Double
maxScore :: Double
$sel:currentScore:AnomalyScore' :: AnomalyScore -> Double
$sel:maxScore:AnomalyScore' :: AnomalyScore -> Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Double
maxScore
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Double
currentScore

instance Prelude.NFData AnomalyScore where
  rnf :: AnomalyScore -> ()
rnf AnomalyScore' {Double
currentScore :: Double
maxScore :: Double
$sel:currentScore:AnomalyScore' :: AnomalyScore -> Double
$sel:maxScore:AnomalyScore' :: AnomalyScore -> Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Double
maxScore
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Double
currentScore