{-# 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.RepositoryAggregationResponse
-- 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.RepositoryAggregationResponse 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 details on the results of a finding aggregation
-- by repository.
--
-- /See:/ 'newRepositoryAggregationResponse' smart constructor.
data RepositoryAggregationResponse = RepositoryAggregationResponse'
  { -- | The ID of the Amazon Web Services account associated with the findings.
    RepositoryAggregationResponse -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text,
    -- | The number of container images impacted by the findings.
    RepositoryAggregationResponse -> Maybe Integer
affectedImages :: Prelude.Maybe Prelude.Integer,
    -- | An object that represent the count of matched findings per severity.
    RepositoryAggregationResponse -> Maybe SeverityCounts
severityCounts :: Prelude.Maybe SeverityCounts,
    -- | The name of the repository associated with the findings.
    RepositoryAggregationResponse -> Text
repository :: Prelude.Text
  }
  deriving (RepositoryAggregationResponse
-> RepositoryAggregationResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RepositoryAggregationResponse
-> RepositoryAggregationResponse -> Bool
$c/= :: RepositoryAggregationResponse
-> RepositoryAggregationResponse -> Bool
== :: RepositoryAggregationResponse
-> RepositoryAggregationResponse -> Bool
$c== :: RepositoryAggregationResponse
-> RepositoryAggregationResponse -> Bool
Prelude.Eq, ReadPrec [RepositoryAggregationResponse]
ReadPrec RepositoryAggregationResponse
Int -> ReadS RepositoryAggregationResponse
ReadS [RepositoryAggregationResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RepositoryAggregationResponse]
$creadListPrec :: ReadPrec [RepositoryAggregationResponse]
readPrec :: ReadPrec RepositoryAggregationResponse
$creadPrec :: ReadPrec RepositoryAggregationResponse
readList :: ReadS [RepositoryAggregationResponse]
$creadList :: ReadS [RepositoryAggregationResponse]
readsPrec :: Int -> ReadS RepositoryAggregationResponse
$creadsPrec :: Int -> ReadS RepositoryAggregationResponse
Prelude.Read, Int -> RepositoryAggregationResponse -> ShowS
[RepositoryAggregationResponse] -> ShowS
RepositoryAggregationResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RepositoryAggregationResponse] -> ShowS
$cshowList :: [RepositoryAggregationResponse] -> ShowS
show :: RepositoryAggregationResponse -> String
$cshow :: RepositoryAggregationResponse -> String
showsPrec :: Int -> RepositoryAggregationResponse -> ShowS
$cshowsPrec :: Int -> RepositoryAggregationResponse -> ShowS
Prelude.Show, forall x.
Rep RepositoryAggregationResponse x
-> RepositoryAggregationResponse
forall x.
RepositoryAggregationResponse
-> Rep RepositoryAggregationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RepositoryAggregationResponse x
-> RepositoryAggregationResponse
$cfrom :: forall x.
RepositoryAggregationResponse
-> Rep RepositoryAggregationResponse x
Prelude.Generic)

-- |
-- Create a value of 'RepositoryAggregationResponse' 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', 'repositoryAggregationResponse_accountId' - The ID of the Amazon Web Services account associated with the findings.
--
-- 'affectedImages', 'repositoryAggregationResponse_affectedImages' - The number of container images impacted by the findings.
--
-- 'severityCounts', 'repositoryAggregationResponse_severityCounts' - An object that represent the count of matched findings per severity.
--
-- 'repository', 'repositoryAggregationResponse_repository' - The name of the repository associated with the findings.
newRepositoryAggregationResponse ::
  -- | 'repository'
  Prelude.Text ->
  RepositoryAggregationResponse
newRepositoryAggregationResponse :: Text -> RepositoryAggregationResponse
newRepositoryAggregationResponse Text
pRepository_ =
  RepositoryAggregationResponse'
    { $sel:accountId:RepositoryAggregationResponse' :: Maybe Text
accountId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:affectedImages:RepositoryAggregationResponse' :: Maybe Integer
affectedImages = forall a. Maybe a
Prelude.Nothing,
      $sel:severityCounts:RepositoryAggregationResponse' :: Maybe SeverityCounts
severityCounts = forall a. Maybe a
Prelude.Nothing,
      $sel:repository:RepositoryAggregationResponse' :: Text
repository = Text
pRepository_
    }

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

