{-# 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.LookoutMetrics.Types.ItemizedMetricStats
-- 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.LookoutMetrics.Types.ItemizedMetricStats where

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

-- | Aggregated statistics about a measure affected by an anomaly.
--
-- /See:/ 'newItemizedMetricStats' smart constructor.
data ItemizedMetricStats = ItemizedMetricStats'
  { -- | The name of the measure.
    ItemizedMetricStats -> Maybe Text
metricName :: Prelude.Maybe Prelude.Text,
    -- | The number of times that the measure appears.
    ItemizedMetricStats -> Maybe Int
occurrenceCount :: Prelude.Maybe Prelude.Int
  }
  deriving (ItemizedMetricStats -> ItemizedMetricStats -> Bool
(ItemizedMetricStats -> ItemizedMetricStats -> Bool)
-> (ItemizedMetricStats -> ItemizedMetricStats -> Bool)
-> Eq ItemizedMetricStats
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ItemizedMetricStats -> ItemizedMetricStats -> Bool
$c/= :: ItemizedMetricStats -> ItemizedMetricStats -> Bool
== :: ItemizedMetricStats -> ItemizedMetricStats -> Bool
$c== :: ItemizedMetricStats -> ItemizedMetricStats -> Bool
Prelude.Eq, ReadPrec [ItemizedMetricStats]
ReadPrec ItemizedMetricStats
Int -> ReadS ItemizedMetricStats
ReadS [ItemizedMetricStats]
(Int -> ReadS ItemizedMetricStats)
-> ReadS [ItemizedMetricStats]
-> ReadPrec ItemizedMetricStats
-> ReadPrec [ItemizedMetricStats]
-> Read ItemizedMetricStats
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ItemizedMetricStats]
$creadListPrec :: ReadPrec [ItemizedMetricStats]
readPrec :: ReadPrec ItemizedMetricStats
$creadPrec :: ReadPrec ItemizedMetricStats
readList :: ReadS [ItemizedMetricStats]
$creadList :: ReadS [ItemizedMetricStats]
readsPrec :: Int -> ReadS ItemizedMetricStats
$creadsPrec :: Int -> ReadS ItemizedMetricStats
Prelude.Read, Int -> ItemizedMetricStats -> ShowS
[ItemizedMetricStats] -> ShowS
ItemizedMetricStats -> String
(Int -> ItemizedMetricStats -> ShowS)
-> (ItemizedMetricStats -> String)
-> ([ItemizedMetricStats] -> ShowS)
-> Show ItemizedMetricStats
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ItemizedMetricStats] -> ShowS
$cshowList :: [ItemizedMetricStats] -> ShowS
show :: ItemizedMetricStats -> String
$cshow :: ItemizedMetricStats -> String
showsPrec :: Int -> ItemizedMetricStats -> ShowS
$cshowsPrec :: Int -> ItemizedMetricStats -> ShowS
Prelude.Show, (forall x. ItemizedMetricStats -> Rep ItemizedMetricStats x)
-> (forall x. Rep ItemizedMetricStats x -> ItemizedMetricStats)
-> Generic ItemizedMetricStats
forall x. Rep ItemizedMetricStats x -> ItemizedMetricStats
forall x. ItemizedMetricStats -> Rep ItemizedMetricStats x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ItemizedMetricStats x -> ItemizedMetricStats
$cfrom :: forall x. ItemizedMetricStats -> Rep ItemizedMetricStats x
Prelude.Generic)

-- |
-- Create a value of 'ItemizedMetricStats' 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:
--
-- 'metricName', 'itemizedMetricStats_metricName' - The name of the measure.
--
-- 'occurrenceCount', 'itemizedMetricStats_occurrenceCount' - The number of times that the measure appears.
newItemizedMetricStats ::
  ItemizedMetricStats
newItemizedMetricStats :: ItemizedMetricStats
newItemizedMetricStats =
  ItemizedMetricStats' :: Maybe Text -> Maybe Int -> ItemizedMetricStats
ItemizedMetricStats'
    { $sel:metricName:ItemizedMetricStats' :: Maybe Text
metricName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:occurrenceCount:ItemizedMetricStats' :: Maybe Int
occurrenceCount = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the measure.
itemizedMetricStats_metricName :: Lens.Lens' ItemizedMetricStats (Prelude.Maybe Prelude.Text)
itemizedMetricStats_metricName :: (Maybe Text -> f (Maybe Text))
-> ItemizedMetricStats -> f ItemizedMetricStats
itemizedMetricStats_metricName = (ItemizedMetricStats -> Maybe Text)
-> (ItemizedMetricStats -> Maybe Text -> ItemizedMetricStats)
-> Lens
     ItemizedMetricStats ItemizedMetricStats (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ItemizedMetricStats' {Maybe Text
metricName :: Maybe Text
$sel:metricName:ItemizedMetricStats' :: ItemizedMetricStats -> Maybe Text
metricName} -> Maybe Text
metricName) (\s :: ItemizedMetricStats
s@ItemizedMetricStats' {} Maybe Text
a -> ItemizedMetricStats
s {$sel:metricName:ItemizedMetricStats' :: Maybe Text
metricName = Maybe Text
a} :: ItemizedMetricStats)

-- | The number of times that the measure appears.
itemizedMetricStats_occurrenceCount :: Lens.Lens' ItemizedMetricStats (Prelude.Maybe Prelude.Int)
itemizedMetricStats_occurrenceCount :: (Maybe Int -> f (Maybe Int))
-> ItemizedMetricStats -> f ItemizedMetricStats
itemizedMetricStats_occurrenceCount = (ItemizedMetricStats -> Maybe Int)
-> (ItemizedMetricStats -> Maybe Int -> ItemizedMetricStats)
-> Lens
     ItemizedMetricStats ItemizedMetricStats (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ItemizedMetricStats' {Maybe Int
occurrenceCount :: Maybe Int
$sel:occurrenceCount:ItemizedMetricStats' :: ItemizedMetricStats -> Maybe Int
occurrenceCount} -> Maybe Int
occurrenceCount) (\s :: ItemizedMetricStats
s@ItemizedMetricStats' {} Maybe Int
a -> ItemizedMetricStats
s {$sel:occurrenceCount:ItemizedMetricStats' :: Maybe Int
occurrenceCount = Maybe Int
a} :: ItemizedMetricStats)

instance Core.FromJSON ItemizedMetricStats where
  parseJSON :: Value -> Parser ItemizedMetricStats
parseJSON =
    String
-> (Object -> Parser ItemizedMetricStats)
-> Value
-> Parser ItemizedMetricStats
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ItemizedMetricStats"
      ( \Object
x ->
          Maybe Text -> Maybe Int -> ItemizedMetricStats
ItemizedMetricStats'
            (Maybe Text -> Maybe Int -> ItemizedMetricStats)
-> Parser (Maybe Text) -> Parser (Maybe Int -> ItemizedMetricStats)
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
"MetricName")
            Parser (Maybe Int -> ItemizedMetricStats)
-> Parser (Maybe Int) -> Parser ItemizedMetricStats
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"OccurrenceCount")
      )

instance Prelude.Hashable ItemizedMetricStats

instance Prelude.NFData ItemizedMetricStats