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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Shield.Types.SubResourceType
import Amazonka.Shield.Types.SummarizedAttackVector
import Amazonka.Shield.Types.SummarizedCounter

-- | The attack information for the specified SubResource.
--
-- /See:/ 'newSubResourceSummary' smart constructor.
data SubResourceSummary = SubResourceSummary'
  { -- | The counters that describe the details of the attack.
    SubResourceSummary -> Maybe [SummarizedCounter]
counters :: Prelude.Maybe [SummarizedCounter],
    -- | The list of attack types and associated counters.
    SubResourceSummary -> Maybe [SummarizedAttackVector]
attackVectors :: Prelude.Maybe [SummarizedAttackVector],
    -- | The unique identifier (ID) of the @SubResource@.
    SubResourceSummary -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The @SubResource@ type.
    SubResourceSummary -> Maybe SubResourceType
type' :: Prelude.Maybe SubResourceType
  }
  deriving (SubResourceSummary -> SubResourceSummary -> Bool
(SubResourceSummary -> SubResourceSummary -> Bool)
-> (SubResourceSummary -> SubResourceSummary -> Bool)
-> Eq SubResourceSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SubResourceSummary -> SubResourceSummary -> Bool
$c/= :: SubResourceSummary -> SubResourceSummary -> Bool
== :: SubResourceSummary -> SubResourceSummary -> Bool
$c== :: SubResourceSummary -> SubResourceSummary -> Bool
Prelude.Eq, ReadPrec [SubResourceSummary]
ReadPrec SubResourceSummary
Int -> ReadS SubResourceSummary
ReadS [SubResourceSummary]
(Int -> ReadS SubResourceSummary)
-> ReadS [SubResourceSummary]
-> ReadPrec SubResourceSummary
-> ReadPrec [SubResourceSummary]
-> Read SubResourceSummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SubResourceSummary]
$creadListPrec :: ReadPrec [SubResourceSummary]
readPrec :: ReadPrec SubResourceSummary
$creadPrec :: ReadPrec SubResourceSummary
readList :: ReadS [SubResourceSummary]
$creadList :: ReadS [SubResourceSummary]
readsPrec :: Int -> ReadS SubResourceSummary
$creadsPrec :: Int -> ReadS SubResourceSummary
Prelude.Read, Int -> SubResourceSummary -> ShowS
[SubResourceSummary] -> ShowS
SubResourceSummary -> String
(Int -> SubResourceSummary -> ShowS)
-> (SubResourceSummary -> String)
-> ([SubResourceSummary] -> ShowS)
-> Show SubResourceSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SubResourceSummary] -> ShowS
$cshowList :: [SubResourceSummary] -> ShowS
show :: SubResourceSummary -> String
$cshow :: SubResourceSummary -> String
showsPrec :: Int -> SubResourceSummary -> ShowS
$cshowsPrec :: Int -> SubResourceSummary -> ShowS
Prelude.Show, (forall x. SubResourceSummary -> Rep SubResourceSummary x)
-> (forall x. Rep SubResourceSummary x -> SubResourceSummary)
-> Generic SubResourceSummary
forall x. Rep SubResourceSummary x -> SubResourceSummary
forall x. SubResourceSummary -> Rep SubResourceSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SubResourceSummary x -> SubResourceSummary
$cfrom :: forall x. SubResourceSummary -> Rep SubResourceSummary x
Prelude.Generic)

-- |
-- Create a value of 'SubResourceSummary' 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:
--
-- 'counters', 'subResourceSummary_counters' - The counters that describe the details of the attack.
--
-- 'attackVectors', 'subResourceSummary_attackVectors' - The list of attack types and associated counters.
--
-- 'id', 'subResourceSummary_id' - The unique identifier (ID) of the @SubResource@.
--
-- 'type'', 'subResourceSummary_type' - The @SubResource@ type.
newSubResourceSummary ::
  SubResourceSummary
newSubResourceSummary :: SubResourceSummary
newSubResourceSummary =
  SubResourceSummary' :: Maybe [SummarizedCounter]
-> Maybe [SummarizedAttackVector]
-> Maybe Text
-> Maybe SubResourceType
-> SubResourceSummary
SubResourceSummary'
    { $sel:counters:SubResourceSummary' :: Maybe [SummarizedCounter]
counters = Maybe [SummarizedCounter]
forall a. Maybe a
Prelude.Nothing,
      $sel:attackVectors:SubResourceSummary' :: Maybe [SummarizedAttackVector]
attackVectors = Maybe [SummarizedAttackVector]
forall a. Maybe a
Prelude.Nothing,
      $sel:id:SubResourceSummary' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':SubResourceSummary' :: Maybe SubResourceType
type' = Maybe SubResourceType
forall a. Maybe a
Prelude.Nothing
    }

