{-# 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.TitleAggregation
-- 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.TitleAggregation 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.AggregationResourceType
import Amazonka.Inspector2.Types.SortOrder
import Amazonka.Inspector2.Types.StringFilter
import Amazonka.Inspector2.Types.TitleSortBy
import qualified Amazonka.Prelude as Prelude

-- | The details that define an aggregation based on finding title.
--
-- /See:/ 'newTitleAggregation' smart constructor.
data TitleAggregation = TitleAggregation'
  { -- | The resource type to aggregate on.
    TitleAggregation -> Maybe AggregationResourceType
resourceType :: Prelude.Maybe AggregationResourceType,
    -- | The value to sort results by.
    TitleAggregation -> Maybe TitleSortBy
sortBy :: Prelude.Maybe TitleSortBy,
    -- | The order to sort results by.
    TitleAggregation -> Maybe SortOrder
sortOrder :: Prelude.Maybe SortOrder,
    -- | The finding titles to aggregate on.
    TitleAggregation -> Maybe (NonEmpty StringFilter)
titles :: Prelude.Maybe (Prelude.NonEmpty StringFilter),
    -- | The vulnerability IDs of the findings.
    TitleAggregation -> Maybe (NonEmpty StringFilter)
vulnerabilityIds :: Prelude.Maybe (Prelude.NonEmpty StringFilter)
  }
  deriving (TitleAggregation -> TitleAggregation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TitleAggregation -> TitleAggregation -> Bool
$c/= :: TitleAggregation -> TitleAggregation -> Bool
== :: TitleAggregation -> TitleAggregation -> Bool
$c== :: TitleAggregation -> TitleAggregation -> Bool
Prelude.Eq, ReadPrec [TitleAggregation]
ReadPrec TitleAggregation
Int -> ReadS TitleAggregation
ReadS [TitleAggregation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TitleAggregation]
$creadListPrec :: ReadPrec [TitleAggregation]
readPrec :: ReadPrec TitleAggregation
$creadPrec :: ReadPrec TitleAggregation
readList :: ReadS [TitleAggregation]
$creadList :: ReadS [TitleAggregation]
readsPrec :: Int -> ReadS TitleAggregation
$creadsPrec :: Int -> ReadS TitleAggregation
Prelude.Read, Int -> TitleAggregation -> ShowS
[TitleAggregation] -> ShowS
TitleAggregation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TitleAggregation] -> ShowS
$cshowList :: [TitleAggregation] -> ShowS
show :: TitleAggregation -> String
$cshow :: TitleAggregation -> String
showsPrec :: Int -> TitleAggregation -> ShowS
$cshowsPrec :: Int -> TitleAggregation -> ShowS
Prelude.Show, forall x. Rep TitleAggregation x -> TitleAggregation
forall x. TitleAggregation -> Rep TitleAggregation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TitleAggregation x -> TitleAggregation
$cfrom :: forall x. TitleAggregation -> Rep TitleAggregation x
Prelude.Generic)

-- |
-- Create a value of 'TitleAggregation' 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:
--
-- 'resourceType', 'titleAggregation_resourceType' - The resource type to aggregate on.
--
-- 'sortBy', 'titleAggregation_sortBy' - The value to sort results by.
--
-- 'sortOrder', 'titleAggregation_sortOrder' - The order to sort results by.
--
-- 'titles', 'titleAggregation_titles' - The finding titles to aggregate on.
--
-- 'vulnerabilityIds', 'titleAggregation_vulnerabilityIds' - The vulnerability IDs of the findings.
newTitleAggregation ::
  TitleAggregation
newTitleAggregation :: TitleAggregation
newTitleAggregation =
  TitleAggregation'
    { $sel:resourceType:TitleAggregation' :: Maybe AggregationResourceType
resourceType = forall a. Maybe a
Prelude.Nothing,
      $sel:sortBy:TitleAggregation' :: Maybe TitleSortBy
sortBy = forall a. Maybe a
Prelude.Nothing,
      $sel:sortOrder:TitleAggregation' :: Maybe SortOrder
sortOrder = forall a. Maybe a
Prelude.Nothing,
      $sel:titles:TitleAggregation' :: Maybe (NonEmpty StringFilter)
titles = forall a. Maybe a
Prelude.Nothing,
      $sel:vulnerabilityIds:TitleAggregation' :: Maybe (NonEmpty StringFilter)
vulnerabilityIds = forall a. Maybe a
Prelude.Nothing
    }

