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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(AttackStatisticsDataItem -> AttackStatisticsDataItem -> Bool)
-> (AttackStatisticsDataItem -> AttackStatisticsDataItem -> Bool)
-> Eq AttackStatisticsDataItem
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]
(Int -> ReadS AttackStatisticsDataItem)
-> ReadS [AttackStatisticsDataItem]
-> ReadPrec AttackStatisticsDataItem
-> ReadPrec [AttackStatisticsDataItem]
-> Read 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
(Int -> AttackStatisticsDataItem -> ShowS)
-> (AttackStatisticsDataItem -> String)
-> ([AttackStatisticsDataItem] -> ShowS)
-> Show AttackStatisticsDataItem
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.
 AttackStatisticsDataItem -> Rep AttackStatisticsDataItem x)
-> (forall x.
    Rep AttackStatisticsDataItem x -> AttackStatisticsDataItem)
-> Generic AttackStatisticsDataItem
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' :: Maybe AttackVolume -> Integer -> AttackStatisticsDataItem
AttackStatisticsDataItem'
    { $sel:attackVolume:AttackStatisticsDataItem' :: Maybe AttackVolume
attackVolume =
        Maybe 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 :: (Maybe AttackVolume -> f (Maybe AttackVolume))
-> AttackStatisticsDataItem -> f AttackStatisticsDataItem
attackStatisticsDataItem_attackVolume = (AttackStatisticsDataItem -> Maybe AttackVolume)
-> (AttackStatisticsDataItem
    -> Maybe AttackVolume -> AttackStatisticsDataItem)
-> Lens
     AttackStatisticsDataItem
     AttackStatisticsDataItem
     (Maybe AttackVolume)
     (Maybe 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 :: (Integer -> f Integer)
-> AttackStatisticsDataItem -> f AttackStatisticsDataItem
attackStatisticsDataItem_attackCount = (AttackStatisticsDataItem -> Integer)
-> (AttackStatisticsDataItem
    -> Integer -> AttackStatisticsDataItem)
-> Lens
     AttackStatisticsDataItem AttackStatisticsDataItem Integer Integer
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 Core.FromJSON AttackStatisticsDataItem where
  parseJSON :: Value -> Parser AttackStatisticsDataItem
parseJSON =
    String
-> (Object -> Parser AttackStatisticsDataItem)
-> Value
-> Parser AttackStatisticsDataItem
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AttackStatisticsDataItem"
      ( \Object
x ->
          Maybe AttackVolume -> Integer -> AttackStatisticsDataItem
AttackStatisticsDataItem'
            (Maybe AttackVolume -> Integer -> AttackStatisticsDataItem)
-> Parser (Maybe AttackVolume)
-> Parser (Integer -> AttackStatisticsDataItem)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe AttackVolume)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AttackVolume")
            Parser (Integer -> AttackStatisticsDataItem)
-> Parser Integer -> Parser AttackStatisticsDataItem
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Integer
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"AttackCount")
      )

instance Prelude.Hashable AttackStatisticsDataItem

instance Prelude.NFData AttackStatisticsDataItem