{-# 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.Ec2InstanceAggregationResponse
-- 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.Ec2InstanceAggregationResponse 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 Amazon
-- EC2 instance.
--
-- /See:/ 'newEc2InstanceAggregationResponse' smart constructor.
data Ec2InstanceAggregationResponse = Ec2InstanceAggregationResponse'
  { -- | The Amazon Web Services account for the Amazon EC2 instance.
    Ec2InstanceAggregationResponse -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Machine Image (AMI) of the Amazon EC2 instance.
    Ec2InstanceAggregationResponse -> Maybe Text
ami :: Prelude.Maybe Prelude.Text,
    -- | The tags attached to the instance.
    Ec2InstanceAggregationResponse -> Maybe (HashMap Text Text)
instanceTags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The number of network findings for the Amazon EC2 instance.
    Ec2InstanceAggregationResponse -> Maybe Integer
networkFindings :: Prelude.Maybe Prelude.Integer,
    -- | The operating system of the Amazon EC2 instance.
    Ec2InstanceAggregationResponse -> Maybe Text
operatingSystem :: Prelude.Maybe Prelude.Text,
    -- | An object that contains the count of matched findings per severity.
    Ec2InstanceAggregationResponse -> Maybe SeverityCounts
severityCounts :: Prelude.Maybe SeverityCounts,
    -- | The Amazon EC2 instance ID.
    Ec2InstanceAggregationResponse -> Text
instanceId :: Prelude.Text
  }
  deriving (Ec2InstanceAggregationResponse
-> Ec2InstanceAggregationResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Ec2InstanceAggregationResponse
-> Ec2InstanceAggregationResponse -> Bool
$c/= :: Ec2InstanceAggregationResponse
-> Ec2InstanceAggregationResponse -> Bool
== :: Ec2InstanceAggregationResponse
-> Ec2InstanceAggregationResponse -> Bool
$c== :: Ec2InstanceAggregationResponse
-> Ec2InstanceAggregationResponse -> Bool
Prelude.Eq, ReadPrec [Ec2InstanceAggregationResponse]
ReadPrec Ec2InstanceAggregationResponse
Int -> ReadS Ec2InstanceAggregationResponse
ReadS [Ec2InstanceAggregationResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Ec2InstanceAggregationResponse]
$creadListPrec :: ReadPrec [Ec2InstanceAggregationResponse]
readPrec :: ReadPrec Ec2InstanceAggregationResponse
$creadPrec :: ReadPrec Ec2InstanceAggregationResponse
readList :: ReadS [Ec2InstanceAggregationResponse]
$creadList :: ReadS [Ec2InstanceAggregationResponse]
readsPrec :: Int -> ReadS Ec2InstanceAggregationResponse
$creadsPrec :: Int -> ReadS Ec2InstanceAggregationResponse
Prelude.Read, Int -> Ec2InstanceAggregationResponse -> ShowS
[Ec2InstanceAggregationResponse] -> ShowS
Ec2InstanceAggregationResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Ec2InstanceAggregationResponse] -> ShowS
$cshowList :: [Ec2InstanceAggregationResponse] -> ShowS
show :: Ec2InstanceAggregationResponse -> String
$cshow :: Ec2InstanceAggregationResponse -> String
showsPrec :: Int -> Ec2InstanceAggregationResponse -> ShowS
$cshowsPrec :: Int -> Ec2InstanceAggregationResponse -> ShowS
Prelude.Show, forall x.
Rep Ec2InstanceAggregationResponse x
-> Ec2InstanceAggregationResponse
forall x.
Ec2InstanceAggregationResponse
-> Rep Ec2InstanceAggregationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep Ec2InstanceAggregationResponse x
-> Ec2InstanceAggregationResponse
$cfrom :: forall x.
Ec2InstanceAggregationResponse
-> Rep Ec2InstanceAggregationResponse x
Prelude.Generic)

-- |
-- Create a value of 'Ec2InstanceAggregationResponse' 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', 'ec2InstanceAggregationResponse_accountId' - The Amazon Web Services account for the Amazon EC2 instance.
--
-- 'ami', 'ec2InstanceAggregationResponse_ami' - The Amazon Machine Image (AMI) of the Amazon EC2 instance.
--
-- 'instanceTags', 'ec2InstanceAggregationResponse_instanceTags' - The tags attached to the instance.
--
-- 'networkFindings', 'ec2InstanceAggregationResponse_networkFindings' - The number of network findings for the Amazon EC2 instance.
--
-- 'operatingSystem', 'ec2InstanceAggregationResponse_operatingSystem' - The operating system of the Amazon EC2 instance.
--
-- 'severityCounts', 'ec2InstanceAggregationResponse_severityCounts' - An object that contains the count of matched findings per severity.
--
-- 'instanceId', 'ec2InstanceAggregationResponse_instanceId' - The Amazon EC2 instance ID.
newEc2InstanceAggregationResponse ::
  -- | 'instanceId'
  Prelude.Text ->
  Ec2InstanceAggregationResponse
