{-# 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.Inspector2.Types.PackageAggregationResponse
-- 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.Inspector2.Types.PackageAggregationResponse where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Inspector2.Types.SeverityCounts
import qualified Amazonka.Prelude as Prelude

-- | A response that contains the results of a finding aggregation by image
-- layer.
--
-- /See:/ 'newPackageAggregationResponse' smart constructor.
data PackageAggregationResponse = PackageAggregationResponse'
  { -- | The ID of the Amazon Web Services account associated with the findings.
    PackageAggregationResponse -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text,
    -- | An object that contains the count of matched findings per severity.
    PackageAggregationResponse -> Maybe SeverityCounts
severityCounts :: Prelude.Maybe SeverityCounts,
    -- | The name of the operating system package.
    PackageAggregationResponse -> Text
packageName :: Prelude.Text
  }
  deriving (PackageAggregationResponse -> PackageAggregationResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PackageAggregationResponse -> PackageAggregationResponse -> Bool
$c/= :: PackageAggregationResponse -> PackageAggregationResponse -> Bool
== :: PackageAggregationResponse -> PackageAggregationResponse -> Bool
$c== :: PackageAggregationResponse -> PackageAggregationResponse -> Bool
Prelude.Eq, ReadPrec [PackageAggregationResponse]
ReadPrec PackageAggregationResponse
Int -> ReadS PackageAggregationResponse
ReadS [PackageAggregationResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PackageAggregationResponse]
$creadListPrec :: ReadPrec [PackageAggregationResponse]
readPrec :: ReadPrec PackageAggregationResponse
$creadPrec :: ReadPrec PackageAggregationResponse
readList :: ReadS [PackageAggregationResponse]
$creadList :: ReadS [PackageAggregationResponse]
readsPrec :: Int -> ReadS PackageAggregationResponse
$creadsPrec :: Int -> ReadS PackageAggregationResponse
Prelude.Read, Int -> PackageAggregationResponse -> ShowS
[PackageAggregationResponse] -> ShowS
PackageAggregationResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PackageAggregationResponse] -> ShowS
$cshowList :: [PackageAggregationResponse] -> ShowS
show :: PackageAggregationResponse -> String
$cshow :: PackageAggregationResponse -> String
showsPrec :: Int -> PackageAggregationResponse -> ShowS
$cshowsPrec :: Int -> PackageAggregationResponse -> ShowS
Prelude.Show, forall x.
Rep PackageAggregationResponse x -> PackageAggregationResponse
forall x.
PackageAggregationResponse -> Rep PackageAggregationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PackageAggregationResponse x -> PackageAggregationResponse
$cfrom :: forall x.
PackageAggregationResponse -> Rep PackageAggregationResponse x
Prelude.Generic)

-- |
-- Create a value of 'PackageAggregationResponse' 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:
--
-- 'accountId', 'packageAggregationResponse_accountId' - The ID of the Amazon Web Services account associated with the findings.
--
-- 'severityCounts', 'packageAggregationResponse_severityCounts' - An object that contains the count of matched findings per severity.
--
-- 'packageName', 'packageAggregationResponse_packageName' - The name of the operating system package.
newPackageAggregationResponse ::
  -- | 'packageName'
  Prelude.Text ->
  PackageAggregationResponse
newPackageAggregationResponse :: Text -> PackageAggregationResponse
newPackageAggregationResponse Text
pPackageName_ =
  PackageAggregationResponse'
    { $sel:accountId:PackageAggregationResponse' :: Maybe Text
accountId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:severityCounts:PackageAggregationResponse' :: Maybe SeverityCounts
severityCounts = forall a. Maybe a
Prelude.Nothing,
      $sel:packageName:PackageAggregationResponse' :: Text
packageName = Text
pPackageName_
    }

