{-# 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.LambdaFunctionAggregation
-- 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.LambdaFunctionAggregation 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.LambdaFunctionSortBy
import Amazonka.Inspector2.Types.MapFilter
import Amazonka.Inspector2.Types.SortOrder
import Amazonka.Inspector2.Types.StringFilter
import qualified Amazonka.Prelude as Prelude

-- | The details that define a findings aggregation based on AWS Lambda
-- functions.
--
-- /See:/ 'newLambdaFunctionAggregation' smart constructor.
data LambdaFunctionAggregation = LambdaFunctionAggregation'
  { -- | The AWS Lambda function names to include in the aggregation results.
    LambdaFunctionAggregation -> Maybe (NonEmpty StringFilter)
functionNames :: Prelude.Maybe (Prelude.NonEmpty StringFilter),
    -- | The tags to include in the aggregation results.
    LambdaFunctionAggregation -> Maybe (NonEmpty MapFilter)
functionTags :: Prelude.Maybe (Prelude.NonEmpty MapFilter),
    -- | The resource IDs to include in the aggregation results.
    LambdaFunctionAggregation -> Maybe (NonEmpty StringFilter)
resourceIds :: Prelude.Maybe (Prelude.NonEmpty StringFilter),
    -- | Returns findings aggregated by AWS Lambda function runtime environments.
    LambdaFunctionAggregation -> Maybe (NonEmpty StringFilter)
runtimes :: Prelude.Maybe (Prelude.NonEmpty StringFilter),
    -- | The finding severity to use for sorting the results.
    LambdaFunctionAggregation -> Maybe LambdaFunctionSortBy
sortBy :: Prelude.Maybe LambdaFunctionSortBy,
    -- | The order to use for sorting the results.
    LambdaFunctionAggregation -> Maybe SortOrder
sortOrder :: Prelude.Maybe SortOrder
  }
  deriving (LambdaFunctionAggregation -> LambdaFunctionAggregation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LambdaFunctionAggregation -> LambdaFunctionAggregation -> Bool
$c/= :: LambdaFunctionAggregation -> LambdaFunctionAggregation -> Bool
== :: LambdaFunctionAggregation -> LambdaFunctionAggregation -> Bool
$c== :: LambdaFunctionAggregation -> LambdaFunctionAggregation -> Bool
Prelude.Eq, ReadPrec [LambdaFunctionAggregation]
ReadPrec LambdaFunctionAggregation
Int -> ReadS LambdaFunctionAggregation
ReadS [LambdaFunctionAggregation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LambdaFunctionAggregation]
$creadListPrec :: ReadPrec [LambdaFunctionAggregation]
readPrec :: ReadPrec LambdaFunctionAggregation
$creadPrec :: ReadPrec LambdaFunctionAggregation
readList :: ReadS [LambdaFunctionAggregation]
$creadList :: ReadS [LambdaFunctionAggregation]
readsPrec :: Int -> ReadS LambdaFunctionAggregation
$creadsPrec :: Int -> ReadS LambdaFunctionAggregation
Prelude.Read, Int -> LambdaFunctionAggregation -> ShowS
[LambdaFunctionAggregation] -> ShowS
LambdaFunctionAggregation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LambdaFunctionAggregation] -> ShowS
$cshowList :: [LambdaFunctionAggregation] -> ShowS
show :: LambdaFunctionAggregation -> String
$cshow :: LambdaFunctionAggregation -> String
showsPrec :: Int -> LambdaFunctionAggregation -> ShowS
$cshowsPrec :: Int -> LambdaFunctionAggregation -> ShowS
Prelude.Show, forall x.
Rep LambdaFunctionAggregation x -> LambdaFunctionAggregation
forall x.
LambdaFunctionAggregation -> Rep LambdaFunctionAggregation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep LambdaFunctionAggregation x -> LambdaFunctionAggregation
$cfrom :: forall x.
LambdaFunctionAggregation -> Rep LambdaFunctionAggregation x
Prelude.Generic)

-- |
-- Create a value of 'LambdaFunctionAggregation' 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:
--
-- 'functionNames', 'lambdaFunctionAggregation_functionNames' - The AWS Lambda function names to include in the aggregation results.
--
-- 'functionTags', 'lambdaFunctionAggregation_functionTags' - The tags to include in the aggregation results.
--
-- 'resourceIds', 'lambdaFunctionAggregation_resourceIds' - The resource IDs to include in the aggregation results.
--
-- 'runtimes', 'lambdaFunctionAggregation_runtimes' - Returns findings aggregated by AWS Lambda function runtime environments.
--
-- 'sortBy', 'lambdaFunctionAggregation_sortBy' - The finding severity to use for sorting the results.
--
-- 'sortOrder', 'lambdaFunctionAggregation_sortOrder' - The order to use for sorting the results.
newLambdaFunctionAggregation ::
  LambdaFunctionAggregation
