{-# 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.CloudTrail.Types.QueryStatistics
-- 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.CloudTrail.Types.QueryStatistics 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

-- | Metadata about a query, such as the number of results.
--
-- /See:/ 'newQueryStatistics' smart constructor.
data QueryStatistics = QueryStatistics'
  { -- | The total bytes that the query scanned in the event data store. This
    -- value matches the number of bytes for which your account is billed for
    -- the query, unless the query is still running.
    QueryStatistics -> Maybe Integer
bytesScanned :: Prelude.Maybe Prelude.Integer,
    -- | The number of results returned.
    QueryStatistics -> Maybe Int
resultsCount :: Prelude.Maybe Prelude.Int,
    -- | The total number of results returned by a query.
    QueryStatistics -> Maybe Int
totalResultsCount :: Prelude.Maybe Prelude.Int
  }
  deriving (QueryStatistics -> QueryStatistics -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: QueryStatistics -> QueryStatistics -> Bool
$c/= :: QueryStatistics -> QueryStatistics -> Bool
== :: QueryStatistics -> QueryStatistics -> Bool
$c== :: QueryStatistics -> QueryStatistics -> Bool
Prelude.Eq, ReadPrec [QueryStatistics]
ReadPrec QueryStatistics
Int -> ReadS QueryStatistics
ReadS [QueryStatistics]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [QueryStatistics]
$creadListPrec :: ReadPrec [QueryStatistics]
readPrec :: ReadPrec QueryStatistics
$creadPrec :: ReadPrec QueryStatistics
readList :: ReadS [QueryStatistics]
$creadList :: ReadS [QueryStatistics]
readsPrec :: Int -> ReadS QueryStatistics
$creadsPrec :: Int -> ReadS QueryStatistics
Prelude.Read, Int -> QueryStatistics -> ShowS
[QueryStatistics] -> ShowS
QueryStatistics -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [QueryStatistics] -> ShowS
$cshowList :: [QueryStatistics] -> ShowS
show :: QueryStatistics -> String
$cshow :: QueryStatistics -> String
showsPrec :: Int -> QueryStatistics -> ShowS
$cshowsPrec :: Int -> QueryStatistics -> ShowS
Prelude.Show, forall x. Rep QueryStatistics x -> QueryStatistics
forall x. QueryStatistics -> Rep QueryStatistics x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep QueryStatistics x -> QueryStatistics
$cfrom :: forall x. QueryStatistics -> Rep QueryStatistics x
Prelude.Generic)

-- |
-- Create a value of 'QueryStatistics' 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:
--
-- 'bytesScanned', 'queryStatistics_bytesScanned' - The total bytes that the query scanned in the event data store. This
-- value matches the number of bytes for which your account is billed for
-- the query, unless the query is still running.
--
-- 'resultsCount', 'queryStatistics_resultsCount' - The number of results returned.
--
-- 'totalResultsCount', 'queryStatistics_totalResultsCount' - The total number of results returned by a query.
newQueryStatistics ::
  QueryStatistics
newQueryStatistics :: QueryStatistics
newQueryStatistics =
  QueryStatistics'
    { $sel:bytesScanned:QueryStatistics' :: Maybe Integer
bytesScanned = forall a. Maybe a
Prelude.Nothing,
      $sel:resultsCount:QueryStatistics' :: Maybe Int
resultsCount = forall a. Maybe a
Prelude.Nothing,
      $sel:totalResultsCount:QueryStatistics' :: Maybe Int
totalResultsCount = forall a. Maybe a
Prelude.Nothing
    }

-- | The total bytes that the query scanned in the event data store. This
-- value matches the number of bytes for which your account is billed for
-- the query, unless the query is still running.
queryStatistics_bytesScanned :: Lens.Lens' QueryStatistics (Prelude.Maybe Prelude.Integer)
queryStatistics_bytesScanned :: Lens' QueryStatistics (Maybe Integer)
queryStatistics_bytesScanned = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryStatistics' {Maybe Integer
bytesScanned :: Maybe Integer
$sel:bytesScanned:QueryStatistics' :: QueryStatistics -> Maybe Integer
bytesScanned} -> Maybe Integer
bytesScanned) (\s :: QueryStatistics
s@QueryStatistics' {} Maybe Integer
a -> QueryStatistics
s {$sel:bytesScanned:QueryStatistics' :: Maybe Integer
bytesScanned = Maybe Integer
a} :: QueryStatistics)

-- | The number of results returned.
queryStatistics_resultsCount :: Lens.Lens' QueryStatistics (Prelude.Maybe Prelude.Int)
queryStatistics_resultsCount :: Lens' QueryStatistics (Maybe Int)
queryStatistics_resultsCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryStatistics' {Maybe Int
resultsCount :: Maybe Int
$sel:resultsCount:QueryStatistics' :: QueryStatistics -> Maybe Int
resultsCount} -> Maybe Int
resultsCount) (\s :: QueryStatistics
s@QueryStatistics' {} Maybe Int
a -> QueryStatistics
s {$sel:resultsCount:QueryStatistics' :: Maybe Int
resultsCount = Maybe Int
a} :: QueryStatistics)

-- | The total number of results returned by a query.
queryStatistics_totalResultsCount :: Lens.Lens' QueryStatistics (Prelude.Maybe Prelude.Int)
queryStatistics_totalResultsCount :: Lens' QueryStatistics (Maybe Int)
queryStatistics_totalResultsCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryStatistics' {Maybe Int
totalResultsCount :: Maybe Int
$sel:totalResultsCount:QueryStatistics' :: QueryStatistics -> Maybe Int
totalResultsCount} -> Maybe Int
totalResultsCount) (\s :: QueryStatistics
s@QueryStatistics' {} Maybe Int
a -> QueryStatistics
s {$sel:totalResultsCount:QueryStatistics' :: Maybe Int
totalResultsCount = Maybe Int
a} :: QueryStatistics)

instance Data.FromJSON QueryStatistics where
  parseJSON :: Value -> Parser QueryStatistics
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"QueryStatistics"
      ( \Object
x ->
          Maybe Integer -> Maybe Int -> Maybe Int -> QueryStatistics
QueryStatistics'
            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
"BytesScanned")
            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
"ResultsCount")
            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
"TotalResultsCount")
      )

instance Prelude.Hashable QueryStatistics where
  hashWithSalt :: Int -> QueryStatistics -> Int
hashWithSalt Int
_salt QueryStatistics' {Maybe Int
Maybe Integer
totalResultsCount :: Maybe Int
resultsCount :: Maybe Int
bytesScanned :: Maybe Integer
$sel:totalResultsCount:QueryStatistics' :: QueryStatistics -> Maybe Int
$sel:resultsCount:QueryStatistics' :: QueryStatistics -> Maybe Int
$sel:bytesScanned:QueryStatistics' :: QueryStatistics -> Maybe Integer
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
bytesScanned
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
resultsCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
totalResultsCount

instance Prelude.NFData QueryStatistics where
  rnf :: QueryStatistics -> ()
rnf QueryStatistics' {Maybe Int
Maybe Integer
totalResultsCount :: Maybe Int
resultsCount :: Maybe Int
bytesScanned :: Maybe Integer
$sel:totalResultsCount:QueryStatistics' :: QueryStatistics -> Maybe Int
$sel:resultsCount:QueryStatistics' :: QueryStatistics -> Maybe Int
$sel:bytesScanned:QueryStatistics' :: QueryStatistics -> Maybe Integer
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
bytesScanned
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
resultsCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
totalResultsCount