{-# 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.ResourceCount
-- 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.ResourceCount where

import Amazonka.Config.Types.ResourceType
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

-- | An object that contains the resource type and the number of resources.
--
-- /See:/ 'newResourceCount' smart constructor.
data ResourceCount = ResourceCount'
  { -- | The number of resources.
    ResourceCount -> Maybe Integer
count :: Prelude.Maybe Prelude.Integer,
    -- | The resource type (for example, @\"AWS::EC2::Instance\"@).
    ResourceCount -> Maybe ResourceType
resourceType :: Prelude.Maybe ResourceType
  }
  deriving (ResourceCount -> ResourceCount -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourceCount -> ResourceCount -> Bool
$c/= :: ResourceCount -> ResourceCount -> Bool
== :: ResourceCount -> ResourceCount -> Bool
$c== :: ResourceCount -> ResourceCount -> Bool
Prelude.Eq, ReadPrec [ResourceCount]
ReadPrec ResourceCount
Int -> ReadS ResourceCount
ReadS [ResourceCount]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourceCount]
$creadListPrec :: ReadPrec [ResourceCount]
readPrec :: ReadPrec ResourceCount
$creadPrec :: ReadPrec ResourceCount
readList :: ReadS [ResourceCount]
$creadList :: ReadS [ResourceCount]
readsPrec :: Int -> ReadS ResourceCount
$creadsPrec :: Int -> ReadS ResourceCount
Prelude.Read, Int -> ResourceCount -> ShowS
[ResourceCount] -> ShowS
ResourceCount -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourceCount] -> ShowS
$cshowList :: [ResourceCount] -> ShowS
show :: ResourceCount -> String
$cshow :: ResourceCount -> String
showsPrec :: Int -> ResourceCount -> ShowS
$cshowsPrec :: Int -> ResourceCount -> ShowS
Prelude.Show, forall x. Rep ResourceCount x -> ResourceCount
forall x. ResourceCount -> Rep ResourceCount x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResourceCount x -> ResourceCount
$cfrom :: forall x. ResourceCount -> Rep ResourceCount x
Prelude.Generic)

-- |
-- Create a value of 'ResourceCount' 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', 'resourceCount_count' - The number of resources.
--
-- 'resourceType', 'resourceCount_resourceType' - The resource type (for example, @\"AWS::EC2::Instance\"@).
newResourceCount ::
  ResourceCount
newResourceCount :: ResourceCount
newResourceCount =
  ResourceCount'
    { $sel:count:ResourceCount' :: Maybe Integer
count = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceType:ResourceCount' :: Maybe ResourceType
resourceType = forall a. Maybe a
Prelude.Nothing
    }

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

-- | The resource type (for example, @\"AWS::EC2::Instance\"@).
resourceCount_resourceType :: Lens.Lens' ResourceCount (Prelude.Maybe ResourceType)
resourceCount_resourceType :: Lens' ResourceCount (Maybe ResourceType)
resourceCount_resourceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceCount' {Maybe ResourceType
resourceType :: Maybe ResourceType
$sel:resourceType:ResourceCount' :: ResourceCount -> Maybe ResourceType
resourceType} -> Maybe ResourceType
resourceType) (\s :: ResourceCount
s@ResourceCount' {} Maybe ResourceType
a -> ResourceCount
s {$sel:resourceType:ResourceCount' :: Maybe ResourceType
resourceType = Maybe ResourceType
a} :: ResourceCount)

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

instance Prelude.Hashable ResourceCount where
  hashWithSalt :: Int -> ResourceCount -> Int
hashWithSalt Int
_salt ResourceCount' {Maybe Integer
Maybe ResourceType
resourceType :: Maybe ResourceType
count :: Maybe Integer
$sel:resourceType:ResourceCount' :: ResourceCount -> Maybe ResourceType
$sel:count:ResourceCount' :: ResourceCount -> 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 ResourceType
resourceType

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