newEc2InstanceAggregationResponse :: Text -> Ec2InstanceAggregationResponse
newEc2InstanceAggregationResponse Text
pInstanceId_ =
  Ec2InstanceAggregationResponse'
    { $sel:accountId:Ec2InstanceAggregationResponse' :: Maybe Text
accountId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:ami:Ec2InstanceAggregationResponse' :: Maybe Text
ami = forall a. Maybe a
Prelude.Nothing,
      $sel:instanceTags:Ec2InstanceAggregationResponse' :: Maybe (HashMap Text Text)
instanceTags = forall a. Maybe a
Prelude.Nothing,
      $sel:networkFindings:Ec2InstanceAggregationResponse' :: Maybe Integer
networkFindings = forall a. Maybe a
Prelude.Nothing,
      $sel:operatingSystem:Ec2InstanceAggregationResponse' :: Maybe Text
operatingSystem = forall a. Maybe a
Prelude.Nothing,
      $sel:severityCounts:Ec2InstanceAggregationResponse' :: Maybe SeverityCounts
severityCounts = forall a. Maybe a
Prelude.Nothing,
      $sel:instanceId:Ec2InstanceAggregationResponse' :: Text
instanceId = Text
pInstanceId_
    }

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

-- | The Amazon Machine Image (AMI) of the Amazon EC2 instance.
ec2InstanceAggregationResponse_ami :: Lens.Lens' Ec2InstanceAggregationResponse (Prelude.Maybe Prelude.Text)
ec2InstanceAggregationResponse_ami :: Lens' Ec2InstanceAggregationResponse (Maybe Text)
ec2InstanceAggregationResponse_ami = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Ec2InstanceAggregationResponse' {Maybe Text
ami :: Maybe Text
$sel:ami:Ec2InstanceAggregationResponse' :: Ec2InstanceAggregationResponse -> Maybe Text
ami} -> Maybe Text
ami) (\s :: Ec2InstanceAggregationResponse
s@Ec2InstanceAggregationResponse' {} Maybe Text
a -> Ec2InstanceAggregationResponse
s {$sel:ami:Ec2InstanceAggregationResponse' :: Maybe Text
ami = Maybe Text
a} :: Ec2InstanceAggregationResponse)

-- | The tags attached to the instance.
ec2InstanceAggregationResponse_instanceTags :: Lens.Lens' Ec2InstanceAggregationResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
ec2InstanceAggregationResponse_instanceTags :: Lens' Ec2InstanceAggregationResponse (Maybe (HashMap Text Text))
ec2InstanceAggregationResponse_instanceTags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Ec2InstanceAggregationResponse' {Maybe (HashMap Text Text)
instanceTags :: Maybe (HashMap Text Text)
$sel:instanceTags:Ec2InstanceAggregationResponse' :: Ec2InstanceAggregationResponse -> Maybe (HashMap Text Text)
instanceTags} -> Maybe (HashMap Text Text)
instanceTags) (\s :: Ec2InstanceAggregationResponse
s@Ec2InstanceAggregationResponse' {} Maybe (HashMap Text Text)
a -> Ec2InstanceAggregationResponse
s {$sel:instanceTags:Ec2InstanceAggregationResponse' :: Maybe (HashMap Text Text)
instanceTags = Maybe (HashMap Text Text)
a} :: Ec2InstanceAggregationResponse) 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 number of network findings for the Amazon EC2 instance.
ec2InstanceAggregationResponse_networkFindings :: Lens.Lens' Ec2InstanceAggregationResponse (Prelude.Maybe Prelude.Integer)
ec2InstanceAggregationResponse_networkFindings :: Lens' Ec2InstanceAggregationResponse (Maybe Integer)
ec2InstanceAggregationResponse_networkFindings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Ec2InstanceAggregationResponse' {Maybe Integer
networkFindings :: Maybe Integer
$sel:networkFindings:Ec2InstanceAggregationResponse' :: Ec2InstanceAggregationResponse -> Maybe Integer
networkFindings} -> Maybe Integer
networkFindings) (\s :: Ec2InstanceAggregationResponse
s@Ec2InstanceAggregationResponse' {} Maybe Integer
a -> Ec2InstanceAggregationResponse
s {$sel:networkFindings:Ec2InstanceAggregationResponse' :: Maybe Integer
networkFindings = Maybe Integer
a} :: Ec2InstanceAggregationResponse)

