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

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

-- | The counter that describes a DDoS attack.
--
-- /See:/ 'newSummarizedCounter' smart constructor.
data SummarizedCounter = SummarizedCounter'
  { -- | The maximum value of the counter for a specified time period.
    SummarizedCounter -> Maybe Double
max :: Prelude.Maybe Prelude.Double,
    -- | The average value of the counter for a specified time period.
    SummarizedCounter -> Maybe Double
average :: 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
(SummarizedCounter -> SummarizedCounter -> Bool)
-> (SummarizedCounter -> SummarizedCounter -> Bool)
-> Eq SummarizedCounter
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]
(Int -> ReadS SummarizedCounter)
-> ReadS [SummarizedCounter]
-> ReadPrec SummarizedCounter
-> ReadPrec [SummarizedCounter]
-> Read 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
(Int -> SummarizedCounter -> ShowS)
-> (SummarizedCounter -> String)
-> ([SummarizedCounter] -> ShowS)
-> Show SummarizedCounter
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. SummarizedCounter -> Rep SummarizedCounter x)
-> (forall x. Rep SummarizedCounter x -> SummarizedCounter)
-> Generic SummarizedCounter
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:
--
-- 'max', 'summarizedCounter_max' - The maximum value of the counter for a specified time period.
--
-- 'average', 'summarizedCounter_average' - The average 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' :: Maybe Double
-> Maybe Double
-> Maybe Int
-> Maybe Text
-> Maybe Double
-> Maybe Text
-> SummarizedCounter
SummarizedCounter'
    { $sel:max:SummarizedCounter' :: Maybe Double
max = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:average:SummarizedCounter' :: Maybe Double
average = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:n:SummarizedCounter' :: Maybe Int
n = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:name:SummarizedCounter' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sum:SummarizedCounter' :: Maybe Double
sum = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:unit:SummarizedCounter' :: Maybe Text
unit = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum value of the counter for a specified time period.
summarizedCounter_max :: Lens.Lens' SummarizedCounter (Prelude.Maybe Prelude.Double)
summarizedCounter_max :: (Maybe Double -> f (Maybe Double))
-> SummarizedCounter -> f SummarizedCounter
summarizedCounter_max = (SummarizedCounter -> Maybe Double)
-> (SummarizedCounter -> Maybe Double -> SummarizedCounter)
-> Lens
     SummarizedCounter SummarizedCounter (Maybe Double) (Maybe Double)
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 average value of the counter for a specified time period.
summarizedCounter_average :: Lens.Lens' SummarizedCounter (Prelude.Maybe Prelude.Double)
summarizedCounter_average :: (Maybe Double -> f (Maybe Double))
-> SummarizedCounter -> f SummarizedCounter
summarizedCounter_average = (SummarizedCounter -> Maybe Double)
-> (SummarizedCounter -> Maybe Double -> SummarizedCounter)
-> Lens
     SummarizedCounter SummarizedCounter (Maybe Double) (Maybe Double)
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 number of counters for a specified time period.
summarizedCounter_n :: Lens.Lens' SummarizedCounter (Prelude.Maybe Prelude.Int)
summarizedCounter_n :: (Maybe Int -> f (Maybe Int))
-> SummarizedCounter -> f SummarizedCounter
summarizedCounter_n = (SummarizedCounter -> Maybe Int)
-> (SummarizedCounter -> Maybe Int -> SummarizedCounter)
-> Lens SummarizedCounter SummarizedCounter (Maybe Int) (Maybe Int)
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 :: (Maybe Text -> f (Maybe Text))
-> SummarizedCounter -> f SummarizedCounter
summarizedCounter_name = (SummarizedCounter -> Maybe Text)
-> (SummarizedCounter -> Maybe Text -> SummarizedCounter)
-> Lens
     SummarizedCounter SummarizedCounter (Maybe Text) (Maybe Text)
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 :: (Maybe Double -> f (Maybe Double))
-> SummarizedCounter -> f SummarizedCounter
summarizedCounter_sum = (SummarizedCounter -> Maybe Double)
-> (SummarizedCounter -> Maybe Double -> SummarizedCounter)
-> Lens
     SummarizedCounter SummarizedCounter (Maybe Double) (Maybe Double)
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 :: (Maybe Text -> f (Maybe Text))
-> SummarizedCounter -> f SummarizedCounter
summarizedCounter_unit = (SummarizedCounter -> Maybe Text)
-> (SummarizedCounter -> Maybe Text -> SummarizedCounter)
-> Lens
     SummarizedCounter SummarizedCounter (Maybe Text) (Maybe Text)
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 Core.FromJSON SummarizedCounter where
  parseJSON :: Value -> Parser SummarizedCounter
parseJSON =
    String
-> (Object -> Parser SummarizedCounter)
-> Value
-> Parser SummarizedCounter
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SummarizedCounter"
      ( \Object
x ->
          Maybe Double
-> Maybe Double
-> Maybe Int
-> Maybe Text
-> Maybe Double
-> Maybe Text
-> SummarizedCounter
SummarizedCounter'
            (Maybe Double
 -> Maybe Double
 -> Maybe Int
 -> Maybe Text
 -> Maybe Double
 -> Maybe Text
 -> SummarizedCounter)
-> Parser (Maybe Double)
-> Parser
     (Maybe Double
      -> Maybe Int
      -> Maybe Text
      -> Maybe Double
      -> Maybe Text
      -> SummarizedCounter)
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
"Max")
            Parser
  (Maybe Double
   -> Maybe Int
   -> Maybe Text
   -> Maybe Double
   -> Maybe Text
   -> SummarizedCounter)
-> Parser (Maybe Double)
-> Parser
     (Maybe Int
      -> Maybe Text -> Maybe Double -> Maybe Text -> SummarizedCounter)
forall (f :: * -> *) a b. Applicative f => 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
"Average")
            Parser
  (Maybe Int
   -> Maybe Text -> Maybe Double -> Maybe Text -> SummarizedCounter)
-> Parser (Maybe Int)
-> Parser
     (Maybe Text -> Maybe Double -> Maybe Text -> SummarizedCounter)
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
"N")
            Parser
  (Maybe Text -> Maybe Double -> Maybe Text -> SummarizedCounter)
-> Parser (Maybe Text)
-> Parser (Maybe Double -> Maybe Text -> SummarizedCounter)
forall (f :: * -> *) a b. Applicative f => 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
"Name")
            Parser (Maybe Double -> Maybe Text -> SummarizedCounter)
-> Parser (Maybe Double)
-> Parser (Maybe Text -> SummarizedCounter)
forall (f :: * -> *) a b. Applicative f => 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
"Sum")
            Parser (Maybe Text -> SummarizedCounter)
-> Parser (Maybe Text) -> Parser SummarizedCounter
forall (f :: * -> *) a b. Applicative f => 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
"Unit")
      )

instance Prelude.Hashable SummarizedCounter

instance Prelude.NFData SummarizedCounter