newLambdaFunctionAggregation :: LambdaFunctionAggregation
newLambdaFunctionAggregation =
  LambdaFunctionAggregation'
    { $sel:functionNames:LambdaFunctionAggregation' :: Maybe (NonEmpty StringFilter)
functionNames =
        forall a. Maybe a
Prelude.Nothing,
      $sel:functionTags:LambdaFunctionAggregation' :: Maybe (NonEmpty MapFilter)
functionTags = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceIds:LambdaFunctionAggregation' :: Maybe (NonEmpty StringFilter)
resourceIds = forall a. Maybe a
Prelude.Nothing,
      $sel:runtimes:LambdaFunctionAggregation' :: Maybe (NonEmpty StringFilter)
runtimes = forall a. Maybe a
Prelude.Nothing,
      $sel:sortBy:LambdaFunctionAggregation' :: Maybe LambdaFunctionSortBy
sortBy = forall a. Maybe a
Prelude.Nothing,
      $sel:sortOrder:LambdaFunctionAggregation' :: Maybe SortOrder
sortOrder = forall a. Maybe a
Prelude.Nothing
    }

-- | The AWS Lambda function names to include in the aggregation results.
lambdaFunctionAggregation_functionNames :: Lens.Lens' LambdaFunctionAggregation (Prelude.Maybe (Prelude.NonEmpty StringFilter))
lambdaFunctionAggregation_functionNames :: Lens' LambdaFunctionAggregation (Maybe (NonEmpty StringFilter))
lambdaFunctionAggregation_functionNames = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaFunctionAggregation' {Maybe (NonEmpty StringFilter)
functionNames :: Maybe (NonEmpty StringFilter)
$sel:functionNames:LambdaFunctionAggregation' :: LambdaFunctionAggregation -> Maybe (NonEmpty StringFilter)
functionNames} -> Maybe (NonEmpty StringFilter)
functionNames) (\s :: LambdaFunctionAggregation
s@LambdaFunctionAggregation' {} Maybe (NonEmpty StringFilter)
a -> LambdaFunctionAggregation
s {$sel:functionNames:LambdaFunctionAggregation' :: Maybe (NonEmpty StringFilter)
functionNames = Maybe (NonEmpty StringFilter)
a} :: LambdaFunctionAggregation) 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 tags to include in the aggregation results.
lambdaFunctionAggregation_functionTags :: Lens.Lens' LambdaFunctionAggregation (Prelude.Maybe (Prelude.NonEmpty MapFilter))
lambdaFunctionAggregation_functionTags :: Lens' LambdaFunctionAggregation (Maybe (NonEmpty MapFilter))
lambdaFunctionAggregation_functionTags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaFunctionAggregation' {Maybe (NonEmpty MapFilter)
functionTags :: Maybe (NonEmpty MapFilter)
$sel:functionTags:LambdaFunctionAggregation' :: LambdaFunctionAggregation -> Maybe (NonEmpty MapFilter)
functionTags} -> Maybe (NonEmpty MapFilter)
functionTags) (\s :: LambdaFunctionAggregation
s@LambdaFunctionAggregation' {} Maybe (NonEmpty MapFilter)
a -> LambdaFunctionAggregation
s {$sel:functionTags:LambdaFunctionAggregation' :: Maybe (NonEmpty MapFilter)
functionTags = Maybe (NonEmpty MapFilter)
a} :: LambdaFunctionAggregation) 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 resource IDs to include in the aggregation results.
lambdaFunctionAggregation_resourceIds :: Lens.Lens' LambdaFunctionAggregation (Prelude.Maybe (Prelude.NonEmpty StringFilter))
lambdaFunctionAggregation_resourceIds :: Lens' LambdaFunctionAggregation (Maybe (NonEmpty StringFilter))
lambdaFunctionAggregation_resourceIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaFunctionAggregation' {Maybe (NonEmpty StringFilter)
resourceIds :: Maybe (NonEmpty StringFilter)
$sel:resourceIds:LambdaFunctionAggregation' :: LambdaFunctionAggregation -> Maybe (NonEmpty StringFilter)
resourceIds} -> Maybe (NonEmpty StringFilter)
resourceIds) (\s :: LambdaFunctionAggregation
s@LambdaFunctionAggregation' {} Maybe (NonEmpty StringFilter)
a -> LambdaFunctionAggregation
s {$sel:resourceIds:LambdaFunctionAggregation' :: Maybe (NonEmpty StringFilter)
resourceIds = Maybe (NonEmpty StringFilter)
a} :: LambdaFunctionAggregation) 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

