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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 list of attacks for a specified time period.
    AttackSummary -> Maybe [AttackVectorDescription]
attackVectors :: Prelude.Maybe [AttackVectorDescription],
    -- | The unique identifier (ID) of the attack.
    AttackSummary -> Maybe Text
attackId :: Prelude.Maybe Prelude.Text,
    -- | The start time of the attack, in Unix time in seconds. For more
    -- information see
    -- <http://docs.aws.amazon.com/cli/latest/userguide/cli-using-param.html#parameter-types timestamp>.
    AttackSummary -> Maybe POSIX
startTime :: Prelude.Maybe Core.POSIX,
    -- | The ARN (Amazon Resource Name) of the resource that was attacked.
    AttackSummary -> Maybe Text
resourceArn :: Prelude.Maybe Prelude.Text,
    -- | The end time of the attack, in Unix time in seconds. For more
    -- information see
    -- <http://docs.aws.amazon.com/cli/latest/userguide/cli-using-param.html#parameter-types timestamp>.
    AttackSummary -> Maybe POSIX
endTime :: Prelude.Maybe Core.POSIX
  }
  deriving (AttackSummary -> AttackSummary -> Bool
(AttackSummary -> AttackSummary -> Bool)
-> (AttackSummary -> AttackSummary -> Bool) -> Eq AttackSummary
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]
(Int -> ReadS AttackSummary)
-> ReadS [AttackSummary]
-> ReadPrec AttackSummary
-> ReadPrec [AttackSummary]
-> Read 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
(Int -> AttackSummary -> ShowS)
-> (AttackSummary -> String)
-> ([AttackSummary] -> ShowS)
-> Show AttackSummary
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. AttackSummary -> Rep AttackSummary x)
-> (forall x. Rep AttackSummary x -> AttackSummary)
-> Generic AttackSummary
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:
--
-- 'attackVectors', 'attackSummary_attackVectors' - The list of attacks for a specified time period.
--
-- 'attackId', 'attackSummary_attackId' - The unique identifier (ID) of the attack.
--
-- 'startTime', 'attackSummary_startTime' - The start time of the attack, in Unix time in seconds. For more
-- information see
-- <http://docs.aws.amazon.com/cli/latest/userguide/cli-using-param.html#parameter-types timestamp>.
--
-- 'resourceArn', 'attackSummary_resourceArn' - The ARN (Amazon Resource Name) of the resource that was attacked.
--
-- 'endTime', 'attackSummary_endTime' - The end time of the attack, in Unix time in seconds. For more
-- information see
-- <http://docs.aws.amazon.com/cli/latest/userguide/cli-using-param.html#parameter-types timestamp>.
newAttackSummary ::
  AttackSummary
newAttackSummary :: AttackSummary
newAttackSummary =
  AttackSummary' :: Maybe [AttackVectorDescription]
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe POSIX
-> AttackSummary
AttackSummary'
    { $sel:attackVectors:AttackSummary' :: Maybe [AttackVectorDescription]
attackVectors = Maybe [AttackVectorDescription]
forall a. Maybe a
Prelude.Nothing,
      $sel:attackId:AttackSummary' :: Maybe Text
attackId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:startTime:AttackSummary' :: Maybe POSIX
startTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceArn:AttackSummary' :: Maybe Text
resourceArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:endTime:AttackSummary' :: Maybe POSIX
endTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The list of attacks for a specified time period.
attackSummary_attackVectors :: Lens.Lens' AttackSummary (Prelude.Maybe [AttackVectorDescription])
attackSummary_attackVectors :: (Maybe [AttackVectorDescription]
 -> f (Maybe [AttackVectorDescription]))
-> AttackSummary -> f AttackSummary
attackSummary_attackVectors = (AttackSummary -> Maybe [AttackVectorDescription])
-> (AttackSummary
    -> Maybe [AttackVectorDescription] -> AttackSummary)
-> Lens
     AttackSummary
     AttackSummary
     (Maybe [AttackVectorDescription])
     (Maybe [AttackVectorDescription])
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) ((Maybe [AttackVectorDescription]
  -> f (Maybe [AttackVectorDescription]))
 -> AttackSummary -> f AttackSummary)
-> ((Maybe [AttackVectorDescription]
     -> f (Maybe [AttackVectorDescription]))
    -> Maybe [AttackVectorDescription]
    -> f (Maybe [AttackVectorDescription]))
-> (Maybe [AttackVectorDescription]
    -> f (Maybe [AttackVectorDescription]))
-> AttackSummary
-> f AttackSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [AttackVectorDescription]
  [AttackVectorDescription]
  [AttackVectorDescription]
  [AttackVectorDescription]
