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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Shield.Types.AttackLayer
import Amazonka.Shield.Types.AttackPropertyIdentifier
import Amazonka.Shield.Types.Contributor
import Amazonka.Shield.Types.Unit

-- | Details of a Shield event. This is provided as part of an AttackDetail.
--
-- /See:/ 'newAttackProperty' smart constructor.
data AttackProperty = AttackProperty'
  { -- | The type of Shield event that was observed. @NETWORK@ indicates layer 3
    -- and layer 4 events and @APPLICATION@ indicates layer 7 events.
    --
    -- For infrastructure layer events (L3 and L4 events) after January 25,
    -- 2021, you can view metrics for top contributors in Amazon CloudWatch
    -- metrics. For more information, see
    -- <https://docs.aws.amazon.com/waf/latest/developerguide/monitoring-cloudwatch.html#set-ddos-alarms Shield metrics and alarms>
    -- in the /WAF Developer Guide/.
    AttackProperty -> Maybe AttackLayer
attackLayer :: Prelude.Maybe AttackLayer,
    -- | Contributor objects for the top five contributors to a Shield event.
    AttackProperty -> Maybe [Contributor]
topContributors :: Prelude.Maybe [Contributor],
    -- | Defines the Shield event property information that is provided. The
    -- @WORDPRESS_PINGBACK_REFLECTOR@ and @WORDPRESS_PINGBACK_SOURCE@ values
    -- are valid only for WordPress reflective pingback events.
    AttackProperty -> Maybe AttackPropertyIdentifier
attackPropertyIdentifier :: Prelude.Maybe AttackPropertyIdentifier,
    -- | The total contributions made to this Shield event by all contributors.
    AttackProperty -> Maybe Integer
total :: Prelude.Maybe Prelude.Integer,
    -- | The unit used for the @Contributor@ @Value@ property.
    AttackProperty -> Maybe Unit
unit :: Prelude.Maybe Unit
  }
  deriving (AttackProperty -> AttackProperty -> Bool
(AttackProperty -> AttackProperty -> Bool)
-> (AttackProperty -> AttackProperty -> Bool) -> Eq AttackProperty
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttackProperty -> AttackProperty -> Bool
$c/= :: AttackProperty -> AttackProperty -> Bool
== :: AttackProperty -> AttackProperty -> Bool
$c== :: AttackProperty -> AttackProperty -> Bool
Prelude.Eq, ReadPrec [AttackProperty]
ReadPrec AttackProperty
Int -> ReadS AttackProperty
ReadS [AttackProperty]
(Int -> ReadS AttackProperty)
-> ReadS [AttackProperty]
-> ReadPrec AttackProperty
-> ReadPrec [AttackProperty]
-> Read AttackProperty
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AttackProperty]
$creadListPrec :: ReadPrec [AttackProperty]
readPrec :: ReadPrec AttackProperty
$creadPrec :: ReadPrec AttackProperty
readList :: ReadS [AttackProperty]
$creadList :: ReadS [AttackProperty]
readsPrec :: Int -> ReadS AttackProperty
$creadsPrec :: Int -> ReadS AttackProperty
Prelude.Read, Int -> AttackProperty -> ShowS
[AttackProperty] -> ShowS
AttackProperty -> String
(Int -> AttackProperty -> ShowS)
-> (AttackProperty -> String)
-> ([AttackProperty] -> ShowS)
-> Show AttackProperty
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AttackProperty] -> ShowS
$cshowList :: [AttackProperty] -> ShowS
show :: AttackProperty -> String
$cshow :: AttackProperty -> String
showsPrec :: Int -> AttackProperty -> ShowS
$cshowsPrec :: Int -> AttackProperty -> ShowS
Prelude.Show, (forall x. AttackProperty -> Rep AttackProperty x)
-> (forall x. Rep AttackProperty x -> AttackProperty)
-> Generic AttackProperty
forall x. Rep AttackProperty x -> AttackProperty
forall x. AttackProperty -> Rep AttackProperty x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AttackProperty x -> AttackProperty
$cfrom :: forall x. AttackProperty -> Rep AttackProperty x
Prelude.Generic)

