{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MacieV2.Types.GroupCount where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 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,
    -- | The total number of findings in the group of query results.
    GroupCount -> Maybe Integer
count :: Prelude.Maybe Prelude.Integer
  }
  deriving (GroupCount -> GroupCount -> Bool
(GroupCount -> GroupCount -> Bool)
-> (GroupCount -> GroupCount -> Bool) -> Eq GroupCount
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]
(Int -> ReadS GroupCount)
-> ReadS [GroupCount]
-> ReadPrec GroupCount
-> ReadPrec [GroupCount]
-> Read 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
(Int -> GroupCount -> ShowS)
-> (GroupCount -> String)
-> ([GroupCount] -> ShowS)
-> Show GroupCount
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. GroupCount -> Rep GroupCount x)
-> (forall x. Rep GroupCount x -> GroupCount) -> Generic GroupCount
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:
--
-- '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.
--
-- 'count', 'groupCount_count' - The total number of findings in the group of query results.
newGroupCount ::
  GroupCount
newGroupCount :: GroupCount
newGroupCount =
  GroupCount' :: Maybe Text -> Maybe Integer -> GroupCount
GroupCount'
    { $sel:groupKey:GroupCount' :: Maybe Text
groupKey = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:count:GroupCount' :: Maybe Integer
count = Maybe Integer
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> GroupCount -> f GroupCount
groupCount_groupKey = (GroupCount -> Maybe Text)
-> (GroupCount -> Maybe Text -> GroupCount)
-> Lens GroupCount GroupCount (Maybe Text) (Maybe Text)
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)

-- | The total number of findings in the group of query results.
groupCount_count :: Lens.Lens' GroupCount (Prelude.Maybe Prelude.Integer)
groupCount_count :: (Maybe Integer -> f (Maybe Integer)) -> GroupCount -> f GroupCount
groupCount_count = (GroupCount -> Maybe Integer)
-> (GroupCount -> Maybe Integer -> GroupCount)
-> Lens GroupCount GroupCount (Maybe Integer) (Maybe Integer)
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)

instance Core.FromJSON GroupCount where
  parseJSON :: Value -> Parser GroupCount
parseJSON =
    String
-> (Object -> Parser GroupCount) -> Value -> Parser GroupCount
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"GroupCount"
      ( \Object
x ->
          Maybe Text -> Maybe Integer -> GroupCount
GroupCount'
            (Maybe Text -> Maybe Integer -> GroupCount)
-> Parser (Maybe Text) -> Parser (Maybe Integer -> GroupCount)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"groupKey")
            Parser (Maybe Integer -> GroupCount)
-> Parser (Maybe Integer) -> Parser GroupCount
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"count")
      )

instance Prelude.Hashable GroupCount

instance Prelude.NFData GroupCount