{-# 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.AttackSummary
-- 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.AttackSummary 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.AttackVectorDescription

-- | Summarizes all DDoS attacks for a specified time period.
--
-- /See:/ 'newAttackSummary' smart constructor.
data AttackSummary = AttackSummary'
  { -- | The unique identifier (ID) of the attack.
    AttackSummary -> Maybe Text
attackId :: Prelude.Maybe Prelude.Text,
    -- | The list of attacks for a specified time period.
    AttackSummary -> Maybe [AttackVectorDescription]
attackVectors :: Prelude.Maybe [AttackVectorDescription],
    -- | The end time of the attack, in Unix time in seconds.
    AttackSummary -> Maybe POSIX
endTime :: Prelude.Maybe Data.POSIX,
    -- | The ARN (Amazon Resource Name) of the resource that was attacked.
    AttackSummary -> Maybe Text
resourceArn :: Prelude.Maybe Prelude.Text,
    -- | The start time of the attack, in Unix time in seconds.
    AttackSummary -> Maybe POSIX
startTime :: Prelude.Maybe Data.POSIX
  }
  deriving (AttackSummary -> AttackSummary -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttackSummary -> AttackSummary -> Bool
$c/= :: AttackSummary -> AttackSummary -> Bool
== :: AttackSummary -> AttackSummary -> Bool
$c== :: AttackSummary -> AttackSummary -> Bool
Prelude.Eq, ReadPrec [AttackSummary]
ReadPrec AttackSummary
Int -> ReadS AttackSummary
ReadS [AttackSummary]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AttackSummary]
$creadListPrec :: ReadPrec [AttackSummary]
readPrec :: ReadPrec AttackSummary
$creadPrec :: ReadPrec AttackSummary
readList :: ReadS [AttackSummary]
$creadList :: ReadS [AttackSummary]
readsPrec :: Int -> ReadS AttackSummary
$creadsPrec :: Int -> ReadS AttackSummary
Prelude.Read, Int -> AttackSummary -> ShowS
[AttackSummary] -> ShowS
AttackSummary -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AttackSummary] -> ShowS
$cshowList :: [AttackSummary] -> ShowS
show :: AttackSummary -> String
$cshow :: AttackSummary -> String
showsPrec :: Int -> AttackSummary -> ShowS
$cshowsPrec :: Int -> AttackSummary -> ShowS
Prelude.Show, forall x. Rep AttackSummary x -> AttackSummary
forall x. AttackSummary -> Rep AttackSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AttackSummary x -> AttackSummary
$cfrom :: forall x. AttackSummary -> Rep AttackSummary x
Prelude.Generic)

-- |
-- Create a value of 'AttackSummary' 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:
--
-- 'attackId', 'attackSummary_attackId' - The unique identifier (ID) of the attack.
--
-- 'attackVectors', 'attackSummary_attackVectors' - The list of attacks for a specified time period.
--
-- 'endTime', 'attackSummary_endTime' - The end time of the attack, in Unix time in seconds.
--
-- 'resourceArn', 'attackSummary_resourceArn' - The ARN (Amazon Resource Name) of the resource that was attacked.
--
-- 'startTime', 'attackSummary_startTime' - The start time of the attack, in Unix time in seconds.
newAttackSummary ::
  AttackSummary
newAttackSummary :: AttackSummary
newAttackSummary =
  AttackSummary'
    { $sel:attackId:AttackSummary' :: Maybe Text
attackId = forall a. Maybe a
Prelude.Nothing,
      $sel:attackVectors:AttackSummary' :: Maybe [AttackVectorDescription]
attackVectors = forall a. Maybe a
Prelude.Nothing,
      $sel:endTime:AttackSummary' :: Maybe POSIX
endTime = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceArn:AttackSummary' :: Maybe Text
resourceArn = forall a. Maybe a
Prelude.Nothing,
      $sel:startTime:AttackSummary' :: Maybe POSIX
startTime = forall a. Maybe a
Prelude.Nothing
    }

-- | The unique identifier (ID) of the attack.
attackSummary_attackId :: Lens.Lens' AttackSummary (Prelude.Maybe Prelude.Text)
attackSummary_attackId :: Lens' AttackSummary (Maybe Text)
attackSummary_attackId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttackSummary' {Maybe Text
attackId :: Maybe Text
$sel:attackId:AttackSummary' :: AttackSummary -> Maybe Text
attackId} -> Maybe Text
attackId) (\s :: AttackSummary
s@AttackSummary' {} Maybe Text
a -> AttackSummary
s {$sel:attackId:AttackSummary' :: Maybe Text
attackId = Maybe Text
a} :: AttackSummary)