-- | Returns findings aggregated by AWS Lambda function runtime environments.
lambdaFunctionAggregation_runtimes :: Lens.Lens' LambdaFunctionAggregation (Prelude.Maybe (Prelude.NonEmpty StringFilter))
lambdaFunctionAggregation_runtimes :: Lens' LambdaFunctionAggregation (Maybe (NonEmpty StringFilter))
lambdaFunctionAggregation_runtimes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaFunctionAggregation' {Maybe (NonEmpty StringFilter)
runtimes :: Maybe (NonEmpty StringFilter)
$sel:runtimes:LambdaFunctionAggregation' :: LambdaFunctionAggregation -> Maybe (NonEmpty StringFilter)
runtimes} -> Maybe (NonEmpty StringFilter)
runtimes) (\s :: LambdaFunctionAggregation
s@LambdaFunctionAggregation' {} Maybe (NonEmpty StringFilter)
a -> LambdaFunctionAggregation
s {$sel:runtimes:LambdaFunctionAggregation' :: Maybe (NonEmpty StringFilter)
runtimes = Maybe (NonEmpty StringFilter)
a} :: LambdaFunctionAggregation) 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 finding severity to use for sorting the results.
lambdaFunctionAggregation_sortBy :: Lens.Lens' LambdaFunctionAggregation (Prelude.Maybe LambdaFunctionSortBy)
lambdaFunctionAggregation_sortBy :: Lens' LambdaFunctionAggregation (Maybe LambdaFunctionSortBy)
lambdaFunctionAggregation_sortBy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaFunctionAggregation' {Maybe LambdaFunctionSortBy
sortBy :: Maybe LambdaFunctionSortBy
$sel:sortBy:LambdaFunctionAggregation' :: LambdaFunctionAggregation -> Maybe LambdaFunctionSortBy
sortBy} -> Maybe LambdaFunctionSortBy
sortBy) (\s :: LambdaFunctionAggregation
s@LambdaFunctionAggregation' {} Maybe LambdaFunctionSortBy
a -> LambdaFunctionAggregation
s {$sel:sortBy:LambdaFunctionAggregation' :: Maybe LambdaFunctionSortBy
sortBy = Maybe LambdaFunctionSortBy
a} :: LambdaFunctionAggregation)

-- | The order to use for sorting the results.
lambdaFunctionAggregation_sortOrder :: Lens.Lens' LambdaFunctionAggregation (Prelude.Maybe SortOrder)
lambdaFunctionAggregation_sortOrder :: Lens' LambdaFunctionAggregation (Maybe SortOrder)
lambdaFunctionAggregation_sortOrder = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaFunctionAggregation' {Maybe SortOrder
sortOrder :: Maybe SortOrder
$sel:sortOrder:LambdaFunctionAggregation' :: LambdaFunctionAggregation -> Maybe SortOrder
sortOrder} -> Maybe SortOrder
sortOrder) (\s :: LambdaFunctionAggregation
s@LambdaFunctionAggregation' {} Maybe SortOrder
a -> LambdaFunctionAggregation
s {$sel:sortOrder:LambdaFunctionAggregation' :: Maybe SortOrder
sortOrder = Maybe SortOrder
a} :: LambdaFunctionAggregation)

instance Prelude.Hashable LambdaFunctionAggregation where
  hashWithSalt :: Int -> LambdaFunctionAggregation -> Int