-- | The counters that describe the details of the attack.
subResourceSummary_counters :: Lens.Lens' SubResourceSummary (Prelude.Maybe [SummarizedCounter])
subResourceSummary_counters :: (Maybe [SummarizedCounter] -> f (Maybe [SummarizedCounter]))
-> SubResourceSummary -> f SubResourceSummary
subResourceSummary_counters = (SubResourceSummary -> Maybe [SummarizedCounter])
-> (SubResourceSummary
    -> Maybe [SummarizedCounter] -> SubResourceSummary)
-> Lens
     SubResourceSummary
     SubResourceSummary
     (Maybe [SummarizedCounter])
     (Maybe [SummarizedCounter])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubResourceSummary' {Maybe [SummarizedCounter]
counters :: Maybe [SummarizedCounter]
$sel:counters:SubResourceSummary' :: SubResourceSummary -> Maybe [SummarizedCounter]
counters} -> Maybe [SummarizedCounter]
counters) (\s :: SubResourceSummary
s@SubResourceSummary' {} Maybe [SummarizedCounter]
a -> SubResourceSummary
s {$sel:counters:SubResourceSummary' :: Maybe [SummarizedCounter]
counters = Maybe [SummarizedCounter]
a} :: SubResourceSummary) ((Maybe [SummarizedCounter] -> f (Maybe [SummarizedCounter]))
 -> SubResourceSummary -> f SubResourceSummary)
-> ((Maybe [SummarizedCounter] -> f (Maybe [SummarizedCounter]))
    -> Maybe [SummarizedCounter] -> f (Maybe [SummarizedCounter]))
-> (Maybe [SummarizedCounter] -> f (Maybe [SummarizedCounter]))
-> SubResourceSummary
-> f SubResourceSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [SummarizedCounter]
  [SummarizedCounter]
  [SummarizedCounter]
  [SummarizedCounter]
-> Iso
     (Maybe [SummarizedCounter])
     (Maybe [SummarizedCounter])
     (Maybe [SummarizedCounter])
     (Maybe [SummarizedCounter])
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
  [SummarizedCounter]
  [SummarizedCounter]
  [SummarizedCounter]
  [SummarizedCounter]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The list of attack types and associated counters.
subResourceSummary_attackVectors :: Lens.Lens' SubResourceSummary (Prelude.Maybe [SummarizedAttackVector])
subResourceSummary_attackVectors :: (Maybe [SummarizedAttackVector]
 -> f (Maybe [SummarizedAttackVector]))
-> SubResourceSummary -> f SubResourceSummary
subResourceSummary_attackVectors = (SubResourceSummary -> Maybe [SummarizedAttackVector])
-> (SubResourceSummary
    -> Maybe [SummarizedAttackVector] -> SubResourceSummary)
-> Lens
     SubResourceSummary
     SubResourceSummary
     (Maybe [SummarizedAttackVector])
     (Maybe [SummarizedAttackVector])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubResourceSummary' {Maybe [SummarizedAttackVector]
attackVectors :: Maybe [SummarizedAttackVector]
$sel:attackVectors:SubResourceSummary' :: SubResourceSummary -> Maybe [SummarizedAttackVector]
attackVectors} -> Maybe [SummarizedAttackVector]
attackVectors) (\s :: SubResourceSummary
s@SubResourceSummary' {} Maybe [SummarizedAttackVector]
a -> SubResourceSummary
s {$sel:attackVectors:SubResourceSummary' :: Maybe [SummarizedAttackVector]
attackVectors = Maybe [SummarizedAttackVector]
a} :: SubResourceSummary) ((Maybe [SummarizedAttackVector]
  -> f (Maybe [SummarizedAttackVector]))
 -> SubResourceSummary -> f SubResourceSummary)
-> ((Maybe [SummarizedAttackVector]
     -> f (Maybe [SummarizedAttackVector]))
    -> Maybe [SummarizedAttackVector]
    -> f (Maybe [SummarizedAttackVector]))
-> (Maybe [SummarizedAttackVector]
    -> f (Maybe [SummarizedAttackVector]))
-> SubResourceSummary
-> f SubResourceSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [SummarizedAttackVector]
  [SummarizedAttackVector]
  [SummarizedAttackVector]
  [SummarizedAttackVector]
