{-# 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-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.AttackVolume where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 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,
    -- | 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
  }
  deriving (AttackVolume -> AttackVolume -> Bool
(AttackVolume -> AttackVolume -> Bool)
-> (AttackVolume -> AttackVolume -> Bool) -> Eq AttackVolume
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]
(Int -> ReadS AttackVolume)
-> ReadS [AttackVolume]
-> ReadPrec AttackVolume
-> ReadPrec [AttackVolume]
-> Read 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
(Int -> AttackVolume -> ShowS)
-> (AttackVolume -> String)
-> ([AttackVolume] -> ShowS)
-> Show AttackVolume
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. AttackVolume -> Rep AttackVolume x)
-> (forall x. Rep AttackVolume x -> AttackVolume)
-> Generic AttackVolume
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:
--
-- '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.
--
-- 'bitsPerSecond', 'attackVolume_bitsPerSecond' - A statistics object that uses bits per second as the unit. This is
-- included for network level attacks.
newAttackVolume ::
  AttackVolume
newAttackVolume :: AttackVolume
newAttackVolume =
  AttackVolume' :: Maybe AttackVolumeStatistics
-> Maybe AttackVolumeStatistics
-> Maybe AttackVolumeStatistics
-> AttackVolume
AttackVolume'
    { $sel:packetsPerSecond:AttackVolume' :: Maybe AttackVolumeStatistics
packetsPerSecond = Maybe AttackVolumeStatistics
forall a. Maybe a
Prelude.Nothing,
      $sel:requestsPerSecond:AttackVolume' :: Maybe AttackVolumeStatistics
requestsPerSecond = Maybe AttackVolumeStatistics
forall a. Maybe a
Prelude.Nothing,
      $sel:bitsPerSecond:AttackVolume' :: Maybe AttackVolumeStatistics
bitsPerSecond = Maybe AttackVolumeStatistics
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe AttackVolumeStatistics -> f (Maybe AttackVolumeStatistics))
-> AttackVolume -> f AttackVolume
attackVolume_packetsPerSecond = (AttackVolume -> Maybe AttackVolumeStatistics)
-> (AttackVolume -> Maybe AttackVolumeStatistics -> AttackVolume)
-> Lens
     AttackVolume
     AttackVolume
     (Maybe AttackVolumeStatistics)
     (Maybe AttackVolumeStatistics)
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 :: (Maybe AttackVolumeStatistics -> f (Maybe AttackVolumeStatistics))
-> AttackVolume -> f AttackVolume
attackVolume_requestsPerSecond = (AttackVolume -> Maybe AttackVolumeStatistics)
-> (AttackVolume -> Maybe AttackVolumeStatistics -> AttackVolume)
-> Lens
     AttackVolume
     AttackVolume
     (Maybe AttackVolumeStatistics)
     (Maybe AttackVolumeStatistics)
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)

-- | 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 :: (Maybe AttackVolumeStatistics -> f (Maybe AttackVolumeStatistics))
-> AttackVolume -> f AttackVolume
attackVolume_bitsPerSecond = (AttackVolume -> Maybe AttackVolumeStatistics)
-> (AttackVolume -> Maybe AttackVolumeStatistics -> AttackVolume)
-> Lens
     AttackVolume
     AttackVolume
     (Maybe AttackVolumeStatistics)
     (Maybe AttackVolumeStatistics)
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)

instance Core.FromJSON AttackVolume where
  parseJSON :: Value -> Parser AttackVolume
parseJSON =
    String
-> (Object -> Parser AttackVolume) -> Value -> Parser AttackVolume
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AttackVolume"
      ( \Object
x ->
          Maybe AttackVolumeStatistics
-> Maybe AttackVolumeStatistics
-> Maybe AttackVolumeStatistics
-> AttackVolume
AttackVolume'
            (Maybe AttackVolumeStatistics
 -> Maybe AttackVolumeStatistics
 -> Maybe AttackVolumeStatistics
 -> AttackVolume)
-> Parser (Maybe AttackVolumeStatistics)
-> Parser
     (Maybe AttackVolumeStatistics
      -> Maybe AttackVolumeStatistics -> AttackVolume)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe AttackVolumeStatistics)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"PacketsPerSecond")
            Parser
  (Maybe AttackVolumeStatistics
   -> Maybe AttackVolumeStatistics -> AttackVolume)
-> Parser (Maybe AttackVolumeStatistics)
-> Parser (Maybe AttackVolumeStatistics -> AttackVolume)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe AttackVolumeStatistics)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RequestsPerSecond")
            Parser (Maybe AttackVolumeStatistics -> AttackVolume)
-> Parser (Maybe AttackVolumeStatistics) -> Parser AttackVolume
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe AttackVolumeStatistics)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"BitsPerSecond")
      )

instance Prelude.Hashable AttackVolume

instance Prelude.NFData AttackVolume