{-# 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.AttackVolume
-- 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.AttackVolume 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
import Amazonka.Shield.Types.AttackVolumeStatistics

-- | Information about the volume of attacks during the time period, included
-- in an AttackStatisticsDataItem. If the accompanying @AttackCount@ in the
-- statistics object is zero, this setting might be empty.
--
-- /See:/ 'newAttackVolume' smart constructor.
data AttackVolume = AttackVolume'
  { -- | A statistics object that uses bits per second as the unit. This is
    -- included for network level attacks.
    AttackVolume -> Maybe AttackVolumeStatistics
bitsPerSecond :: Prelude.Maybe AttackVolumeStatistics,
    -- | A statistics object that uses packets per second as the unit. This is
    -- included for network level attacks.
    AttackVolume -> Maybe AttackVolumeStatistics
packetsPerSecond :: Prelude.Maybe AttackVolumeStatistics,
    -- | A statistics object that uses requests per second as the unit. This is
    -- included for application level attacks, and is only available for
    -- accounts that are subscribed to Shield Advanced.
    AttackVolume -> Maybe AttackVolumeStatistics
requestsPerSecond :: Prelude.Maybe AttackVolumeStatistics
  }
  deriving (AttackVolume -> AttackVolume -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttackVolume -> AttackVolume -> Bool
$c/= :: AttackVolume -> AttackVolume -> Bool
== :: AttackVolume -> AttackVolume -> Bool
$c== :: AttackVolume -> AttackVolume -> Bool
Prelude.Eq, ReadPrec [AttackVolume]
ReadPrec AttackVolume
Int -> ReadS AttackVolume
ReadS [AttackVolume]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AttackVolume]
$creadListPrec :: ReadPrec [AttackVolume]
readPrec :: ReadPrec AttackVolume
$creadPrec :: ReadPrec AttackVolume
readList :: ReadS [AttackVolume]
$creadList :: ReadS [AttackVolume]
readsPrec :: Int -> ReadS AttackVolume
$creadsPrec :: Int -> ReadS AttackVolume
Prelude.Read, Int -> AttackVolume -> ShowS
[AttackVolume] -> ShowS
AttackVolume -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AttackVolume] -> ShowS
$cshowList :: [AttackVolume] -> ShowS
show :: AttackVolume -> String
$cshow :: AttackVolume -> String
showsPrec :: Int -> AttackVolume -> ShowS
$cshowsPrec :: Int -> AttackVolume -> ShowS
Prelude.Show, forall x. Rep AttackVolume x -> AttackVolume
forall x. AttackVolume -> Rep AttackVolume x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AttackVolume x -> AttackVolume
$cfrom :: forall x. AttackVolume -> Rep AttackVolume x
Prelude.Generic)

-- |
-- Create a value of 'AttackVolume' 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:
--
-- 'bitsPerSecond', 'attackVolume_bitsPerSecond' - A statistics object that uses bits per second as the unit. This is
-- included for network level attacks.
--
-- 'packetsPerSecond', 'attackVolume_packetsPerSecond' - A statistics object that uses packets per second as the unit. This is
-- included for network level attacks.
--
-- 'requestsPerSecond', 'attackVolume_requestsPerSecond' - A statistics object that uses requests per second as the unit. This is
-- included for application level attacks, and is only available for
-- accounts that are subscribed to Shield Advanced.
newAttackVolume ::
  AttackVolume
newAttackVolume :: AttackVolume
newAttackVolume =
  AttackVolume'
    { $sel:bitsPerSecond:AttackVolume' :: Maybe AttackVolumeStatistics
bitsPerSecond = forall a. Maybe a
Prelude.Nothing,
      $sel:packetsPerSecond:AttackVolume' :: Maybe AttackVolumeStatistics
packetsPerSecond = forall a. Maybe a
Prelude.Nothing,
      $sel:requestsPerSecond:AttackVolume' :: Maybe AttackVolumeStatistics
requestsPerSecond = forall a. Maybe a
Prelude.Nothing
    }

-- | A statistics object that uses bits per second as the unit. This is
-- included for network level attacks.
attackVolume_bitsPerSecond :: Lens.Lens' AttackVolume (Prelude.Maybe AttackVolumeStatistics)
attackVolume_bitsPerSecond :: Lens' AttackVolume (Maybe AttackVolumeStatistics)
attackVolume_bitsPerSecond = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttackVolume' {Maybe AttackVolumeStatistics
bitsPerSecond :: Maybe AttackVolumeStatistics
$sel:bitsPerSecond:AttackVolume' :: AttackVolume -> Maybe AttackVolumeStatistics
bitsPerSecond} -> Maybe AttackVolumeStatistics
bitsPerSecond) (\s :: AttackVolume
s@AttackVolume' {} Maybe AttackVolumeStatistics
a -> AttackVolume
s {$sel:bitsPerSecond:AttackVolume' :: Maybe AttackVolumeStatistics
bitsPerSecond = Maybe AttackVolumeStatistics
a} :: AttackVolume)