-- | The resource type to aggregate on.
titleAggregation_resourceType :: Lens.Lens' TitleAggregation (Prelude.Maybe AggregationResourceType)
titleAggregation_resourceType :: Lens' TitleAggregation (Maybe AggregationResourceType)
titleAggregation_resourceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TitleAggregation' {Maybe AggregationResourceType
resourceType :: Maybe AggregationResourceType
$sel:resourceType:TitleAggregation' :: TitleAggregation -> Maybe AggregationResourceType
resourceType} -> Maybe AggregationResourceType
resourceType) (\s :: TitleAggregation
s@TitleAggregation' {} Maybe AggregationResourceType
a -> TitleAggregation
s {$sel:resourceType:TitleAggregation' :: Maybe AggregationResourceType
resourceType = Maybe AggregationResourceType
a} :: TitleAggregation)

-- | The value to sort results by.
titleAggregation_sortBy :: Lens.Lens' TitleAggregation (Prelude.Maybe TitleSortBy)
titleAggregation_sortBy :: Lens' TitleAggregation (Maybe TitleSortBy)
titleAggregation_sortBy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TitleAggregation' {Maybe TitleSortBy
sortBy :: Maybe TitleSortBy
$sel:sortBy:TitleAggregation' :: TitleAggregation -> Maybe TitleSortBy
sortBy} -> Maybe TitleSortBy
sortBy) (\s :: TitleAggregation
s@TitleAggregation' {} Maybe TitleSortBy
a -> TitleAggregation
s {$sel:sortBy:TitleAggregation' :: Maybe TitleSortBy
sortBy = Maybe TitleSortBy
a} :: TitleAggregation)

-- | The order to sort results by.
titleAggregation_sortOrder :: Lens.Lens' TitleAggregation (Prelude.Maybe SortOrder)
titleAggregation_sortOrder :: Lens' TitleAggregation (Maybe SortOrder)
titleAggregation_sortOrder = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TitleAggregation' {Maybe SortOrder
sortOrder :: Maybe SortOrder
$sel:sortOrder:TitleAggregation' :: TitleAggregation -> Maybe SortOrder
sortOrder} -> Maybe SortOrder
sortOrder) (\s :: TitleAggregation
s@TitleAggregation' {} Maybe SortOrder
a -> TitleAggregation
s {$sel:sortOrder:TitleAggregation' :: Maybe SortOrder
sortOrder = Maybe SortOrder
a} :: TitleAggregation)

-- | The finding titles to aggregate on.
titleAggregation_titles :: Lens.Lens' TitleAggregation (Prelude.Maybe (Prelude.NonEmpty StringFilter))
titleAggregation_titles :: Lens' TitleAggregation (Maybe (NonEmpty StringFilter))
titleAggregation_titles = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TitleAggregation' {Maybe (NonEmpty StringFilter)
titles :: Maybe (NonEmpty StringFilter)
$sel:titles:TitleAggregation' :: TitleAggregation -> Maybe (NonEmpty StringFilter)
titles} -> Maybe (NonEmpty StringFilter)
titles) (\s :: TitleAggregation
s@TitleAggregation' {} Maybe (NonEmpty StringFilter)
a -> TitleAggregation
s {$sel:titles:TitleAggregation' :: Maybe (NonEmpty StringFilter)
titles = Maybe (NonEmpty StringFilter)
a} :: TitleAggregation) 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 vulnerability IDs of the findings.
titleAggregation_vulnerabilityIds :: Lens.Lens' TitleAggregation (Prelude.Maybe (Prelude.NonEmpty StringFilter))
titleAggregation_vulnerabilityIds :: Lens' TitleAggregation (Maybe (NonEmpty StringFilter))
titleAggregation_vulnerabilityIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TitleAggregation' {Maybe (NonEmpty StringFilter)
vulnerabilityIds :: Maybe (NonEmpty StringFilter)
$sel:vulnerabilityIds:TitleAggregation' :: TitleAggregation -> Maybe (NonEmpty StringFilter)
vulnerabilityIds} -> Maybe (NonEmpty StringFilter)
vulnerabilityIds) (\s :: TitleAggregation
s@TitleAggregation' {} Maybe (NonEmpty StringFilter)
a -> TitleAggregation
s {$sel:vulnerabilityIds:TitleAggregation' :: Maybe (NonEmpty StringFilter)
vulnerabilityIds = Maybe (NonEmpty StringFilter)
a} :: TitleAggregation) 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

