{-# 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.CloudWatchLogs.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.CloudWatchLogs.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

-- | Contains the number of log events scanned by the query, the number of
-- log events that matched the query criteria, and the total number of
-- bytes in the log events that were scanned.
--
-- /See:/ 'newQueryStatistics' smart constructor.
data QueryStatistics = QueryStatistics'
  { -- | The total number of bytes in the log events scanned during the query.
    QueryStatistics -> Maybe Double
bytesScanned :: Prelude.Maybe Prelude.Double,
    -- | The number of log events that matched the query string.
    QueryStatistics -> Maybe Double
recordsMatched :: Prelude.Maybe Prelude.Double,
    -- | The total number of log events scanned during the query.
    QueryStatistics -> Maybe Double
recordsScanned :: Prelude.Maybe Prelude.Double
  }
  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 number of bytes in the log events scanned during the query.
--
-- 'recordsMatched', 'queryStatistics_recordsMatched' - The number of log events that matched the query string.
--
-- 'recordsScanned', 'queryStatistics_recordsScanned' - The total number of log events scanned during the query.
newQueryStatistics ::
  QueryStatistics
newQueryStatistics :: QueryStatistics
newQueryStatistics =
  QueryStatistics'
    { $sel:bytesScanned:QueryStatistics' :: Maybe Double
bytesScanned = forall a. Maybe a
Prelude.Nothing,
      $sel:recordsMatched:QueryStatistics' :: Maybe Double
recordsMatched = forall a. Maybe a
Prelude.Nothing,
      $sel:recordsScanned:QueryStatistics' :: Maybe Double
recordsScanned = forall a. Maybe a
Prelude.Nothing
    }

-- | The total number of bytes in the log events scanned during the query.
queryStatistics_bytesScanned :: Lens.Lens' QueryStatistics (Prelude.Maybe Prelude.Double)
queryStatistics_bytesScanned :: Lens' QueryStatistics (Maybe Double)
queryStatistics_bytesScanned = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryStatistics' {Maybe Double
bytesScanned :: Maybe Double
$sel:bytesScanned:QueryStatistics' :: QueryStatistics -> Maybe Double
bytesScanned} -> Maybe Double
bytesScanned) (\s :: QueryStatistics
s@QueryStatistics' {} Maybe Double
a -> QueryStatistics
s {$sel:bytesScanned:QueryStatistics' :: Maybe Double
bytesScanned = Maybe Double
a} :: QueryStatistics)

-- | The number of log events that matched the query string.
queryStatistics_recordsMatched :: Lens.Lens' QueryStatistics (Prelude.Maybe Prelude.Double)
queryStatistics_recordsMatched :: Lens' QueryStatistics (Maybe Double)
queryStatistics_recordsMatched = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryStatistics' {Maybe Double
recordsMatched :: Maybe Double
$sel:recordsMatched:QueryStatistics' :: QueryStatistics -> Maybe Double
recordsMatched} -> Maybe Double
recordsMatched) (\s :: QueryStatistics
s@QueryStatistics' {} Maybe Double
a -> QueryStatistics
s {$sel:recordsMatched:QueryStatistics' :: Maybe Double
recordsMatched = Maybe Double
a} :: QueryStatistics)

-- | The total number of log events scanned during the query.
queryStatistics_recordsScanned :: Lens.Lens' QueryStatistics (Prelude.Maybe Prelude.Double)
queryStatistics_recordsScanned :: Lens' QueryStatistics (Maybe Double)
queryStatistics_recordsScanned = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryStatistics' {Maybe Double
recordsScanned :: Maybe Double
$sel:recordsScanned:QueryStatistics' :: QueryStatistics -> Maybe Double
recordsScanned} -> Maybe Double
recordsScanned) (\s :: QueryStatistics
s@QueryStatistics' {} Maybe Double
a -> QueryStatistics
s {$sel:recordsScanned:QueryStatistics' :: Maybe Double
recordsScanned = Maybe Double
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 Double -> Maybe Double -> Maybe Double -> 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
"recordsMatched")
            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
"recordsScanned")
      )

instance Prelude.Hashable QueryStatistics where
  hashWithSalt :: Int -> QueryStatistics -> Int
hashWithSalt Int
_salt QueryStatistics' {Maybe Double
recordsScanned :: Maybe Double
recordsMatched :: Maybe Double
bytesScanned :: Maybe Double
$sel:recordsScanned:QueryStatistics' :: QueryStatistics -> Maybe Double
$sel:recordsMatched:QueryStatistics' :: QueryStatistics -> Maybe Double
$sel:bytesScanned:QueryStatistics' :: QueryStatistics -> Maybe Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
bytesScanned
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
recordsMatched
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
recordsScanned

instance Prelude.NFData QueryStatistics where
  rnf :: QueryStatistics -> ()
rnf QueryStatistics' {Maybe Double
recordsScanned :: Maybe Double
recordsMatched :: Maybe Double
bytesScanned :: Maybe Double
$sel:recordsScanned:QueryStatistics' :: QueryStatistics -> Maybe Double
$sel:recordsMatched:QueryStatistics' :: QueryStatistics -> Maybe Double
$sel:bytesScanned:QueryStatistics' :: QueryStatistics -> Maybe Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
bytesScanned
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
recordsMatched
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
recordsScanned