{-# 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.MacieV2.Types.GroupCount
-- 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.MacieV2.Types.GroupCount where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Provides a group of results for a query that retrieved aggregated
-- statistical data about findings.
--
-- /See:/ 'newGroupCount' smart constructor.
data GroupCount = GroupCount'
  { -- | The total number of findings in the group of query results.
    GroupCount -> Maybe Integer
count :: Prelude.Maybe Prelude.Integer,
    -- | The name of the property that defines the group in the query results, as
    -- specified by the groupBy property in the query request.
    GroupCount -> Maybe Text
groupKey :: Prelude.Maybe Prelude.Text
  }
  deriving (GroupCount -> GroupCount -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GroupCount -> GroupCount -> Bool
$c/= :: GroupCount -> GroupCount -> Bool
== :: GroupCount -> GroupCount -> Bool
$c== :: GroupCount -> GroupCount -> Bool
Prelude.Eq, ReadPrec [GroupCount]
ReadPrec GroupCount
Int -> ReadS GroupCount
ReadS [GroupCount]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GroupCount]
$creadListPrec :: ReadPrec [GroupCount]
readPrec :: ReadPrec GroupCount
$creadPrec :: ReadPrec GroupCount
readList :: ReadS [GroupCount]
$creadList :: ReadS [GroupCount]
readsPrec :: Int -> ReadS GroupCount
$creadsPrec :: Int -> ReadS GroupCount
Prelude.Read, Int -> GroupCount -> ShowS
[GroupCount] -> ShowS
GroupCount -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GroupCount] -> ShowS
$cshowList :: [GroupCount] -> ShowS
show :: GroupCount -> String
$cshow :: GroupCount -> String
showsPrec :: Int -> GroupCount -> ShowS
$cshowsPrec :: Int -> GroupCount -> ShowS
Prelude.Show, forall x. Rep GroupCount x -> GroupCount
forall x. GroupCount -> Rep GroupCount x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GroupCount x -> GroupCount
$cfrom :: forall x. GroupCount -> Rep GroupCount x
Prelude.Generic)

-- |
-- Create a value of 'GroupCount' 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:
--
-- 'count', 'groupCount_count' - The total number of findings in the group of query results.
--
-- 'groupKey', 'groupCount_groupKey' - The name of the property that defines the group in the query results, as
-- specified by the groupBy property in the query request.
newGroupCount ::
  GroupCount
newGroupCount :: GroupCount
newGroupCount =
  GroupCount'
    { $sel:count:GroupCount' :: Maybe Integer
count = forall a. Maybe a
Prelude.Nothing,
      $sel:groupKey:GroupCount' :: Maybe Text
groupKey = forall a. Maybe a
Prelude.Nothing
    }

-- | The total number of findings in the group of query results.
groupCount_count :: Lens.Lens' GroupCount (Prelude.Maybe Prelude.Integer)
groupCount_count :: Lens' GroupCount (Maybe Integer)
groupCount_count = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GroupCount' {Maybe Integer
count :: Maybe Integer
$sel:count:GroupCount' :: GroupCount -> Maybe Integer
count} -> Maybe Integer
count) (\s :: GroupCount
s@GroupCount' {} Maybe Integer
a -> GroupCount
s {$sel:count:GroupCount' :: Maybe Integer
count = Maybe Integer
a} :: GroupCount)

-- | The name of the property that defines the group in the query results, as
-- specified by the groupBy property in the query request.
groupCount_groupKey :: Lens.Lens' GroupCount (Prelude.Maybe Prelude.Text)
groupCount_groupKey :: Lens' GroupCount (Maybe Text)
groupCount_groupKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GroupCount' {Maybe Text
groupKey :: Maybe Text
$sel:groupKey:GroupCount' :: GroupCount -> Maybe Text
groupKey} -> Maybe Text
groupKey) (\s :: GroupCount
s@GroupCount' {} Maybe Text
a -> GroupCount
s {$sel:groupKey:GroupCount' :: Maybe Text
groupKey = Maybe Text
a} :: GroupCount)

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

instance Prelude.Hashable GroupCount where
  hashWithSalt :: Int -> GroupCount -> Int
hashWithSalt Int
_salt GroupCount' {Maybe Integer
Maybe Text
groupKey :: Maybe Text
count :: Maybe Integer
$sel:groupKey:GroupCount' :: GroupCount -> Maybe Text
$sel:count:GroupCount' :: GroupCount -> Maybe Integer
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
count
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
groupKey

instance Prelude.NFData GroupCount where
  rnf :: GroupCount -> ()
rnf GroupCount' {Maybe Integer
Maybe Text
groupKey :: Maybe Text
count :: Maybe Integer
$sel:groupKey:GroupCount' :: GroupCount -> Maybe Text
$sel:count:GroupCount' :: GroupCount -> Maybe Integer
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
count
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
groupKey