-- | A statistics object that uses packets per second as the unit. This is
-- included for network level attacks.
attackVolume_packetsPerSecond :: Lens.Lens' AttackVolume (Prelude.Maybe AttackVolumeStatistics)
attackVolume_packetsPerSecond :: Lens' AttackVolume (Maybe AttackVolumeStatistics)
attackVolume_packetsPerSecond = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttackVolume' {Maybe AttackVolumeStatistics
packetsPerSecond :: Maybe AttackVolumeStatistics
$sel:packetsPerSecond:AttackVolume' :: AttackVolume -> Maybe AttackVolumeStatistics
packetsPerSecond} -> Maybe AttackVolumeStatistics
packetsPerSecond) (\s :: AttackVolume
s@AttackVolume' {} Maybe AttackVolumeStatistics
a -> AttackVolume
s {$sel:packetsPerSecond:AttackVolume' :: Maybe AttackVolumeStatistics
packetsPerSecond = Maybe AttackVolumeStatistics
a} :: AttackVolume)

-- | A statistics object that uses requests per second as the unit. This is
-- included for application level attacks, and is only available for
-- accounts that are subscribed to Shield Advanced.
attackVolume_requestsPerSecond :: Lens.Lens' AttackVolume (Prelude.Maybe AttackVolumeStatistics)
attackVolume_requestsPerSecond :: Lens' AttackVolume (Maybe AttackVolumeStatistics)
attackVolume_requestsPerSecond = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttackVolume' {Maybe AttackVolumeStatistics
requestsPerSecond :: Maybe AttackVolumeStatistics
$sel:requestsPerSecond:AttackVolume' :: AttackVolume -> Maybe AttackVolumeStatistics
requestsPerSecond} -> Maybe AttackVolumeStatistics
requestsPerSecond) (\s :: AttackVolume
s@AttackVolume' {} Maybe AttackVolumeStatistics
a -> AttackVolume
s {$sel:requestsPerSecond:AttackVolume' :: Maybe AttackVolumeStatistics
requestsPerSecond = Maybe AttackVolumeStatistics
a} :: AttackVolume)

instance Data.FromJSON AttackVolume where
  parseJSON :: Value -> Parser AttackVolume
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AttackVolume"
      ( \Object
x ->
          Maybe AttackVolumeStatistics
-> Maybe AttackVolumeStatistics
-> Maybe AttackVolumeStatistics
-> AttackVolume
AttackVolume'
            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
"BitsPerSecond")
            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
"PacketsPerSecond")
            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
"RequestsPerSecond")
      )

instance Prelude.Hashable AttackVolume where
  hashWithSalt :: Int -> AttackVolume -> Int
hashWithSalt Int
_salt AttackVolume' {Maybe AttackVolumeStatistics
requestsPerSecond :: Maybe AttackVolumeStatistics
packetsPerSecond :: Maybe AttackVolumeStatistics
bitsPerSecond :: Maybe AttackVolumeStatistics
$sel:requestsPerSecond:AttackVolume' :: AttackVolume -> Maybe AttackVolumeStatistics
$sel:packetsPerSecond:AttackVolume' :: AttackVolume -> Maybe AttackVolumeStatistics
$sel:bitsPerSecond:AttackVolume' :: AttackVolume -> Maybe AttackVolumeStatistics
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AttackVolumeStatistics
bitsPerSecond
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AttackVolumeStatistics
packetsPerSecond
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AttackVolumeStatistics
requestsPerSecond

instance Prelude.NFData AttackVolume where
  rnf :: AttackVolume -> ()
rnf AttackVolume' {Maybe AttackVolumeStatistics
requestsPerSecond :: Maybe AttackVolumeStatistics
packetsPerSecond :: Maybe AttackVolumeStatistics
bitsPerSecond :: Maybe AttackVolumeStatistics
$sel:requestsPerSecond:AttackVolume' :: AttackVolume -> Maybe AttackVolumeStatistics
$sel:packetsPerSecond:AttackVolume' :: AttackVolume -> Maybe AttackVolumeStatistics
$sel:bitsPerSecond:AttackVolume' :: AttackVolume -> Maybe AttackVolumeStatistics
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AttackVolumeStatistics
bitsPerSecond
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe AttackVolumeStatistics
packetsPerSecond
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe AttackVolumeStatistics
requestsPerSecond