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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(GroupedResourceCount -> GroupedResourceCount -> Bool)
-> (GroupedResourceCount -> GroupedResourceCount -> Bool)
-> Eq GroupedResourceCount
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]
(Int -> ReadS GroupedResourceCount)
-> ReadS [GroupedResourceCount]
-> ReadPrec GroupedResourceCount
-> ReadPrec [GroupedResourceCount]
-> Read 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
(Int -> GroupedResourceCount -> ShowS)
-> (GroupedResourceCount -> String)
-> ([GroupedResourceCount] -> ShowS)
-> Show GroupedResourceCount
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. GroupedResourceCount -> Rep GroupedResourceCount x)
-> (forall x. Rep GroupedResourceCount x -> GroupedResourceCount)
-> Generic GroupedResourceCount
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' :: Text -> Integer -> GroupedResourceCount
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 :: (Text -> f Text) -> GroupedResourceCount -> f GroupedResourceCount
groupedResourceCount_groupName = (GroupedResourceCount -> Text)
-> (GroupedResourceCount -> Text -> GroupedResourceCount)
-> Lens GroupedResourceCount GroupedResourceCount Text Text
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 :: (Integer -> f Integer)
-> GroupedResourceCount -> f GroupedResourceCount
groupedResourceCount_resourceCount = (GroupedResourceCount -> Integer)
-> (GroupedResourceCount -> Integer -> GroupedResourceCount)
-> Lens GroupedResourceCount GroupedResourceCount Integer Integer
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 Core.FromJSON GroupedResourceCount where
  parseJSON :: Value -> Parser GroupedResourceCount
parseJSON =
    String
-> (Object -> Parser GroupedResourceCount)
-> Value
-> Parser GroupedResourceCount
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"GroupedResourceCount"
      ( \Object
x ->
          Text -> Integer -> GroupedResourceCount
GroupedResourceCount'
            (Text -> Integer -> GroupedResourceCount)
-> Parser Text -> Parser (Integer -> GroupedResourceCount)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"GroupName")
            Parser (Integer -> GroupedResourceCount)
-> Parser Integer -> Parser GroupedResourceCount
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Integer
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ResourceCount")
      )

instance Prelude.Hashable GroupedResourceCount

instance Prelude.NFData GroupedResourceCount