{-# 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.Shield.Types.SummarizedCounter
-- 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.Shield.Types.SummarizedCounter 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

-- | The counter that describes a DDoS attack.
--
-- /See:/ 'newSummarizedCounter' smart constructor.
data SummarizedCounter = SummarizedCounter'
  { -- | The average value of the counter for a specified time period.
    SummarizedCounter -> Maybe Double
average :: Prelude.Maybe Prelude.Double,
    -- | The maximum value of the counter for a specified time period.
    SummarizedCounter -> Maybe Double
max :: Prelude.Maybe Prelude.Double,
    -- | The number of counters for a specified time period.
    SummarizedCounter -> Maybe Int
n :: Prelude.Maybe Prelude.Int,
    -- | The counter name.
    SummarizedCounter -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The total of counter values for a specified time period.
    SummarizedCounter -> Maybe Double
sum :: Prelude.Maybe Prelude.Double,
    -- | The unit of the counters.
    SummarizedCounter -> Maybe Text
unit :: Prelude.Maybe Prelude.Text
  }
  deriving (SummarizedCounter -> SummarizedCounter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SummarizedCounter -> SummarizedCounter -> Bool
$c/= :: SummarizedCounter -> SummarizedCounter -> Bool
== :: SummarizedCounter -> SummarizedCounter -> Bool
$c== :: SummarizedCounter -> SummarizedCounter -> Bool
Prelude.Eq, ReadPrec [SummarizedCounter]
ReadPrec SummarizedCounter
Int -> ReadS SummarizedCounter
ReadS [SummarizedCounter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SummarizedCounter]
$creadListPrec :: ReadPrec [SummarizedCounter]
readPrec :: ReadPrec SummarizedCounter
$creadPrec :: ReadPrec SummarizedCounter
readList :: ReadS [SummarizedCounter]
$creadList :: ReadS [SummarizedCounter]
readsPrec :: Int -> ReadS SummarizedCounter
$creadsPrec :: Int -> ReadS SummarizedCounter
Prelude.Read, Int -> SummarizedCounter -> ShowS
[SummarizedCounter] -> ShowS
SummarizedCounter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SummarizedCounter] -> ShowS
$cshowList :: [SummarizedCounter] -> ShowS
show :: SummarizedCounter -> String
$cshow :: SummarizedCounter -> String
showsPrec :: Int -> SummarizedCounter -> ShowS
$cshowsPrec :: Int -> SummarizedCounter -> ShowS
Prelude.Show, forall x. Rep SummarizedCounter x -> SummarizedCounter
forall x. SummarizedCounter -> Rep SummarizedCounter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SummarizedCounter x -> SummarizedCounter
$cfrom :: forall x. SummarizedCounter -> Rep SummarizedCounter x
Prelude.Generic)

-- |
-- Create a value of 'SummarizedCounter' 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:
--
-- 'average', 'summarizedCounter_average' - The average value of the counter for a specified time period.
--
-- 'max', 'summarizedCounter_max' - The maximum value of the counter for a specified time period.
--
-- 'n', 'summarizedCounter_n' - The number of counters for a specified time period.
--
-- 'name', 'summarizedCounter_name' - The counter name.
--
-- 'sum', 'summarizedCounter_sum' - The total of counter values for a specified time period.
--
-- 'unit', 'summarizedCounter_unit' - The unit of the counters.
newSummarizedCounter ::
  SummarizedCounter
newSummarizedCounter :: SummarizedCounter
newSummarizedCounter =
  SummarizedCounter'
    { $sel:average:SummarizedCounter' :: Maybe Double
average = forall a. Maybe a
Prelude.Nothing,
      $sel:max:SummarizedCounter' :: Maybe Double
max = forall a. Maybe a
Prelude.Nothing,
      $sel:n:SummarizedCounter' :: Maybe Int
n = forall a. Maybe a
Prelude.Nothing,
      $sel:name:SummarizedCounter' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:sum:SummarizedCounter' :: Maybe Double
sum = forall a. Maybe a
Prelude.Nothing,
      $sel:unit:SummarizedCounter' :: Maybe Text
unit = forall a. Maybe a
Prelude.Nothing
    }

-- | The average value of the counter for a specified time period.
summarizedCounter_average :: Lens.Lens' SummarizedCounter (Prelude.Maybe Prelude.Double)
summarizedCounter_average :: Lens' SummarizedCounter (Maybe Double)
summarizedCounter_average = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SummarizedCounter' {Maybe Double
average :: Maybe Double
$sel:average:SummarizedCounter' :: SummarizedCounter -> Maybe Double
average} -> Maybe Double
average) (\s :: SummarizedCounter
s@SummarizedCounter' {} Maybe Double
a -> SummarizedCounter
s {$sel:average:SummarizedCounter' :: Maybe Double
average = Maybe Double
a} :: SummarizedCounter)

-- | The maximum value of the counter for a specified time period.
summarizedCounter_max :: Lens.Lens' SummarizedCounter (Prelude.Maybe Prelude.Double)
summarizedCounter_max :: Lens' SummarizedCounter (Maybe Double)
summarizedCounter_max = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SummarizedCounter' {Maybe Double
max :: Maybe Double
$sel:max:SummarizedCounter' :: SummarizedCounter -> Maybe Double
max} -> Maybe Double
max) (\s :: SummarizedCounter
s@SummarizedCounter' {} Maybe Double
a -> SummarizedCounter
s {$sel:max:SummarizedCounter' :: Maybe Double
max = Maybe Double
a} :: SummarizedCounter)