-- |
-- Create a value of 'AttackProperty' 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:
--
-- 'attackLayer', 'attackProperty_attackLayer' - The type of Shield event that was observed. @NETWORK@ indicates layer 3
-- and layer 4 events and @APPLICATION@ indicates layer 7 events.
--
-- For infrastructure layer events (L3 and L4 events) after January 25,
-- 2021, you can view metrics for top contributors in Amazon CloudWatch
-- metrics. For more information, see
-- <https://docs.aws.amazon.com/waf/latest/developerguide/monitoring-cloudwatch.html#set-ddos-alarms Shield metrics and alarms>
-- in the /WAF Developer Guide/.
--
-- 'topContributors', 'attackProperty_topContributors' - Contributor objects for the top five contributors to a Shield event.
--
-- 'attackPropertyIdentifier', 'attackProperty_attackPropertyIdentifier' - Defines the Shield event property information that is provided. The
-- @WORDPRESS_PINGBACK_REFLECTOR@ and @WORDPRESS_PINGBACK_SOURCE@ values
-- are valid only for WordPress reflective pingback events.
--
-- 'total', 'attackProperty_total' - The total contributions made to this Shield event by all contributors.
--
-- 'unit', 'attackProperty_unit' - The unit used for the @Contributor@ @Value@ property.
newAttackProperty ::
  AttackProperty
newAttackProperty :: AttackProperty
newAttackProperty =
  AttackProperty' :: Maybe AttackLayer
-> Maybe [Contributor]
-> Maybe AttackPropertyIdentifier
-> Maybe Integer
-> Maybe Unit
-> AttackProperty
AttackProperty'
    { $sel:attackLayer:AttackProperty' :: Maybe AttackLayer
attackLayer = Maybe AttackLayer
forall a. Maybe a
Prelude.Nothing,
      $sel:topContributors:AttackProperty' :: Maybe [Contributor]
topContributors = Maybe [Contributor]
forall a. Maybe a
Prelude.Nothing,
      $sel:attackPropertyIdentifier:AttackProperty' :: Maybe AttackPropertyIdentifier
attackPropertyIdentifier = Maybe AttackPropertyIdentifier
forall a. Maybe a
Prelude.Nothing,
      $sel:total:AttackProperty' :: Maybe Integer
total = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:unit:AttackProperty' :: Maybe Unit
unit = Maybe Unit
forall a. Maybe a
Prelude.Nothing
    }

-- | The type of Shield event that was observed. @NETWORK@ indicates layer 3
-- and layer 4 events and @APPLICATION@ indicates layer 7 events.
--
-- For infrastructure layer events (L3 and L4 events) after January 25,
-- 2021, you can view metrics for top contributors in Amazon CloudWatch
-- metrics. For more information, see
-- <https://docs.aws.amazon.com/waf/latest/developerguide/monitoring-cloudwatch.html#set-ddos-alarms Shield metrics and alarms>
-- in the /WAF Developer Guide/.
attackProperty_attackLayer :: Lens.Lens' AttackProperty (Prelude.Maybe AttackLayer)
attackProperty_attackLayer :: (Maybe AttackLayer -> f (Maybe AttackLayer))
-> AttackProperty -> f AttackProperty
attackProperty_attackLayer = (AttackProperty -> Maybe AttackLayer)
-> (AttackProperty -> Maybe AttackLayer -> AttackProperty)
-> Lens
     AttackProperty
     AttackProperty
     (Maybe AttackLayer)
     (Maybe AttackLayer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttackProperty' {Maybe AttackLayer
attackLayer :: Maybe AttackLayer
$sel:attackLayer:AttackProperty' :: AttackProperty -> Maybe AttackLayer
attackLayer} -> Maybe AttackLayer
attackLayer) (\s :: AttackProperty
s@AttackProperty' {} Maybe AttackLayer
a -> AttackProperty
s {$sel:attackLayer:AttackProperty' :: Maybe AttackLayer
attackLayer = Maybe AttackLayer
a} :: AttackProperty)