instance Prelude.Hashable TitleAggregation where
  hashWithSalt :: Int -> TitleAggregation -> Int
hashWithSalt Int
_salt TitleAggregation' {Maybe (NonEmpty StringFilter)
Maybe AggregationResourceType
Maybe SortOrder
Maybe TitleSortBy
vulnerabilityIds :: Maybe (NonEmpty StringFilter)
titles :: Maybe (NonEmpty StringFilter)
sortOrder :: Maybe SortOrder
sortBy :: Maybe TitleSortBy
resourceType :: Maybe AggregationResourceType
$sel:vulnerabilityIds:TitleAggregation' :: TitleAggregation -> Maybe (NonEmpty StringFilter)
$sel:titles:TitleAggregation' :: TitleAggregation -> Maybe (NonEmpty StringFilter)
$sel:sortOrder:TitleAggregation' :: TitleAggregation -> Maybe SortOrder
$sel:sortBy:TitleAggregation' :: TitleAggregation -> Maybe TitleSortBy
$sel:resourceType:TitleAggregation' :: TitleAggregation -> Maybe AggregationResourceType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AggregationResourceType
resourceType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TitleSortBy
sortBy
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SortOrder
sortOrder
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty StringFilter)
titles
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty StringFilter)
vulnerabilityIds

instance Prelude.NFData TitleAggregation where
  rnf :: TitleAggregation -> ()
rnf TitleAggregation' {Maybe (NonEmpty StringFilter)
Maybe AggregationResourceType
Maybe SortOrder
Maybe TitleSortBy
vulnerabilityIds :: Maybe (NonEmpty StringFilter)
titles :: Maybe (NonEmpty StringFilter)
sortOrder :: Maybe SortOrder
sortBy :: Maybe TitleSortBy
resourceType :: Maybe AggregationResourceType
$sel:vulnerabilityIds:TitleAggregation' :: TitleAggregation -> Maybe (NonEmpty StringFilter)
$sel:titles:TitleAggregation' :: TitleAggregation -> Maybe (NonEmpty StringFilter)
$sel:sortOrder:TitleAggregation' :: TitleAggregation -> Maybe SortOrder
$sel:sortBy:TitleAggregation' :: TitleAggregation -> Maybe TitleSortBy
$sel:resourceType:TitleAggregation' :: TitleAggregation -> Maybe AggregationResourceType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AggregationResourceType
resourceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TitleSortBy
sortBy
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SortOrder
sortOrder
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty StringFilter)
titles
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty StringFilter)
vulnerabilityIds

instance Data.ToJSON TitleAggregation where
  toJSON :: TitleAggregation -> Value
toJSON TitleAggregation' {Maybe (NonEmpty StringFilter)
Maybe AggregationResourceType
Maybe SortOrder
Maybe TitleSortBy
vulnerabilityIds :: Maybe (NonEmpty StringFilter)
titles :: Maybe (NonEmpty StringFilter)
sortOrder :: Maybe SortOrder
sortBy :: Maybe TitleSortBy
resourceType :: Maybe AggregationResourceType
$sel:vulnerabilityIds:TitleAggregation' :: TitleAggregation -> Maybe (NonEmpty StringFilter)
$sel:titles:TitleAggregation' :: TitleAggregation -> Maybe (NonEmpty StringFilter)
$sel:sortOrder:TitleAggregation' :: TitleAggregation -> Maybe SortOrder
$sel:sortBy:TitleAggregation' :: TitleAggregation -> Maybe TitleSortBy
$sel:resourceType:TitleAggregation' :: TitleAggregation -> Maybe AggregationResourceType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"resourceType" 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 AggregationResourceType
resourceType,
            (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 TitleSortBy
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,
            (Key
"titles" 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)
titles,
            (Key
"vulnerabilityIds" 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)
vulnerabilityIds
          ]
      )