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

import Amazonka.Config.Types.ResourceType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 resource type (for example, @\"AWS::EC2::Instance\"@).
    ResourceCount -> Maybe ResourceType
resourceType :: Prelude.Maybe ResourceType,
    -- | The number of resources.
    ResourceCount -> Maybe Integer
count :: Prelude.Maybe Prelude.Integer
  }
  deriving (ResourceCount -> ResourceCount -> Bool
(ResourceCount -> ResourceCount -> Bool)
-> (ResourceCount -> ResourceCount -> Bool) -> Eq ResourceCount
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]
(Int -> ReadS ResourceCount)
-> ReadS [ResourceCount]
-> ReadPrec ResourceCount
-> ReadPrec [ResourceCount]
-> Read 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
(Int -> ResourceCount -> ShowS)
-> (ResourceCount -> String)
-> ([ResourceCount] -> ShowS)
-> Show ResourceCount
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. ResourceCount -> Rep ResourceCount x)
-> (forall x. Rep ResourceCount x -> ResourceCount)
-> Generic ResourceCount
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:
--
-- 'resourceType', 'resourceCount_resourceType' - The resource type (for example, @\"AWS::EC2::Instance\"@).
--
-- 'count', 'resourceCount_count' - The number of resources.
newResourceCount ::
  ResourceCount
newResourceCount :: ResourceCount
newResourceCount =
  ResourceCount' :: Maybe ResourceType -> Maybe Integer -> ResourceCount
ResourceCount'
    { $sel:resourceType:ResourceCount' :: Maybe ResourceType
resourceType = Maybe ResourceType
forall a. Maybe a
Prelude.Nothing,
      $sel:count:ResourceCount' :: Maybe Integer
count = Maybe Integer
forall a. Maybe a
Prelude.Nothing
    }

-- | The resource type (for example, @\"AWS::EC2::Instance\"@).
resourceCount_resourceType :: Lens.Lens' ResourceCount (Prelude.Maybe ResourceType)
resourceCount_resourceType :: (Maybe ResourceType -> f (Maybe ResourceType))
-> ResourceCount -> f ResourceCount
resourceCount_resourceType = (ResourceCount -> Maybe ResourceType)
-> (ResourceCount -> Maybe ResourceType -> ResourceCount)
-> Lens
     ResourceCount
     ResourceCount
     (Maybe ResourceType)
     (Maybe 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)

-- | The number of resources.
resourceCount_count :: Lens.Lens' ResourceCount (Prelude.Maybe Prelude.Integer)
resourceCount_count :: (Maybe Integer -> f (Maybe Integer))
-> ResourceCount -> f ResourceCount
resourceCount_count = (ResourceCount -> Maybe Integer)
-> (ResourceCount -> Maybe Integer -> ResourceCount)
-> Lens ResourceCount ResourceCount (Maybe Integer) (Maybe Integer)
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)

instance Core.FromJSON ResourceCount where
  parseJSON :: Value -> Parser ResourceCount
parseJSON =
    String
-> (Object -> Parser ResourceCount)
-> Value
-> Parser ResourceCount
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ResourceCount"
      ( \Object
x ->
          Maybe ResourceType -> Maybe Integer -> ResourceCount
ResourceCount'
            (Maybe ResourceType -> Maybe Integer -> ResourceCount)
-> Parser (Maybe ResourceType)
-> Parser (Maybe Integer -> ResourceCount)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ResourceType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"resourceType")
            Parser (Maybe Integer -> ResourceCount)
-> Parser (Maybe Integer) -> Parser ResourceCount
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 ResourceCount

instance Prelude.NFData ResourceCount