{-# 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.ImageLayerAggregationResponse
-- 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.ImageLayerAggregationResponse 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:/ 'newImageLayerAggregationResponse' smart constructor.
data ImageLayerAggregationResponse = ImageLayerAggregationResponse'
  { -- | An object that represents the count of matched findings per severity.
    ImageLayerAggregationResponse -> Maybe SeverityCounts
severityCounts :: Prelude.Maybe SeverityCounts,
    -- | The ID of the Amazon Web Services account that owns the container image
    -- hosting the layer image.
    ImageLayerAggregationResponse -> Text
accountId :: Prelude.Text,
    -- | The layer hash.
    ImageLayerAggregationResponse -> Text
layerHash :: Prelude.Text,
    -- | The repository the layer resides in.
    ImageLayerAggregationResponse -> Text
repository :: Prelude.Text,
    -- | The resource ID of the container image layer.
    ImageLayerAggregationResponse -> Text
resourceId :: Prelude.Text
  }
  deriving (ImageLayerAggregationResponse
-> ImageLayerAggregationResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImageLayerAggregationResponse
-> ImageLayerAggregationResponse -> Bool
$c/= :: ImageLayerAggregationResponse
-> ImageLayerAggregationResponse -> Bool
== :: ImageLayerAggregationResponse
-> ImageLayerAggregationResponse -> Bool
$c== :: ImageLayerAggregationResponse
-> ImageLayerAggregationResponse -> Bool
Prelude.Eq, ReadPrec [ImageLayerAggregationResponse]
ReadPrec ImageLayerAggregationResponse
Int -> ReadS ImageLayerAggregationResponse
ReadS [ImageLayerAggregationResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImageLayerAggregationResponse]
$creadListPrec :: ReadPrec [ImageLayerAggregationResponse]
readPrec :: ReadPrec ImageLayerAggregationResponse
$creadPrec :: ReadPrec ImageLayerAggregationResponse
readList :: ReadS [ImageLayerAggregationResponse]
$creadList :: ReadS [ImageLayerAggregationResponse]
readsPrec :: Int -> ReadS ImageLayerAggregationResponse
$creadsPrec :: Int -> ReadS ImageLayerAggregationResponse
Prelude.Read, Int -> ImageLayerAggregationResponse -> ShowS
[ImageLayerAggregationResponse] -> ShowS
ImageLayerAggregationResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImageLayerAggregationResponse] -> ShowS
$cshowList :: [ImageLayerAggregationResponse] -> ShowS
show :: ImageLayerAggregationResponse -> String
$cshow :: ImageLayerAggregationResponse -> String
showsPrec :: Int -> ImageLayerAggregationResponse -> ShowS
$cshowsPrec :: Int -> ImageLayerAggregationResponse -> ShowS
Prelude.Show, forall x.
Rep ImageLayerAggregationResponse x
-> ImageLayerAggregationResponse
forall x.
ImageLayerAggregationResponse
-> Rep ImageLayerAggregationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ImageLayerAggregationResponse x
-> ImageLayerAggregationResponse
$cfrom :: forall x.
ImageLayerAggregationResponse
-> Rep ImageLayerAggregationResponse x
Prelude.Generic)

-- |
-- Create a value of 'ImageLayerAggregationResponse' 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:
--
-- 'severityCounts', 'imageLayerAggregationResponse_severityCounts' - An object that represents the count of matched findings per severity.
--
-- 'accountId', 'imageLayerAggregationResponse_accountId' - The ID of the Amazon Web Services account that owns the container image
-- hosting the layer image.
--
-- 'layerHash', 'imageLayerAggregationResponse_layerHash' - The layer hash.
--
-- 'repository', 'imageLayerAggregationResponse_repository' - The repository the layer resides in.
--
-- 'resourceId', 'imageLayerAggregationResponse_resourceId' - The resource ID of the container image layer.
newImageLayerAggregationResponse ::
  -- | 'accountId'
  Prelude.Text ->
  -- | 'layerHash'
  Prelude.Text ->
  -- | 'repository'
  Prelude.Text ->
  -- | 'resourceId'
  Prelude.Text ->
  ImageLayerAggregationResponse
newImageLayerAggregationResponse :: Text -> Text -> Text -> Text -> ImageLayerAggregationResponse
newImageLayerAggregationResponse
  Text
pAccountId_
  Text
pLayerHash_
  Text
pRepository_
  Text
