{-# 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.AmiAggregationResponse
-- 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.AmiAggregationResponse 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 AMI.
--
-- /See:/ 'newAmiAggregationResponse' smart constructor.
data AmiAggregationResponse = AmiAggregationResponse'
  { -- | The Amazon Web Services account ID for the AMI.
    AmiAggregationResponse -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text,
    -- | The IDs of Amazon EC2 instances using this AMI.
    AmiAggregationResponse -> Maybe Integer
affectedInstances :: Prelude.Maybe Prelude.Integer,
    -- | An object that contains the count of matched findings per severity.
    AmiAggregationResponse -> Maybe SeverityCounts
severityCounts :: Prelude.Maybe SeverityCounts,
    -- | The ID of the AMI that findings were aggregated for.
    AmiAggregationResponse -> Text
ami :: Prelude.Text
  }
  deriving (AmiAggregationResponse -> AmiAggregationResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AmiAggregationResponse -> AmiAggregationResponse -> Bool
$c/= :: AmiAggregationResponse -> AmiAggregationResponse -> Bool
== :: AmiAggregationResponse -> AmiAggregationResponse -> Bool
$c== :: AmiAggregationResponse -> AmiAggregationResponse -> Bool
Prelude.Eq, ReadPrec [AmiAggregationResponse]
ReadPrec AmiAggregationResponse
Int -> ReadS AmiAggregationResponse
ReadS [AmiAggregationResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AmiAggregationResponse]
$creadListPrec :: ReadPrec [AmiAggregationResponse]
readPrec :: ReadPrec AmiAggregationResponse
$creadPrec :: ReadPrec AmiAggregationResponse
readList :: ReadS [AmiAggregationResponse]
$creadList :: ReadS [AmiAggregationResponse]
readsPrec :: Int -> ReadS AmiAggregationResponse
$creadsPrec :: Int -> ReadS AmiAggregationResponse
Prelude.Read, Int -> AmiAggregationResponse -> ShowS
[AmiAggregationResponse] -> ShowS
AmiAggregationResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AmiAggregationResponse] -> ShowS
$cshowList :: [AmiAggregationResponse] -> ShowS
show :: AmiAggregationResponse -> String
$cshow :: AmiAggregationResponse -> String
showsPrec :: Int -> AmiAggregationResponse -> ShowS
$cshowsPrec :: Int -> AmiAggregationResponse -> ShowS
Prelude.Show, forall x. Rep AmiAggregationResponse x -> AmiAggregationResponse
forall x. AmiAggregationResponse -> Rep AmiAggregationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AmiAggregationResponse x -> AmiAggregationResponse
$cfrom :: forall x. AmiAggregationResponse -> Rep AmiAggregationResponse x
Prelude.Generic)

-- |
-- Create a value of 'AmiAggregationResponse' 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', 'amiAggregationResponse_accountId' - The Amazon Web Services account ID for the AMI.
--
-- 'affectedInstances', 'amiAggregationResponse_affectedInstances' - The IDs of Amazon EC2 instances using this AMI.
--
-- 'severityCounts', 'amiAggregationResponse_severityCounts' - An object that contains the count of matched findings per severity.
--
-- 'ami', 'amiAggregationResponse_ami' - The ID of the AMI that findings were aggregated for.
newAmiAggregationResponse ::
  -- | 'ami'
  Prelude.Text ->
  AmiAggregationResponse
newAmiAggregationResponse :: Text -> AmiAggregationResponse
newAmiAggregationResponse Text
pAmi_ =
  AmiAggregationResponse'
    { $sel:accountId:AmiAggregationResponse' :: Maybe Text
accountId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:affectedInstances:AmiAggregationResponse' :: Maybe Integer
affectedInstances = forall a. Maybe a
Prelude.Nothing,
      $sel:severityCounts:AmiAggregationResponse' :: Maybe SeverityCounts
severityCounts = forall a. Maybe a
Prelude.Nothing,
      $sel:ami:AmiAggregationResponse' :: Text
ami = Text
pAmi_
    }

-- | The Amazon Web Services account ID for the AMI.
amiAggregationResponse_accountId :: Lens.Lens' AmiAggregationResponse (Prelude.Maybe Prelude.Text)
amiAggregationResponse_accountId :: Lens' AmiAggregationResponse (Maybe Text)
amiAggregationResponse_accountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AmiAggregationResponse' {Maybe Text
accountId :: Maybe Text
$sel:accountId:AmiAggregationResponse' :: AmiAggregationResponse -> Maybe Text
accountId} -> Maybe Text
accountId) (\s :: AmiAggregationResponse
s@AmiAggregationResponse' {} Maybe Text
a -> AmiAggregationResponse
s {$sel:accountId:AmiAggregationResponse' :: Maybe Text
accountId = Maybe Text
a} :: AmiAggregationResponse)

-- | The IDs of Amazon EC2 instances using this AMI.
amiAggregationResponse_affectedInstances :: Lens.Lens' AmiAggregationResponse (Prelude.Maybe Prelude.Integer)
amiAggregationResponse_affectedInstances :: Lens' AmiAggregationResponse (Maybe Integer)
amiAggregationResponse_affectedInstances = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AmiAggregationResponse' {Maybe Integer
affectedInstances :: Maybe Integer
$sel:affectedInstances:AmiAggregationResponse' :: AmiAggregationResponse -> Maybe Integer
affectedInstances} -> Maybe Integer
affectedInstances) (\s :: AmiAggregationResponse
s@AmiAggregationResponse' {} Maybe Integer
a -> AmiAggregationResponse
s {$sel:affectedInstances:AmiAggregationResponse' :: Maybe Integer
affectedInstances = Maybe Integer
a} :: AmiAggregationResponse)

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

-- | The ID of the AMI that findings were aggregated for.
amiAggregationResponse_ami :: Lens.Lens' AmiAggregationResponse Prelude.Text
amiAggregationResponse_ami :: Lens' AmiAggregationResponse Text
amiAggregationResponse_ami = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AmiAggregationResponse' {Text
ami :: Text
$sel:ami:AmiAggregationResponse' :: AmiAggregationResponse -> Text
ami} -> Text
ami) (\s :: AmiAggregationResponse
s@AmiAggregationResponse' {} Text
a -> AmiAggregationResponse
s {$sel:ami:AmiAggregationResponse' :: Text
ami = Text
a} :: AmiAggregationResponse)

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

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

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