-- | The number of container images impacted by the findings.
repositoryAggregationResponse_affectedImages :: Lens.Lens' RepositoryAggregationResponse (Prelude.Maybe Prelude.Integer)
repositoryAggregationResponse_affectedImages :: Lens' RepositoryAggregationResponse (Maybe Integer)
repositoryAggregationResponse_affectedImages = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RepositoryAggregationResponse' {Maybe Integer
affectedImages :: Maybe Integer
$sel:affectedImages:RepositoryAggregationResponse' :: RepositoryAggregationResponse -> Maybe Integer
affectedImages} -> Maybe Integer
affectedImages) (\s :: RepositoryAggregationResponse
s@RepositoryAggregationResponse' {} Maybe Integer
a -> RepositoryAggregationResponse
s {$sel:affectedImages:RepositoryAggregationResponse' :: Maybe Integer
affectedImages = Maybe Integer
a} :: RepositoryAggregationResponse)

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

-- | The name of the repository associated with the findings.
repositoryAggregationResponse_repository :: Lens.Lens' RepositoryAggregationResponse Prelude.Text
repositoryAggregationResponse_repository :: Lens' RepositoryAggregationResponse Text
repositoryAggregationResponse_repository = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RepositoryAggregationResponse' {Text
repository :: Text
$sel:repository:RepositoryAggregationResponse' :: RepositoryAggregationResponse -> Text
repository} -> Text
repository) (\s :: RepositoryAggregationResponse
s@RepositoryAggregationResponse' {} Text
a -> RepositoryAggregationResponse
s {$sel:repository:RepositoryAggregationResponse' :: Text
repository = Text
a} :: RepositoryAggregationResponse)

instance Data.FromJSON RepositoryAggregationResponse where
  parseJSON :: Value -> Parser RepositoryAggregationResponse
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RepositoryAggregationResponse"
      ( \Object
x ->
          Maybe Text
-> Maybe Integer
-> Maybe SeverityCounts
-> Text
-> RepositoryAggregationResponse
RepositoryAggregationResponse'
            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
"affectedImages")
            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
"repository")
      )

instance
  Prelude.Hashable
    RepositoryAggregationResponse
  where
  hashWithSalt :: Int -> RepositoryAggregationResponse -> Int
hashWithSalt Int
_salt RepositoryAggregationResponse' {Maybe Integer
Maybe Text
Maybe SeverityCounts
Text
repository :: Text
severityCounts :: Maybe SeverityCounts
affectedImages :: Maybe Integer
accountId :: Maybe Text
$sel:repository:RepositoryAggregationResponse' :: RepositoryAggregationResponse -> Text
$sel:severityCounts:RepositoryAggregationResponse' :: RepositoryAggregationResponse -> Maybe SeverityCounts
$sel:affectedImages:RepositoryAggregationResponse' :: RepositoryAggregationResponse -> Maybe Integer
$sel:accountId:RepositoryAggregationResponse' :: RepositoryAggregationResponse -> 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 Integer
affectedImages
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SeverityCounts
severityCounts
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
repository

instance Prelude.NFData RepositoryAggregationResponse where
  rnf :: RepositoryAggregationResponse -> ()
rnf RepositoryAggregationResponse' {Maybe Integer
Maybe Text
Maybe SeverityCounts
Text
repository :: Text
severityCounts :: Maybe SeverityCounts
affectedImages :: Maybe Integer
accountId :: Maybe Text
$sel:repository:RepositoryAggregationResponse' :: RepositoryAggregationResponse -> Text
$sel:severityCounts:RepositoryAggregationResponse' :: RepositoryAggregationResponse -> Maybe SeverityCounts
$sel:affectedImages:RepositoryAggregationResponse' :: RepositoryAggregationResponse -> Maybe Integer
$sel:accountId:RepositoryAggregationResponse' :: RepositoryAggregationResponse -> 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 Integer
affectedImages
      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
repository