{-# 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.Config.Types.GroupedResourceCount
-- 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.Config.Types.GroupedResourceCount 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

-- | The count of resources that are grouped by the group name.
--
-- /See:/ 'newGroupedResourceCount' smart constructor.
data GroupedResourceCount = GroupedResourceCount'
  { -- | The name of the group that can be region, account ID, or resource type.
    -- For example, region1, region2 if the region was chosen as @GroupByKey@.
    GroupedResourceCount -> Text
groupName :: Prelude.Text,
    -- | The number of resources in the group.
    GroupedResourceCount -> Integer
resourceCount :: Prelude.Integer
  }
  deriving (GroupedResourceCount -> GroupedResourceCount -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GroupedResourceCount -> GroupedResourceCount -> Bool
$c/= :: GroupedResourceCount -> GroupedResourceCount -> Bool
== :: GroupedResourceCount -> GroupedResourceCount -> Bool
$c== :: GroupedResourceCount -> GroupedResourceCount -> Bool
Prelude.Eq, ReadPrec [GroupedResourceCount]
ReadPrec GroupedResourceCount
Int -> ReadS GroupedResourceCount
ReadS [GroupedResourceCount]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GroupedResourceCount]
$creadListPrec :: ReadPrec [GroupedResourceCount]
readPrec :: ReadPrec GroupedResourceCount
$creadPrec :: ReadPrec GroupedResourceCount
readList :: ReadS [GroupedResourceCount]
$creadList :: ReadS [GroupedResourceCount]
readsPrec :: Int -> ReadS GroupedResourceCount
$creadsPrec :: Int -> ReadS GroupedResourceCount
Prelude.Read, Int -> GroupedResourceCount -> ShowS
[GroupedResourceCount] -> ShowS
GroupedResourceCount -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GroupedResourceCount] -> ShowS
$cshowList :: [GroupedResourceCount] -> ShowS
show :: GroupedResourceCount -> String
$cshow :: GroupedResourceCount -> String
showsPrec :: Int -> GroupedResourceCount -> ShowS
$cshowsPrec :: Int -> GroupedResourceCount -> ShowS
Prelude.Show, forall x. Rep GroupedResourceCount x -> GroupedResourceCount
forall x. GroupedResourceCount -> Rep GroupedResourceCount x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GroupedResourceCount x -> GroupedResourceCount
$cfrom :: forall x. GroupedResourceCount -> Rep GroupedResourceCount x
Prelude.Generic)

-- |
-- Create a value of 'GroupedResourceCount' 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:
--
-- 'groupName', 'groupedResourceCount_groupName' - The name of the group that can be region, account ID, or resource type.
-- For example, region1, region2 if the region was chosen as @GroupByKey@.
--
-- 'resourceCount', 'groupedResourceCount_resourceCount' - The number of resources in the group.
newGroupedResourceCount ::
  -- | 'groupName'
  Prelude.Text ->
  -- | 'resourceCount'
  Prelude.Integer ->
  GroupedResourceCount
newGroupedResourceCount :: Text -> Integer -> GroupedResourceCount
newGroupedResourceCount Text
pGroupName_ Integer
pResourceCount_ =
  GroupedResourceCount'
    { $sel:groupName:GroupedResourceCount' :: Text
groupName = Text
pGroupName_,
      $sel:resourceCount:GroupedResourceCount' :: Integer
resourceCount = Integer
pResourceCount_
    }

-- | The name of the group that can be region, account ID, or resource type.
-- For example, region1, region2 if the region was chosen as @GroupByKey@.
groupedResourceCount_groupName :: Lens.Lens' GroupedResourceCount Prelude.Text
groupedResourceCount_groupName :: Lens' GroupedResourceCount Text
groupedResourceCount_groupName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GroupedResourceCount' {Text
groupName :: Text
$sel:groupName:GroupedResourceCount' :: GroupedResourceCount -> Text
groupName} -> Text
groupName) (\s :: GroupedResourceCount
s@GroupedResourceCount' {} Text
a -> GroupedResourceCount
s {$sel:groupName:GroupedResourceCount' :: Text
groupName = Text
a} :: GroupedResourceCount)

-- | The number of resources in the group.
groupedResourceCount_resourceCount :: Lens.Lens' GroupedResourceCount Prelude.Integer
groupedResourceCount_resourceCount :: Lens' GroupedResourceCount Integer
groupedResourceCount_resourceCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GroupedResourceCount' {Integer
resourceCount :: Integer
$sel:resourceCount:GroupedResourceCount' :: GroupedResourceCount -> Integer
resourceCount} -> Integer
resourceCount) (\s :: GroupedResourceCount
s@GroupedResourceCount' {} Integer
a -> GroupedResourceCount
s {$sel:resourceCount:GroupedResourceCount' :: Integer
resourceCount = Integer
a} :: GroupedResourceCount)

instance Data.FromJSON GroupedResourceCount where
  parseJSON :: Value -> Parser GroupedResourceCount
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"GroupedResourceCount"
      ( \Object
x ->
          Text -> Integer -> GroupedResourceCount
GroupedResourceCount'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"GroupName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ResourceCount")
      )

instance Prelude.Hashable GroupedResourceCount where
  hashWithSalt :: Int -> GroupedResourceCount -> Int
hashWithSalt Int
_salt GroupedResourceCount' {Integer
Text
resourceCount :: Integer
groupName :: Text
$sel:resourceCount:GroupedResourceCount' :: GroupedResourceCount -> Integer
$sel:groupName:GroupedResourceCount' :: GroupedResourceCount -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
groupName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Integer
resourceCount

instance Prelude.NFData GroupedResourceCount where
  rnf :: GroupedResourceCount -> ()
rnf GroupedResourceCount' {Integer
Text
resourceCount :: Integer
groupName :: Text
$sel:resourceCount:GroupedResourceCount' :: GroupedResourceCount -> Integer
$sel:groupName:GroupedResourceCount' :: GroupedResourceCount -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
groupName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Integer
resourceCount