-- | The number of counters for a specified time period.
summarizedCounter_n :: Lens.Lens' SummarizedCounter (Prelude.Maybe Prelude.Int)
summarizedCounter_n :: Lens' SummarizedCounter (Maybe Int)
summarizedCounter_n = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SummarizedCounter' {Maybe Int
n :: Maybe Int
$sel:n:SummarizedCounter' :: SummarizedCounter -> Maybe Int
n} -> Maybe Int
n) (\s :: SummarizedCounter
s@SummarizedCounter' {} Maybe Int
a -> SummarizedCounter
s {$sel:n:SummarizedCounter' :: Maybe Int
n = Maybe Int
a} :: SummarizedCounter)

-- | The counter name.
summarizedCounter_name :: Lens.Lens' SummarizedCounter (Prelude.Maybe Prelude.Text)
summarizedCounter_name :: Lens' SummarizedCounter (Maybe Text)
summarizedCounter_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SummarizedCounter' {Maybe Text
name :: Maybe Text
$sel:name:SummarizedCounter' :: SummarizedCounter -> Maybe Text
name} -> Maybe Text
name) (\s :: SummarizedCounter
s@SummarizedCounter' {} Maybe Text
a -> SummarizedCounter
s {$sel:name:SummarizedCounter' :: Maybe Text
name = Maybe Text
a} :: SummarizedCounter)

-- | The total of counter values for a specified time period.
summarizedCounter_sum :: Lens.Lens' SummarizedCounter (Prelude.Maybe Prelude.Double)
summarizedCounter_sum :: Lens' SummarizedCounter (Maybe Double)
summarizedCounter_sum = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SummarizedCounter' {Maybe Double
sum :: Maybe Double
$sel:sum:SummarizedCounter' :: SummarizedCounter -> Maybe Double
sum} -> Maybe Double
sum) (\s :: SummarizedCounter
s@SummarizedCounter' {} Maybe Double
a -> SummarizedCounter
s {$sel:sum:SummarizedCounter' :: Maybe Double
sum = Maybe Double
a} :: SummarizedCounter)

-- | The unit of the counters.
summarizedCounter_unit :: Lens.Lens' SummarizedCounter (Prelude.Maybe Prelude.Text)
summarizedCounter_unit :: Lens' SummarizedCounter (Maybe Text)
summarizedCounter_unit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SummarizedCounter' {Maybe Text
unit :: Maybe Text
$sel:unit:SummarizedCounter' :: SummarizedCounter -> Maybe Text
unit} -> Maybe Text
unit) (\s :: SummarizedCounter
s@SummarizedCounter' {} Maybe Text
a -> SummarizedCounter
s {$sel:unit:SummarizedCounter' :: Maybe Text
unit = Maybe Text
a} :: SummarizedCounter)

instance Data.FromJSON SummarizedCounter where
  parseJSON :: Value -> Parser SummarizedCounter
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SummarizedCounter"
      ( \Object
x ->
          Maybe Double
-> Maybe Double
-> Maybe Int
-> Maybe Text
-> Maybe Double
-> Maybe Text
-> SummarizedCounter
SummarizedCounter'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Average")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Max")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"N")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Sum")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Unit")
      )

instance Prelude.Hashable SummarizedCounter where
  hashWithSalt :: Int -> SummarizedCounter -> Int
hashWithSalt Int
_salt SummarizedCounter' {Maybe Double
Maybe Int
Maybe Text
unit :: Maybe Text
sum :: Maybe Double
name :: Maybe Text
n :: Maybe Int
max :: Maybe Double
average :: Maybe Double
$sel:unit:SummarizedCounter' :: SummarizedCounter -> Maybe Text
$sel:sum:SummarizedCounter' :: SummarizedCounter -> Maybe Double
$sel:name:SummarizedCounter' :: SummarizedCounter -> Maybe Text
$sel:n:SummarizedCounter' :: SummarizedCounter -> Maybe Int
$sel:max:SummarizedCounter' :: SummarizedCounter -> Maybe Double
$sel:average:SummarizedCounter' :: SummarizedCounter -> Maybe Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
average
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
max
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
n
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
sum
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
unit

instance Prelude.NFData SummarizedCounter where
  rnf :: SummarizedCounter -> ()
rnf SummarizedCounter' {Maybe Double
Maybe Int
Maybe Text
unit :: Maybe Text
sum :: Maybe Double
name :: Maybe Text
n :: Maybe Int
max :: Maybe Double
average :: Maybe Double
$sel:unit:SummarizedCounter' :: SummarizedCounter -> Maybe Text
$sel:sum:SummarizedCounter' :: SummarizedCounter -> Maybe Double
$sel:name:SummarizedCounter' :: SummarizedCounter -> Maybe Text
$sel:n:SummarizedCounter' :: SummarizedCounter -> Maybe Int
$sel:max:SummarizedCounter' :: SummarizedCounter -> Maybe Double
$sel:average:SummarizedCounter' :: SummarizedCounter -> Maybe Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
average
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
max
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
n
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
sum
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
unit