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

-- | A single attack statistics data record. This is returned by
-- DescribeAttackStatistics along with a time range indicating the time
-- period that the attack statistics apply to.
--
-- /See:/ 'newAttackStatisticsDataItem' smart constructor.
data AttackStatisticsDataItem = AttackStatisticsDataItem'
  { -- | Information about the volume of attacks during the time period. If the
    -- accompanying @AttackCount@ is zero, this setting might be empty.
    AttackStatisticsDataItem -> Maybe AttackVolume
attackVolume :: Prelude.Maybe AttackVolume,
    -- | The number of attacks detected during the time period. This is always
    -- present, but might be zero.
    AttackStatisticsDataItem -> Integer
attackCount :: Prelude.Integer
  }
  deriving (AttackStatisticsDataItem -> AttackStatisticsDataItem -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttackStatisticsDataItem -> AttackStatisticsDataItem -> Bool
$c/= :: AttackStatisticsDataItem -> AttackStatisticsDataItem -> Bool
== :: AttackStatisticsDataItem -> AttackStatisticsDataItem -> Bool
$c== :: AttackStatisticsDataItem -> AttackStatisticsDataItem -> Bool
Prelude.Eq, ReadPrec [AttackStatisticsDataItem]
ReadPrec AttackStatisticsDataItem
Int -> ReadS AttackStatisticsDataItem
ReadS [AttackStatisticsDataItem]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AttackStatisticsDataItem]
$creadListPrec :: ReadPrec [AttackStatisticsDataItem]
readPrec :: ReadPrec AttackStatisticsDataItem
$creadPrec :: ReadPrec AttackStatisticsDataItem
readList :: ReadS [AttackStatisticsDataItem]
$creadList :: ReadS [AttackStatisticsDataItem]
readsPrec :: Int -> ReadS AttackStatisticsDataItem
$creadsPrec :: Int -> ReadS AttackStatisticsDataItem
Prelude.Read, Int -> AttackStatisticsDataItem -> ShowS
[AttackStatisticsDataItem] -> ShowS
AttackStatisticsDataItem -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AttackStatisticsDataItem] -> ShowS
$cshowList :: [AttackStatisticsDataItem] -> ShowS
show :: AttackStatisticsDataItem -> String
$cshow :: AttackStatisticsDataItem -> String
showsPrec :: Int -> AttackStatisticsDataItem -> ShowS
$cshowsPrec :: Int -> AttackStatisticsDataItem -> ShowS
Prelude.Show, forall x.
Rep AttackStatisticsDataItem x -> AttackStatisticsDataItem
forall x.
AttackStatisticsDataItem -> Rep AttackStatisticsDataItem x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AttackStatisticsDataItem x -> AttackStatisticsDataItem
$cfrom :: forall x.
AttackStatisticsDataItem -> Rep AttackStatisticsDataItem x
Prelude.Generic)

-- |
-- Create a value of 'AttackStatisticsDataItem' 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:
--
-- 'attackVolume', 'attackStatisticsDataItem_attackVolume' - Information about the volume of attacks during the time period. If the
-- accompanying @AttackCount@ is zero, this setting might be empty.
--
-- 'attackCount', 'attackStatisticsDataItem_attackCount' - The number of attacks detected during the time period. This is always
-- present, but might be zero.
newAttackStatisticsDataItem ::
  -- | 'attackCount'
  Prelude.Integer ->
  AttackStatisticsDataItem
newAttackStatisticsDataItem :: Integer -> AttackStatisticsDataItem
newAttackStatisticsDataItem Integer
pAttackCount_ =
  AttackStatisticsDataItem'
    { $sel:attackVolume:AttackStatisticsDataItem' :: Maybe AttackVolume
attackVolume =
        forall a. Maybe a
Prelude.Nothing,
      $sel:attackCount:AttackStatisticsDataItem' :: Integer
attackCount = Integer
pAttackCount_
    }

-- | Information about the volume of attacks during the time period. If the
-- accompanying @AttackCount@ is zero, this setting might be empty.
attackStatisticsDataItem_attackVolume :: Lens.Lens' AttackStatisticsDataItem (Prelude.Maybe AttackVolume)
attackStatisticsDataItem_attackVolume :: Lens' AttackStatisticsDataItem (Maybe AttackVolume)
attackStatisticsDataItem_attackVolume = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttackStatisticsDataItem' {Maybe AttackVolume
attackVolume :: Maybe AttackVolume
$sel:attackVolume:AttackStatisticsDataItem' :: AttackStatisticsDataItem -> Maybe AttackVolume
attackVolume} -> Maybe AttackVolume
attackVolume) (\s :: AttackStatisticsDataItem
s@AttackStatisticsDataItem' {} Maybe AttackVolume
a -> AttackStatisticsDataItem
s {$sel:attackVolume:AttackStatisticsDataItem' :: Maybe AttackVolume
attackVolume = Maybe AttackVolume
a} :: AttackStatisticsDataItem)

-- | The number of attacks detected during the time period. This is always
-- present, but might be zero.
attackStatisticsDataItem_attackCount :: Lens.Lens' AttackStatisticsDataItem Prelude.Integer
attackStatisticsDataItem_attackCount :: Lens' AttackStatisticsDataItem Integer
attackStatisticsDataItem_attackCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttackStatisticsDataItem' {Integer
attackCount :: Integer
$sel:attackCount:AttackStatisticsDataItem' :: AttackStatisticsDataItem -> Integer
attackCount} -> Integer
attackCount) (\s :: AttackStatisticsDataItem
s@AttackStatisticsDataItem' {} Integer
a -> AttackStatisticsDataItem
s {$sel:attackCount:AttackStatisticsDataItem' :: Integer
attackCount = Integer
a} :: AttackStatisticsDataItem)

instance Data.FromJSON AttackStatisticsDataItem where
  parseJSON :: Value -> Parser AttackStatisticsDataItem
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AttackStatisticsDataItem"
      ( \Object
x ->
          Maybe AttackVolume -> Integer -> AttackStatisticsDataItem
AttackStatisticsDataItem'
            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
"AttackVolume")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"AttackCount")
      )

instance Prelude.Hashable AttackStatisticsDataItem where
  hashWithSalt :: Int -> AttackStatisticsDataItem -> Int
hashWithSalt Int
_salt AttackStatisticsDataItem' {Integer
Maybe AttackVolume
attackCount :: Integer
attackVolume :: Maybe AttackVolume
$sel:attackCount:AttackStatisticsDataItem' :: AttackStatisticsDataItem -> Integer
$sel:attackVolume:AttackStatisticsDataItem' :: AttackStatisticsDataItem -> Maybe AttackVolume
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AttackVolume
attackVolume
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Integer
attackCount

instance Prelude.NFData AttackStatisticsDataItem where
  rnf :: AttackStatisticsDataItem -> ()
rnf AttackStatisticsDataItem' {Integer
Maybe AttackVolume
attackCount :: Integer
attackVolume :: Maybe AttackVolume
$sel:attackCount:AttackStatisticsDataItem' :: AttackStatisticsDataItem -> Integer
$sel:attackVolume:AttackStatisticsDataItem' :: AttackStatisticsDataItem -> Maybe AttackVolume
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AttackVolume
attackVolume
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Integer
attackCount