-- | The ID of the Amazon Web Services account associated with the findings.
packageAggregationResponse_accountId :: Lens.Lens' PackageAggregationResponse (Prelude.Maybe Prelude.Text)
packageAggregationResponse_accountId :: Lens' PackageAggregationResponse (Maybe Text)
packageAggregationResponse_accountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PackageAggregationResponse' {Maybe Text
accountId :: Maybe Text
$sel:accountId:PackageAggregationResponse' :: PackageAggregationResponse -> Maybe Text
accountId} -> Maybe Text
accountId) (\s :: PackageAggregationResponse
s@PackageAggregationResponse' {} Maybe Text
a -> PackageAggregationResponse
s {$sel:accountId:PackageAggregationResponse' :: Maybe Text
accountId = Maybe Text
a} :: PackageAggregationResponse)

-- | An object that contains the count of matched findings per severity.
packageAggregationResponse_severityCounts :: Lens.Lens' PackageAggregationResponse (Prelude.Maybe SeverityCounts)
packageAggregationResponse_severityCounts :: Lens' PackageAggregationResponse (Maybe SeverityCounts)
packageAggregationResponse_severityCounts = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PackageAggregationResponse' {Maybe SeverityCounts
severityCounts :: Maybe SeverityCounts
$sel:severityCounts:PackageAggregationResponse' :: PackageAggregationResponse -> Maybe SeverityCounts
severityCounts} -> Maybe SeverityCounts
severityCounts) (\s :: PackageAggregationResponse
s@PackageAggregationResponse' {} Maybe SeverityCounts
a -> PackageAggregationResponse
s {$sel:severityCounts:PackageAggregationResponse' :: Maybe SeverityCounts
severityCounts = Maybe SeverityCounts
a} :: PackageAggregationResponse)

-- | The name of the operating system package.
packageAggregationResponse_packageName :: Lens.Lens' PackageAggregationResponse Prelude.Text
packageAggregationResponse_packageName :: Lens' PackageAggregationResponse Text
packageAggregationResponse_packageName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PackageAggregationResponse' {Text
packageName :: Text
$sel:packageName:PackageAggregationResponse' :: PackageAggregationResponse -> Text
packageName} -> Text
packageName) (\s :: PackageAggregationResponse
s@PackageAggregationResponse' {} Text
a -> PackageAggregationResponse
s {$sel:packageName:PackageAggregationResponse' :: Text
packageName = Text
a} :: PackageAggregationResponse)

instance Data.FromJSON PackageAggregationResponse where
  parseJSON :: Value -> Parser PackageAggregationResponse
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PackageAggregationResponse"
      ( \Object
x ->
          Maybe Text
-> Maybe SeverityCounts -> Text -> PackageAggregationResponse
PackageAggregationResponse'
            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
"accountId")
            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
"severityCounts")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"packageName")
      )

instance Prelude.Hashable PackageAggregationResponse where
  hashWithSalt :: Int -> PackageAggregationResponse -> Int
hashWithSalt Int
_salt PackageAggregationResponse' {Maybe Text
Maybe SeverityCounts
Text
packageName :: Text
severityCounts :: Maybe SeverityCounts
accountId :: Maybe Text
$sel:packageName:PackageAggregationResponse' :: PackageAggregationResponse -> Text
$sel:severityCounts:PackageAggregationResponse' :: PackageAggregationResponse -> Maybe SeverityCounts
$sel:accountId:PackageAggregationResponse' :: PackageAggregationResponse -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
accountId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SeverityCounts
severityCounts
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
packageName

instance Prelude.NFData PackageAggregationResponse where
  rnf :: PackageAggregationResponse -> ()
rnf PackageAggregationResponse' {Maybe Text
Maybe SeverityCounts
Text
packageName :: Text
severityCounts :: Maybe SeverityCounts
accountId :: Maybe Text
$sel:packageName:PackageAggregationResponse' :: PackageAggregationResponse -> Text
$sel:severityCounts:PackageAggregationResponse' :: PackageAggregationResponse -> Maybe SeverityCounts
$sel:accountId:PackageAggregationResponse' :: PackageAggregationResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
accountId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SeverityCounts
severityCounts
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
packageName