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

-- | The list of attack types and associated counters.
subResourceSummary_attackVectors :: Lens.Lens' SubResourceSummary (Prelude.Maybe [SummarizedAttackVector])
subResourceSummary_attackVectors :: Lens' SubResourceSummary (Maybe [SummarizedAttackVector])
subResourceSummary_attackVectors = 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) 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 counters that describe the details of the attack.
subResourceSummary_counters :: Lens.Lens' SubResourceSummary (Prelude.Maybe [SummarizedCounter])
subResourceSummary_counters :: Lens' SubResourceSummary (Maybe [SummarizedCounter])
subResourceSummary_counters = 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) 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 unique identifier (ID) of the @SubResource@.
subResourceSummary_id :: Lens.Lens' SubResourceSummary (Prelude.Maybe Prelude.Text)
subResourceSummary_id :: Lens' SubResourceSummary (Maybe Text)
subResourceSummary_id = 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 :: Lens' SubResourceSummary (Maybe SubResourceType)
subResourceSummary_type = 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 Data.FromJSON SubResourceSummary where
  parseJSON :: Value -> Parser SubResourceSummary
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SubResourceSummary"
      ( \Object
x ->
          Maybe [SummarizedAttackVector]
-> Maybe [SummarizedCounter]
-> Maybe Text
-> Maybe SubResourceType
-> SubResourceSummary
SubResourceSummary'
            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
"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
"Counters" 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
"Id")
            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
"Type")
      )

instance Prelude.Hashable SubResourceSummary where
  hashWithSalt :: Int -> SubResourceSummary -> Int
hashWithSalt Int
_salt SubResourceSummary' {Maybe [SummarizedCounter]
Maybe [SummarizedAttackVector]
Maybe Text
Maybe SubResourceType
type' :: Maybe SubResourceType
id :: Maybe Text
counters :: Maybe [SummarizedCounter]
attackVectors :: Maybe [SummarizedAttackVector]
$sel:type':SubResourceSummary' :: SubResourceSummary -> Maybe SubResourceType
$sel:id:SubResourceSummary' :: SubResourceSummary -> Maybe Text
$sel:counters:SubResourceSummary' :: SubResourceSummary -> Maybe [SummarizedCounter]
$sel:attackVectors:SubResourceSummary' :: SubResourceSummary -> Maybe [SummarizedAttackVector]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [SummarizedAttackVector]
attackVectors
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [SummarizedCounter]
counters
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SubResourceType
type'

instance Prelude.NFData SubResourceSummary where
  rnf :: SubResourceSummary -> ()
rnf SubResourceSummary' {Maybe [SummarizedCounter]
Maybe [SummarizedAttackVector]
Maybe Text
Maybe SubResourceType
type' :: Maybe SubResourceType
id :: Maybe Text
counters :: Maybe [SummarizedCounter]
attackVectors :: Maybe [SummarizedAttackVector]
$sel:type':SubResourceSummary' :: SubResourceSummary -> Maybe SubResourceType
$sel:id:SubResourceSummary' :: SubResourceSummary -> Maybe Text
$sel:counters:SubResourceSummary' :: SubResourceSummary -> Maybe [SummarizedCounter]
$sel:attackVectors:SubResourceSummary' :: SubResourceSummary -> Maybe [SummarizedAttackVector]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [SummarizedAttackVector]
attackVectors
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [SummarizedCounter]
counters
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SubResourceType
type'