-- | Contributor objects for the top five contributors to a Shield event.
attackProperty_topContributors :: Lens.Lens' AttackProperty (Prelude.Maybe [Contributor])
attackProperty_topContributors :: (Maybe [Contributor] -> f (Maybe [Contributor]))
-> AttackProperty -> f AttackProperty
attackProperty_topContributors = (AttackProperty -> Maybe [Contributor])
-> (AttackProperty -> Maybe [Contributor] -> AttackProperty)
-> Lens
     AttackProperty
     AttackProperty
     (Maybe [Contributor])
     (Maybe [Contributor])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttackProperty' {Maybe [Contributor]
topContributors :: Maybe [Contributor]
$sel:topContributors:AttackProperty' :: AttackProperty -> Maybe [Contributor]
topContributors} -> Maybe [Contributor]
topContributors) (\s :: AttackProperty
s@AttackProperty' {} Maybe [Contributor]
a -> AttackProperty
s {$sel:topContributors:AttackProperty' :: Maybe [Contributor]
topContributors = Maybe [Contributor]
a} :: AttackProperty) ((Maybe [Contributor] -> f (Maybe [Contributor]))
 -> AttackProperty -> f AttackProperty)
-> ((Maybe [Contributor] -> f (Maybe [Contributor]))
    -> Maybe [Contributor] -> f (Maybe [Contributor]))
-> (Maybe [Contributor] -> f (Maybe [Contributor]))
-> AttackProperty
-> f AttackProperty
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Contributor] [Contributor] [Contributor] [Contributor]
-> Iso
     (Maybe [Contributor])
     (Maybe [Contributor])
     (Maybe [Contributor])
     (Maybe [Contributor])
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 [Contributor] [Contributor] [Contributor] [Contributor]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Defines the Shield event property information that is provided. The
-- @WORDPRESS_PINGBACK_REFLECTOR@ and @WORDPRESS_PINGBACK_SOURCE@ values
-- are valid only for WordPress reflective pingback events.
attackProperty_attackPropertyIdentifier :: Lens.Lens' AttackProperty (Prelude.Maybe AttackPropertyIdentifier)
attackProperty_attackPropertyIdentifier :: (Maybe AttackPropertyIdentifier
 -> f (Maybe AttackPropertyIdentifier))
-> AttackProperty -> f AttackProperty
attackProperty_attackPropertyIdentifier = (AttackProperty -> Maybe AttackPropertyIdentifier)
-> (AttackProperty
    -> Maybe AttackPropertyIdentifier -> AttackProperty)
-> Lens
     AttackProperty
     AttackProperty
     (Maybe AttackPropertyIdentifier)
     (Maybe AttackPropertyIdentifier)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttackProperty' {Maybe AttackPropertyIdentifier
attackPropertyIdentifier :: Maybe AttackPropertyIdentifier
$sel:attackPropertyIdentifier:AttackProperty' :: AttackProperty -> Maybe AttackPropertyIdentifier
attackPropertyIdentifier} -> Maybe AttackPropertyIdentifier
attackPropertyIdentifier) (\s :: AttackProperty
s@AttackProperty' {} Maybe AttackPropertyIdentifier
a -> AttackProperty
s {$sel:attackPropertyIdentifier:AttackProperty' :: Maybe AttackPropertyIdentifier
attackPropertyIdentifier = Maybe AttackPropertyIdentifier
a} :: AttackProperty)

