{-# 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.Counts
-- 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.Counts 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.GroupKey
import qualified Amazonka.Prelude as Prelude

-- | a structure that contains information on the count of resources within a
-- group.
--
-- /See:/ 'newCounts' smart constructor.
data Counts = Counts'
  { -- | The number of resources.
    Counts -> Maybe Integer
count :: Prelude.Maybe Prelude.Integer,
    -- | The key associated with this group
    Counts -> Maybe GroupKey
groupKey :: Prelude.Maybe GroupKey
  }
  deriving (Counts -> Counts -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Counts -> Counts -> Bool
$c/= :: Counts -> Counts -> Bool
== :: Counts -> Counts -> Bool
$c== :: Counts -> Counts -> Bool
Prelude.Eq, ReadPrec [Counts]
ReadPrec Counts
Int -> ReadS Counts
ReadS [Counts]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Counts]
$creadListPrec :: ReadPrec [Counts]
readPrec :: ReadPrec Counts
$creadPrec :: ReadPrec Counts
readList :: ReadS [Counts]
$creadList :: ReadS [Counts]
readsPrec :: Int -> ReadS Counts
$creadsPrec :: Int -> ReadS Counts
Prelude.Read, Int -> Counts -> ShowS
[Counts] -> ShowS
Counts -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Counts] -> ShowS
$cshowList :: [Counts] -> ShowS
show :: Counts -> String
$cshow :: Counts -> String
showsPrec :: Int -> Counts -> ShowS
$cshowsPrec :: Int -> Counts -> ShowS
Prelude.Show, forall x. Rep Counts x -> Counts
forall x. Counts -> Rep Counts x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Counts x -> Counts
$cfrom :: forall x. Counts -> Rep Counts x
Prelude.Generic)

-- |
-- Create a value of 'Counts' 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', 'counts_count' - The number of resources.
--
-- 'groupKey', 'counts_groupKey' - The key associated with this group
newCounts ::
  Counts
newCounts :: Counts
newCounts =
  Counts'
    { $sel:count:Counts' :: Maybe Integer
count = forall a. Maybe a
Prelude.Nothing,
      $sel:groupKey:Counts' :: Maybe GroupKey
groupKey = forall a. Maybe a
Prelude.Nothing
    }

-- | The number of resources.
counts_count :: Lens.Lens' Counts (Prelude.Maybe Prelude.Integer)
counts_count :: Lens' Counts (Maybe Integer)
counts_count = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Counts' {Maybe Integer
count :: Maybe Integer
$sel:count:Counts' :: Counts -> Maybe Integer
count} -> Maybe Integer
count) (\s :: Counts
s@Counts' {} Maybe Integer
a -> Counts
s {$sel:count:Counts' :: Maybe Integer
count = Maybe Integer
a} :: Counts)

-- | The key associated with this group
counts_groupKey :: Lens.Lens' Counts (Prelude.Maybe GroupKey)
counts_groupKey :: Lens' Counts (Maybe GroupKey)
counts_groupKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Counts' {Maybe GroupKey
groupKey :: Maybe GroupKey
$sel:groupKey:Counts' :: Counts -> Maybe GroupKey
groupKey} -> Maybe GroupKey
groupKey) (\s :: Counts
s@Counts' {} Maybe GroupKey
a -> Counts
s {$sel:groupKey:Counts' :: Maybe GroupKey
groupKey = Maybe GroupKey
a} :: Counts)

instance Data.FromJSON Counts where
  parseJSON :: Value -> Parser Counts
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Counts"
      ( \Object
x ->
          Maybe Integer -> Maybe GroupKey -> Counts
Counts'
            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 Counts where
  hashWithSalt :: Int -> Counts -> Int
hashWithSalt Int
_salt Counts' {Maybe Integer
Maybe GroupKey
groupKey :: Maybe GroupKey
count :: Maybe Integer
$sel:groupKey:Counts' :: Counts -> Maybe GroupKey
$sel:count:Counts' :: Counts -> 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 GroupKey
groupKey

instance Prelude.NFData Counts where
  rnf :: Counts -> ()
rnf Counts' {Maybe Integer
Maybe GroupKey
groupKey :: Maybe GroupKey
count :: Maybe Integer
$sel:groupKey:Counts' :: Counts -> Maybe GroupKey
$sel:count:Counts' :: Counts -> 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 GroupKey
groupKey