pResourceId_ =
    ImageLayerAggregationResponse'
      { $sel:severityCounts:ImageLayerAggregationResponse' :: Maybe SeverityCounts
severityCounts =
          forall a. Maybe a
Prelude.Nothing,
        $sel:accountId:ImageLayerAggregationResponse' :: Text
accountId = Text
pAccountId_,
        $sel:layerHash:ImageLayerAggregationResponse' :: Text
layerHash = Text
pLayerHash_,
        $sel:repository:ImageLayerAggregationResponse' :: Text
repository = Text
pRepository_,
        $sel:resourceId:ImageLayerAggregationResponse' :: Text
resourceId = Text
pResourceId_
      }

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

-- | The ID of the Amazon Web Services account that owns the container image
-- hosting the layer image.
imageLayerAggregationResponse_accountId :: Lens.Lens' ImageLayerAggregationResponse Prelude.Text
imageLayerAggregationResponse_accountId :: Lens' ImageLayerAggregationResponse Text
imageLayerAggregationResponse_accountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageLayerAggregationResponse' {Text
accountId :: Text
$sel:accountId:ImageLayerAggregationResponse' :: ImageLayerAggregationResponse -> Text
accountId} -> Text
accountId) (\s :: ImageLayerAggregationResponse
s@ImageLayerAggregationResponse' {} Text
a -> ImageLayerAggregationResponse
s {$sel:accountId:ImageLayerAggregationResponse' :: Text
accountId = Text
a} :: ImageLayerAggregationResponse)

-- | The layer hash.
imageLayerAggregationResponse_layerHash :: Lens.Lens' ImageLayerAggregationResponse Prelude.Text
imageLayerAggregationResponse_layerHash :: Lens' ImageLayerAggregationResponse Text
imageLayerAggregationResponse_layerHash = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageLayerAggregationResponse' {Text
layerHash :: Text
$sel:layerHash:ImageLayerAggregationResponse' :: ImageLayerAggregationResponse -> Text
layerHash} -> Text
layerHash) (\s :: ImageLayerAggregationResponse
s@ImageLayerAggregationResponse' {} Text
a -> ImageLayerAggregationResponse
s {$sel:layerHash:ImageLayerAggregationResponse' :: Text
layerHash = Text
a} :: ImageLayerAggregationResponse)

-- | The repository the layer resides in.
imageLayerAggregationResponse_repository :: Lens.Lens' ImageLayerAggregationResponse Prelude.Text
imageLayerAggregationResponse_repository :: Lens' ImageLayerAggregationResponse Text
imageLayerAggregationResponse_repository = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageLayerAggregationResponse' {Text
repository :: Text
$sel:repository:ImageLayerAggregationResponse' :: ImageLayerAggregationResponse -> Text
repository} -> Text
repository) (\s :: ImageLayerAggregationResponse
s@ImageLayerAggregationResponse' {} Text
a -> ImageLayerAggregationResponse
s {$sel:repository:ImageLayerAggregationResponse' :: Text
repository = Text
a} :: ImageLayerAggregationResponse)

-- | The resource ID of the container image layer.
imageLayerAggregationResponse_resourceId :: Lens.Lens' ImageLayerAggregationResponse Prelude.Text
imageLayerAggregationResponse_resourceId :: Lens' ImageLayerAggregationResponse Text
imageLayerAggregationResponse_resourceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageLayerAggregationResponse' {Text
resourceId :: Text
$sel:resourceId:ImageLayerAggregationResponse' :: ImageLayerAggregationResponse -> Text
resourceId} -> Text
resourceId) (\s :: ImageLayerAggregationResponse
s@ImageLayerAggregationResponse' {} Text
a -> ImageLayerAggregationResponse
s {$sel:resourceId:ImageLayerAggregationResponse' :: Text
resourceId = Text
a} :: ImageLayerAggregationResponse)

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

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

instance Prelude.NFData ImageLayerAggregationResponse where
  rnf :: ImageLayerAggregationResponse -> ()
rnf ImageLayerAggregationResponse' {Maybe SeverityCounts
Text
resourceId :: Text
repository :: Text
layerHash :: Text
accountId :: Text
severityCounts :: Maybe SeverityCounts
$sel:resourceId:ImageLayerAggregationResponse' :: ImageLayerAggregationResponse -> Text
$sel:repository:ImageLayerAggregationResponse' :: ImageLayerAggregationResponse -> Text
$sel:layerHash:ImageLayerAggregationResponse' :: ImageLayerAggregationResponse -> Text
$sel:accountId:ImageLayerAggregationResponse' :: ImageLayerAggregationResponse -> Text
$sel:severityCounts:ImageLayerAggregationResponse' :: ImageLayerAggregationResponse -> Maybe SeverityCounts
..} =
    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
accountId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
layerHash
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
repository
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
resourceId