hashWithSalt Int
_salt LambdaFunctionAggregation' {Maybe (NonEmpty MapFilter)
Maybe (NonEmpty StringFilter)
Maybe LambdaFunctionSortBy
Maybe SortOrder
sortOrder :: Maybe SortOrder
sortBy :: Maybe LambdaFunctionSortBy
runtimes :: Maybe (NonEmpty StringFilter)
resourceIds :: Maybe (NonEmpty StringFilter)
functionTags :: Maybe (NonEmpty MapFilter)
functionNames :: Maybe (NonEmpty StringFilter)
$sel:sortOrder:LambdaFunctionAggregation' :: LambdaFunctionAggregation -> Maybe SortOrder
$sel:sortBy:LambdaFunctionAggregation' :: LambdaFunctionAggregation -> Maybe LambdaFunctionSortBy
$sel:runtimes:LambdaFunctionAggregation' :: LambdaFunctionAggregation -> Maybe (NonEmpty StringFilter)
$sel:resourceIds:LambdaFunctionAggregation' :: LambdaFunctionAggregation -> Maybe (NonEmpty StringFilter)
$sel:functionTags:LambdaFunctionAggregation' :: LambdaFunctionAggregation -> Maybe (NonEmpty MapFilter)
$sel:functionNames:LambdaFunctionAggregation' :: LambdaFunctionAggregation -> Maybe (NonEmpty StringFilter)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty StringFilter)
functionNames
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty MapFilter)
functionTags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty StringFilter)
resourceIds
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty StringFilter)
runtimes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe LambdaFunctionSortBy
sortBy
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SortOrder
sortOrder

instance Prelude.NFData LambdaFunctionAggregation where
  rnf :: LambdaFunctionAggregation -> ()
rnf LambdaFunctionAggregation' {Maybe (NonEmpty MapFilter)
Maybe (NonEmpty StringFilter)
Maybe LambdaFunctionSortBy
Maybe SortOrder
sortOrder :: Maybe SortOrder
sortBy :: Maybe LambdaFunctionSortBy
runtimes :: Maybe (NonEmpty StringFilter)
resourceIds :: Maybe (NonEmpty StringFilter)
functionTags :: Maybe (NonEmpty MapFilter)
functionNames :: Maybe (NonEmpty StringFilter)
$sel:sortOrder:LambdaFunctionAggregation' :: LambdaFunctionAggregation -> Maybe SortOrder
$sel:sortBy:LambdaFunctionAggregation' :: LambdaFunctionAggregation -> Maybe LambdaFunctionSortBy
$sel:runtimes:LambdaFunctionAggregation' :: LambdaFunctionAggregation -> Maybe (NonEmpty StringFilter)
$sel:resourceIds:LambdaFunctionAggregation' :: LambdaFunctionAggregation -> Maybe (NonEmpty StringFilter)
$sel:functionTags:LambdaFunctionAggregation' :: LambdaFunctionAggregation -> Maybe (NonEmpty MapFilter)
$sel:functionNames:LambdaFunctionAggregation' :: LambdaFunctionAggregation -> Maybe (NonEmpty StringFilter)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty StringFilter)
functionNames
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty MapFilter)
functionTags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty StringFilter)
resourceIds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty StringFilter)
runtimes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe LambdaFunctionSortBy
sortBy
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SortOrder
sortOrder

instance Data.ToJSON LambdaFunctionAggregation where
  toJSON :: LambdaFunctionAggregation -> Value
toJSON LambdaFunctionAggregation' {Maybe (NonEmpty MapFilter)
Maybe (NonEmpty StringFilter)
Maybe LambdaFunctionSortBy
Maybe SortOrder
sortOrder :: Maybe SortOrder
sortBy :: Maybe LambdaFunctionSortBy
runtimes :: Maybe (NonEmpty StringFilter)
resourceIds :: Maybe (NonEmpty StringFilter)
functionTags :: Maybe (NonEmpty MapFilter)
functionNames :: Maybe (NonEmpty StringFilter)
$sel:sortOrder:LambdaFunctionAggregation' :: LambdaFunctionAggregation -> Maybe SortOrder
$sel:sortBy:LambdaFunctionAggregation' :: LambdaFunctionAggregation -> Maybe LambdaFunctionSortBy
$sel:runtimes:LambdaFunctionAggregation' :: LambdaFunctionAggregation -> Maybe (NonEmpty StringFilter)
$sel:resourceIds:LambdaFunctionAggregation' :: LambdaFunctionAggregation -> Maybe (NonEmpty StringFilter)
$sel:functionTags:LambdaFunctionAggregation' :: LambdaFunctionAggregation -> Maybe (NonEmpty MapFilter)
$sel:functionNames:LambdaFunctionAggregation' :: LambdaFunctionAggregation -> Maybe (NonEmpty StringFilter)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"functionNames" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty StringFilter)
functionNames,
            (Key
"functionTags" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty MapFilter)
functionTags,
            (Key
"resourceIds" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty StringFilter)
resourceIds,
            (Key
"runtimes" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty StringFilter)
runtimes,
            (Key
"sortBy" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe LambdaFunctionSortBy
sortBy,
            (Key
"sortOrder" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SortOrder
sortOrder
          ]
      )