-- | The total contributions made to this Shield event by all contributors.
attackProperty_total :: Lens.Lens' AttackProperty (Prelude.Maybe Prelude.Integer)
attackProperty_total :: (Maybe Integer -> f (Maybe Integer))
-> AttackProperty -> f AttackProperty
attackProperty_total = (AttackProperty -> Maybe Integer)
-> (AttackProperty -> Maybe Integer -> AttackProperty)
-> Lens
     AttackProperty AttackProperty (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttackProperty' {Maybe Integer
total :: Maybe Integer
$sel:total:AttackProperty' :: AttackProperty -> Maybe Integer
total} -> Maybe Integer
total) (\s :: AttackProperty
s@AttackProperty' {} Maybe Integer
a -> AttackProperty
s {$sel:total:AttackProperty' :: Maybe Integer
total = Maybe Integer
a} :: AttackProperty)

-- | The unit used for the @Contributor@ @Value@ property.
attackProperty_unit :: Lens.Lens' AttackProperty (Prelude.Maybe Unit)
attackProperty_unit :: (Maybe Unit -> f (Maybe Unit))
-> AttackProperty -> f AttackProperty
attackProperty_unit = (AttackProperty -> Maybe Unit)
-> (AttackProperty -> Maybe Unit -> AttackProperty)
-> Lens AttackProperty AttackProperty (Maybe Unit) (Maybe Unit)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttackProperty' {Maybe Unit
unit :: Maybe Unit
$sel:unit:AttackProperty' :: AttackProperty -> Maybe Unit
unit} -> Maybe Unit
unit) (\s :: AttackProperty
s@AttackProperty' {} Maybe Unit
a -> AttackProperty
s {$sel:unit:AttackProperty' :: Maybe Unit
unit = Maybe Unit
a} :: AttackProperty)

instance Core.FromJSON AttackProperty where
  parseJSON :: Value -> Parser AttackProperty
parseJSON =
    String
-> (Object -> Parser AttackProperty)
-> Value
-> Parser AttackProperty
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AttackProperty"
      ( \Object
x ->
          Maybe AttackLayer
-> Maybe [Contributor]
-> Maybe AttackPropertyIdentifier
-> Maybe Integer
-> Maybe Unit
-> AttackProperty
AttackProperty'
            (Maybe AttackLayer
 -> Maybe [Contributor]
 -> Maybe AttackPropertyIdentifier
 -> Maybe Integer
 -> Maybe Unit
 -> AttackProperty)
-> Parser (Maybe AttackLayer)
-> Parser
     (Maybe [Contributor]
      -> Maybe AttackPropertyIdentifier
      -> Maybe Integer
      -> Maybe Unit
      -> AttackProperty)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe AttackLayer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AttackLayer")
            Parser
  (Maybe [Contributor]
   -> Maybe AttackPropertyIdentifier
   -> Maybe Integer
   -> Maybe Unit
   -> AttackProperty)
-> Parser (Maybe [Contributor])
-> Parser
     (Maybe AttackPropertyIdentifier
      -> Maybe Integer -> Maybe Unit -> AttackProperty)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Contributor]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TopContributors"
                            Parser (Maybe (Maybe [Contributor]))
-> Maybe [Contributor] -> Parser (Maybe [Contributor])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Contributor]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Maybe AttackPropertyIdentifier
   -> Maybe Integer -> Maybe Unit -> AttackProperty)
-> Parser (Maybe AttackPropertyIdentifier)
-> Parser (Maybe Integer -> Maybe Unit -> AttackProperty)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe AttackPropertyIdentifier)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AttackPropertyIdentifier")
            Parser (Maybe Integer -> Maybe Unit -> AttackProperty)
-> Parser (Maybe Integer) -> Parser (Maybe Unit -> AttackProperty)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Total")
            Parser (Maybe Unit -> AttackProperty)
-> Parser (Maybe Unit) -> Parser AttackProperty
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Unit)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Unit")
      )

instance Prelude.Hashable AttackProperty

instance Prelude.NFData AttackProperty