-- | The list of attacks for a specified time period.
attackSummary_attackVectors :: Lens.Lens' AttackSummary (Prelude.Maybe [AttackVectorDescription])
attackSummary_attackVectors :: Lens' AttackSummary (Maybe [AttackVectorDescription])
attackSummary_attackVectors = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttackSummary' {Maybe [AttackVectorDescription]
attackVectors :: Maybe [AttackVectorDescription]
$sel:attackVectors:AttackSummary' :: AttackSummary -> Maybe [AttackVectorDescription]
attackVectors} -> Maybe [AttackVectorDescription]
attackVectors) (\s :: AttackSummary
s@AttackSummary' {} Maybe [AttackVectorDescription]
a -> AttackSummary
s {$sel:attackVectors:AttackSummary' :: Maybe [AttackVectorDescription]
attackVectors = Maybe [AttackVectorDescription]
a} :: AttackSummary) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The end time of the attack, in Unix time in seconds.
attackSummary_endTime :: Lens.Lens' AttackSummary (Prelude.Maybe Prelude.UTCTime)
attackSummary_endTime :: Lens' AttackSummary (Maybe UTCTime)
attackSummary_endTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttackSummary' {Maybe POSIX
endTime :: Maybe POSIX
$sel:endTime:AttackSummary' :: AttackSummary -> Maybe POSIX
endTime} -> Maybe POSIX
endTime) (\s :: AttackSummary
s@AttackSummary' {} Maybe POSIX
a -> AttackSummary
s {$sel:endTime:AttackSummary' :: Maybe POSIX
endTime = Maybe POSIX
a} :: AttackSummary) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The ARN (Amazon Resource Name) of the resource that was attacked.
attackSummary_resourceArn :: Lens.Lens' AttackSummary (Prelude.Maybe Prelude.Text)
attackSummary_resourceArn :: Lens' AttackSummary (Maybe Text)
attackSummary_resourceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttackSummary' {Maybe Text
resourceArn :: Maybe Text
$sel:resourceArn:AttackSummary' :: AttackSummary -> Maybe Text
resourceArn} -> Maybe Text
resourceArn) (\s :: AttackSummary
s@AttackSummary' {} Maybe Text
a -> AttackSummary
s {$sel:resourceArn:AttackSummary' :: Maybe Text
resourceArn = Maybe Text
a} :: AttackSummary)

-- | The start time of the attack, in Unix time in seconds.
attackSummary_startTime :: Lens.Lens' AttackSummary (Prelude.Maybe Prelude.UTCTime)
attackSummary_startTime :: Lens' AttackSummary (Maybe UTCTime)
attackSummary_startTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttackSummary' {Maybe POSIX
startTime :: Maybe POSIX
$sel:startTime:AttackSummary' :: AttackSummary -> Maybe POSIX
startTime} -> Maybe POSIX
startTime) (\s :: AttackSummary
s@AttackSummary' {} Maybe POSIX
a -> AttackSummary
s {$sel:startTime:AttackSummary' :: Maybe POSIX
startTime = Maybe POSIX
a} :: AttackSummary) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

instance Data.FromJSON AttackSummary where
  parseJSON :: Value -> Parser AttackSummary
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AttackSummary"
      ( \Object
x ->
          Maybe Text
-> Maybe [AttackVectorDescription]
-> Maybe POSIX
-> Maybe Text
-> Maybe POSIX
-> AttackSummary
AttackSummary'
            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
"AttackId")
            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
"AttackVectors" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"EndTime")
            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
"ResourceArn")
            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
"StartTime")
      )

instance Prelude.Hashable AttackSummary where
  hashWithSalt :: Int -> AttackSummary -> Int
hashWithSalt Int
_salt AttackSummary' {Maybe [AttackVectorDescription]
Maybe Text
Maybe POSIX
startTime :: Maybe POSIX
resourceArn :: Maybe Text
endTime :: Maybe POSIX
attackVectors :: Maybe [AttackVectorDescription]
attackId :: Maybe Text
$sel:startTime:AttackSummary' :: AttackSummary -> Maybe POSIX
$sel:resourceArn:AttackSummary' :: AttackSummary -> Maybe Text
$sel:endTime:AttackSummary' :: AttackSummary -> Maybe POSIX
$sel:attackVectors:AttackSummary' :: AttackSummary -> Maybe [AttackVectorDescription]
$sel:attackId:AttackSummary' :: AttackSummary -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
attackId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [AttackVectorDescription]
attackVectors
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
endTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resourceArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
startTime

instance Prelude.NFData AttackSummary where
  rnf :: AttackSummary -> ()
rnf AttackSummary' {Maybe [AttackVectorDescription]
Maybe Text
Maybe POSIX
startTime :: Maybe POSIX
resourceArn :: Maybe Text
endTime :: Maybe POSIX
attackVectors :: Maybe [AttackVectorDescription]
attackId :: Maybe Text
$sel:startTime:AttackSummary' :: AttackSummary -> Maybe POSIX
$sel:resourceArn:AttackSummary' :: AttackSummary -> Maybe Text
$sel:endTime:AttackSummary' :: AttackSummary -> Maybe POSIX
$sel:attackVectors:AttackSummary' :: AttackSummary -> Maybe [AttackVectorDescription]
$sel:attackId:AttackSummary' :: AttackSummary -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
attackId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [AttackVectorDescription]
attackVectors
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
endTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
startTime