-> Iso
     (Maybe [AttackVectorDescription])
     (Maybe [AttackVectorDescription])
     (Maybe [AttackVectorDescription])
     (Maybe [AttackVectorDescription])
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 AnIso
  [AttackVectorDescription]
  [AttackVectorDescription]
  [AttackVectorDescription]
  [AttackVectorDescription]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The unique identifier (ID) of the attack.
attackSummary_attackId :: Lens.Lens' AttackSummary (Prelude.Maybe Prelude.Text)
attackSummary_attackId :: (Maybe Text -> f (Maybe Text)) -> AttackSummary -> f AttackSummary
attackSummary_attackId = (AttackSummary -> Maybe Text)
-> (AttackSummary -> Maybe Text -> AttackSummary)
-> Lens AttackSummary AttackSummary (Maybe Text) (Maybe Text)
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 start time of the attack, in Unix time in seconds. For more
-- information see
-- <http://docs.aws.amazon.com/cli/latest/userguide/cli-using-param.html#parameter-types timestamp>.
attackSummary_startTime :: Lens.Lens' AttackSummary (Prelude.Maybe Prelude.UTCTime)
attackSummary_startTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> AttackSummary -> f AttackSummary
attackSummary_startTime = (AttackSummary -> Maybe POSIX)
-> (AttackSummary -> Maybe POSIX -> AttackSummary)
-> Lens AttackSummary AttackSummary (Maybe POSIX) (Maybe POSIX)
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) ((Maybe POSIX -> f (Maybe POSIX))
 -> AttackSummary -> f AttackSummary)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> AttackSummary
-> f AttackSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The ARN (Amazon Resource Name) of the resource that was attacked.
attackSummary_resourceArn :: Lens.Lens' AttackSummary (Prelude.Maybe Prelude.Text)
attackSummary_resourceArn :: (Maybe Text -> f (Maybe Text)) -> AttackSummary -> f AttackSummary
attackSummary_resourceArn = (AttackSummary -> Maybe Text)
-> (AttackSummary -> Maybe Text -> AttackSummary)
-> Lens AttackSummary AttackSummary (Maybe Text) (Maybe Text)
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 end time of the attack, in Unix time in seconds. For more
-- information see
-- <http://docs.aws.amazon.com/cli/latest/userguide/cli-using-param.html#parameter-types timestamp>.
attackSummary_endTime :: Lens.Lens' AttackSummary (Prelude.Maybe Prelude.UTCTime)
attackSummary_endTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> AttackSummary -> f AttackSummary
attackSummary_endTime = (AttackSummary -> Maybe POSIX)
-> (AttackSummary -> Maybe POSIX -> AttackSummary)
-> Lens AttackSummary AttackSummary (Maybe POSIX) (Maybe POSIX)
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) ((Maybe POSIX -> f (Maybe POSIX))
 -> AttackSummary -> f AttackSummary)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> AttackSummary
-> f AttackSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromJSON AttackSummary where
  parseJSON :: Value -> Parser AttackSummary
parseJSON =
    String
-> (Object -> Parser AttackSummary)
-> Value
-> Parser AttackSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AttackSummary"
      ( \Object
x ->
          Maybe [AttackVectorDescription]
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe POSIX
-> AttackSummary
AttackSummary'
            (Maybe [AttackVectorDescription]
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe Text
 -> Maybe POSIX
 -> AttackSummary)
-> Parser (Maybe [AttackVectorDescription])
-> Parser
     (Maybe Text
      -> Maybe POSIX -> Maybe Text -> Maybe POSIX -> AttackSummary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [AttackVectorDescription]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AttackVectors" Parser (Maybe (Maybe [AttackVectorDescription]))
-> Maybe [AttackVectorDescription]
-> Parser (Maybe [AttackVectorDescription])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [AttackVectorDescription]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe Text
   -> Maybe POSIX -> Maybe Text -> Maybe POSIX -> AttackSummary)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX -> Maybe Text -> Maybe POSIX -> AttackSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AttackId")
            Parser (Maybe POSIX -> Maybe Text -> Maybe POSIX -> AttackSummary)
-> Parser (Maybe POSIX)
-> Parser (Maybe Text -> Maybe POSIX -> AttackSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StartTime")
            Parser (Maybe Text -> Maybe POSIX -> AttackSummary)
-> Parser (Maybe Text) -> Parser (Maybe POSIX -> AttackSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ResourceArn")
            Parser (Maybe POSIX -> AttackSummary)
-> Parser (Maybe POSIX) -> Parser AttackSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EndTime")
      )

instance Prelude.Hashable AttackSummary

instance Prelude.NFData AttackSummary