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

-- | Information about the number of results that match the query. At this
-- time, Amazon Web Services Resource Explorer doesn\'t count more than
-- 1,000 matches for any query. This structure provides information about
-- whether the query exceeded this limit.
--
-- This field is included in every page when you paginate the results.
--
-- /See:/ 'newResourceCount' smart constructor.
data ResourceCount = ResourceCount'
  { -- | Indicates whether the @TotalResources@ value represents an exhaustive
    -- count of search results.
    --
    -- -   If @True@, it indicates that the search was exhaustive. Every
    --     resource that matches the query was counted.
    --
    -- -   If @False@, then the search reached the limit of 1,000 matching
    --     results, and stopped counting.
    ResourceCount -> Maybe Bool
complete :: Prelude.Maybe Prelude.Bool,
    -- | The number of resources that match the search query. This value can\'t
    -- exceed 1,000. If there are more than 1,000 resources that match the
    -- query, then only 1,000 are counted and the @Complete@ field is set to
    -- false. We recommend that you refine your query to return a smaller
    -- number of results.
    ResourceCount -> Maybe Integer
totalResources :: Prelude.Maybe Prelude.Integer
  }
  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:
--
-- 'complete', 'resourceCount_complete' - Indicates whether the @TotalResources@ value represents an exhaustive
-- count of search results.
--
-- -   If @True@, it indicates that the search was exhaustive. Every
--     resource that matches the query was counted.
--
-- -   If @False@, then the search reached the limit of 1,000 matching
--     results, and stopped counting.
--
-- 'totalResources', 'resourceCount_totalResources' - The number of resources that match the search query. This value can\'t
-- exceed 1,000. If there are more than 1,000 resources that match the
-- query, then only 1,000 are counted and the @Complete@ field is set to
-- false. We recommend that you refine your query to return a smaller
-- number of results.
newResourceCount ::
  ResourceCount
newResourceCount :: ResourceCount
newResourceCount =
  ResourceCount'
    { $sel:complete:ResourceCount' :: Maybe Bool
complete = forall a. Maybe a
Prelude.Nothing,
      $sel:totalResources:ResourceCount' :: Maybe Integer
totalResources = forall a. Maybe a
Prelude.Nothing
    }

-- | Indicates whether the @TotalResources@ value represents an exhaustive
-- count of search results.
--
-- -   If @True@, it indicates that the search was exhaustive. Every
--     resource that matches the query was counted.
--
-- -   If @False@, then the search reached the limit of 1,000 matching
--     results, and stopped counting.
resourceCount_complete :: Lens.Lens' ResourceCount (Prelude.Maybe Prelude.Bool)
resourceCount_complete :: Lens' ResourceCount (Maybe Bool)
resourceCount_complete = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceCount' {Maybe Bool
complete :: Maybe Bool
$sel:complete:ResourceCount' :: ResourceCount -> Maybe Bool
complete} -> Maybe Bool
complete) (\s :: ResourceCount
s@ResourceCount' {} Maybe Bool
a -> ResourceCount
s {$sel:complete:ResourceCount' :: Maybe Bool
complete = Maybe Bool
a} :: ResourceCount)

-- | The number of resources that match the search query. This value can\'t
-- exceed 1,000. If there are more than 1,000 resources that match the
-- query, then only 1,000 are counted and the @Complete@ field is set to
-- false. We recommend that you refine your query to return a smaller
-- number of results.
resourceCount_totalResources :: Lens.Lens' ResourceCount (Prelude.Maybe Prelude.Integer)
resourceCount_totalResources :: Lens' ResourceCount (Maybe Integer)
resourceCount_totalResources = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceCount' {Maybe Integer
totalResources :: Maybe Integer
$sel:totalResources:ResourceCount' :: ResourceCount -> Maybe Integer
totalResources} -> Maybe Integer
totalResources) (\s :: ResourceCount
s@ResourceCount' {} Maybe Integer
a -> ResourceCount
s {$sel:totalResources:ResourceCount' :: Maybe Integer
totalResources = Maybe Integer
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 Bool -> Maybe Integer -> 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
"Complete")
            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
"TotalResources")
      )

instance Prelude.Hashable ResourceCount where
  hashWithSalt :: Int -> ResourceCount -> Int
hashWithSalt Int
_salt ResourceCount' {Maybe Bool
Maybe Integer
totalResources :: Maybe Integer
complete :: Maybe Bool
$sel:totalResources:ResourceCount' :: ResourceCount -> Maybe Integer
$sel:complete:ResourceCount' :: ResourceCount -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
complete
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
totalResources

instance Prelude.NFData ResourceCount where
  rnf :: ResourceCount -> ()
rnf ResourceCount' {Maybe Bool
Maybe Integer
totalResources :: Maybe Integer
complete :: Maybe Bool
$sel:totalResources:ResourceCount' :: ResourceCount -> Maybe Integer
$sel:complete:ResourceCount' :: ResourceCount -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
complete
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
totalResources