-> Iso
     (Maybe [SummarizedAttackVector])
     (Maybe [SummarizedAttackVector])
     (Maybe [SummarizedAttackVector])
     (Maybe [SummarizedAttackVector])
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
  [SummarizedAttackVector]
  [SummarizedAttackVector]
  [SummarizedAttackVector]
  [SummarizedAttackVector]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The unique identifier (ID) of the @SubResource@.
subResourceSummary_id :: Lens.Lens' SubResourceSummary (Prelude.Maybe Prelude.Text)
subResourceSummary_id :: (Maybe Text -> f (Maybe Text))
-> SubResourceSummary -> f SubResourceSummary
subResourceSummary_id = (SubResourceSummary -> Maybe Text)
-> (SubResourceSummary -> Maybe Text -> SubResourceSummary)
-> Lens
     SubResourceSummary SubResourceSummary (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubResourceSummary' {Maybe Text
id :: Maybe Text
$sel:id:SubResourceSummary' :: SubResourceSummary -> Maybe Text
id} -> Maybe Text
id) (\s :: SubResourceSummary
s@SubResourceSummary' {} Maybe Text
a -> SubResourceSummary
s {$sel:id:SubResourceSummary' :: Maybe Text
id = Maybe Text
a} :: SubResourceSummary)

-- | The @SubResource@ type.
subResourceSummary_type :: Lens.Lens' SubResourceSummary (Prelude.Maybe SubResourceType)
subResourceSummary_type :: (Maybe SubResourceType -> f (Maybe SubResourceType))
-> SubResourceSummary -> f SubResourceSummary
subResourceSummary_type = (SubResourceSummary -> Maybe SubResourceType)
-> (SubResourceSummary
    -> Maybe SubResourceType -> SubResourceSummary)
-> Lens
     SubResourceSummary
     SubResourceSummary
     (Maybe SubResourceType)
     (Maybe SubResourceType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubResourceSummary' {Maybe SubResourceType
type' :: Maybe SubResourceType
$sel:type':SubResourceSummary' :: SubResourceSummary -> Maybe SubResourceType
type'} -> Maybe SubResourceType
type') (\s :: SubResourceSummary
s@SubResourceSummary' {} Maybe SubResourceType
a -> SubResourceSummary
s {$sel:type':SubResourceSummary' :: Maybe SubResourceType
type' = Maybe SubResourceType
a} :: SubResourceSummary)

instance Core.FromJSON SubResourceSummary where
  parseJSON :: Value -> Parser SubResourceSummary
parseJSON =
    String
-> (Object -> Parser SubResourceSummary)
-> Value
-> Parser SubResourceSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SubResourceSummary"
      ( \Object
x ->
          Maybe [SummarizedCounter]
-> Maybe [SummarizedAttackVector]
-> Maybe Text
-> Maybe SubResourceType
-> SubResourceSummary
SubResourceSummary'
            (Maybe [SummarizedCounter]
 -> Maybe [SummarizedAttackVector]
 -> Maybe Text
 -> Maybe SubResourceType
 -> SubResourceSummary)
-> Parser (Maybe [SummarizedCounter])
-> Parser
     (Maybe [SummarizedAttackVector]
      -> Maybe Text -> Maybe SubResourceType -> SubResourceSummary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [SummarizedCounter]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Counters" Parser (Maybe (Maybe [SummarizedCounter]))
-> Maybe [SummarizedCounter] -> Parser (Maybe [SummarizedCounter])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [SummarizedCounter]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe [SummarizedAttackVector]
   -> Maybe Text -> Maybe SubResourceType -> SubResourceSummary)
-> Parser (Maybe [SummarizedAttackVector])
-> Parser
     (Maybe Text -> Maybe SubResourceType -> SubResourceSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [SummarizedAttackVector]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AttackVectors" Parser (Maybe (Maybe [SummarizedAttackVector]))
-> Maybe [SummarizedAttackVector]
-> Parser (Maybe [SummarizedAttackVector])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [SummarizedAttackVector]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> Maybe SubResourceType -> SubResourceSummary)
-> Parser (Maybe Text)
-> Parser (Maybe SubResourceType -> SubResourceSummary)
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
"Id")
            Parser (Maybe SubResourceType -> SubResourceSummary)
-> Parser (Maybe SubResourceType) -> Parser SubResourceSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe SubResourceType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Type")
      )

instance Prelude.Hashable SubResourceSummary

instance Prelude.NFData SubResourceSummary