-- | The operating system of the Amazon EC2 instance.
ec2InstanceAggregationResponse_operatingSystem :: Lens.Lens' Ec2InstanceAggregationResponse (Prelude.Maybe Prelude.Text)
ec2InstanceAggregationResponse_operatingSystem :: Lens' Ec2InstanceAggregationResponse (Maybe Text)
ec2InstanceAggregationResponse_operatingSystem = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Ec2InstanceAggregationResponse' {Maybe Text
operatingSystem :: Maybe Text
$sel:operatingSystem:Ec2InstanceAggregationResponse' :: Ec2InstanceAggregationResponse -> Maybe Text
operatingSystem} -> Maybe Text
operatingSystem) (\s :: Ec2InstanceAggregationResponse
s@Ec2InstanceAggregationResponse' {} Maybe Text
a -> Ec2InstanceAggregationResponse
s {$sel:operatingSystem:Ec2InstanceAggregationResponse' :: Maybe Text
operatingSystem = Maybe Text
a} :: Ec2InstanceAggregationResponse)

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

-- | The Amazon EC2 instance ID.
ec2InstanceAggregationResponse_instanceId :: Lens.Lens' Ec2InstanceAggregationResponse Prelude.Text
ec2InstanceAggregationResponse_instanceId :: Lens' Ec2InstanceAggregationResponse Text
ec2InstanceAggregationResponse_instanceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Ec2InstanceAggregationResponse' {Text
instanceId :: Text
$sel:instanceId:Ec2InstanceAggregationResponse' :: Ec2InstanceAggregationResponse -> Text
instanceId} -> Text
instanceId) (\s :: Ec2InstanceAggregationResponse
s@Ec2InstanceAggregationResponse' {} Text
a -> Ec2InstanceAggregationResponse
s {$sel:instanceId:Ec2InstanceAggregationResponse' :: Text
instanceId = Text
a} :: Ec2InstanceAggregationResponse)

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

instance
  Prelude.Hashable
    Ec2InstanceAggregationResponse
  where
  hashWithSalt :: Int -> Ec2InstanceAggregationResponse -> Int
hashWithSalt
    Int
_salt
    Ec2InstanceAggregationResponse' {Maybe Integer
Maybe Text
Maybe (HashMap Text Text)
Maybe SeverityCounts
Text
instanceId :: Text
severityCounts :: Maybe SeverityCounts
operatingSystem :: Maybe Text
networkFindings :: Maybe Integer
instanceTags :: Maybe (HashMap Text Text)
ami :: Maybe Text
accountId :: Maybe Text
$sel:instanceId:Ec2InstanceAggregationResponse' :: Ec2InstanceAggregationResponse -> Text
$sel:severityCounts:Ec2InstanceAggregationResponse' :: Ec2InstanceAggregationResponse -> Maybe SeverityCounts
$sel:operatingSystem:Ec2InstanceAggregationResponse' :: Ec2InstanceAggregationResponse -> Maybe Text
$sel:networkFindings:Ec2InstanceAggregationResponse' :: Ec2InstanceAggregationResponse -> Maybe Integer
$sel:instanceTags:Ec2InstanceAggregationResponse' :: Ec2InstanceAggregationResponse -> Maybe (HashMap Text Text)
$sel:ami:Ec2InstanceAggregationResponse' :: Ec2InstanceAggregationResponse -> Maybe Text
$sel:accountId:Ec2InstanceAggregationResponse' :: Ec2InstanceAggregationResponse -> 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 Text
ami
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
instanceTags
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
networkFindings
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
operatingSystem
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SeverityCounts
severityCounts
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
instanceId

instance
  Prelude.NFData
    Ec2InstanceAggregationResponse
  where
  rnf :: Ec2InstanceAggregationResponse -> ()
rnf Ec2InstanceAggregationResponse' {Maybe Integer
Maybe Text
Maybe (HashMap Text Text)
Maybe SeverityCounts
Text
instanceId :: Text
severityCounts :: Maybe SeverityCounts
operatingSystem :: Maybe Text
networkFindings :: Maybe Integer
instanceTags :: Maybe (HashMap Text Text)
ami :: Maybe Text
accountId :: Maybe Text
$sel:instanceId:Ec2InstanceAggregationResponse' :: Ec2InstanceAggregationResponse -> Text
$sel:severityCounts:Ec2InstanceAggregationResponse' :: Ec2InstanceAggregationResponse -> Maybe SeverityCounts
$sel:operatingSystem:Ec2InstanceAggregationResponse' :: Ec2InstanceAggregationResponse -> Maybe Text
$sel:networkFindings:Ec2InstanceAggregationResponse' :: Ec2InstanceAggregationResponse -> Maybe Integer
$sel:instanceTags:Ec2InstanceAggregationResponse' :: Ec2InstanceAggregationResponse -> Maybe (HashMap Text Text)
$sel:ami:Ec2InstanceAggregationResponse' :: Ec2InstanceAggregationResponse -> Maybe Text
$sel:accountId:Ec2InstanceAggregationResponse' :: Ec2InstanceAggregationResponse -> 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 Text
ami
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
instanceTags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
networkFindings
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
operatingSystem
      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
instanceId