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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 log events scanned during the query.
    QueryStatistics -> Maybe Double
recordsScanned :: Prelude.Maybe Prelude.Double,
    -- | 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
  }
  deriving (QueryStatistics -> QueryStatistics -> Bool
(QueryStatistics -> QueryStatistics -> Bool)
-> (QueryStatistics -> QueryStatistics -> Bool)
-> Eq QueryStatistics
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]
(Int -> ReadS QueryStatistics)
-> ReadS [QueryStatistics]
-> ReadPrec QueryStatistics
-> ReadPrec [QueryStatistics]
-> Read 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
(Int -> QueryStatistics -> ShowS)
-> (QueryStatistics -> String)
-> ([QueryStatistics] -> ShowS)
-> Show QueryStatistics
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. QueryStatistics -> Rep QueryStatistics x)
-> (forall x. Rep QueryStatistics x -> QueryStatistics)
-> Generic QueryStatistics
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:
--
-- 'recordsScanned', 'queryStatistics_recordsScanned' - The total number of log events scanned during the query.
--
-- '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.
newQueryStatistics ::
  QueryStatistics
newQueryStatistics :: QueryStatistics
newQueryStatistics =
  QueryStatistics' :: Maybe Double -> Maybe Double -> Maybe Double -> QueryStatistics
QueryStatistics'
    { $sel:recordsScanned:QueryStatistics' :: Maybe Double
recordsScanned = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:bytesScanned:QueryStatistics' :: Maybe Double
bytesScanned = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:recordsMatched:QueryStatistics' :: Maybe Double
recordsMatched = Maybe Double
forall a. Maybe a
Prelude.Nothing
    }

-- | The total number of log events scanned during the query.
queryStatistics_recordsScanned :: Lens.Lens' QueryStatistics (Prelude.Maybe Prelude.Double)
queryStatistics_recordsScanned :: (Maybe Double -> f (Maybe Double))
-> QueryStatistics -> f QueryStatistics
queryStatistics_recordsScanned = (QueryStatistics -> Maybe Double)
-> (QueryStatistics -> Maybe Double -> QueryStatistics)
-> Lens
     QueryStatistics QueryStatistics (Maybe Double) (Maybe Double)
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)

-- | The total number of bytes in the log events scanned during the query.
queryStatistics_bytesScanned :: Lens.Lens' QueryStatistics (Prelude.Maybe Prelude.Double)
queryStatistics_bytesScanned :: (Maybe Double -> f (Maybe Double))
-> QueryStatistics -> f QueryStatistics
queryStatistics_bytesScanned = (QueryStatistics -> Maybe Double)
-> (QueryStatistics -> Maybe Double -> QueryStatistics)
-> Lens
     QueryStatistics QueryStatistics (Maybe Double) (Maybe Double)
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 :: (Maybe Double -> f (Maybe Double))
-> QueryStatistics -> f QueryStatistics
queryStatistics_recordsMatched = (QueryStatistics -> Maybe Double)
-> (QueryStatistics -> Maybe Double -> QueryStatistics)
-> Lens
     QueryStatistics QueryStatistics (Maybe Double) (Maybe Double)
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)

instance Core.FromJSON QueryStatistics where
  parseJSON :: Value -> Parser QueryStatistics
parseJSON =
    String
-> (Object -> Parser QueryStatistics)
-> Value
-> Parser QueryStatistics
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"QueryStatistics"
      ( \Object
x ->
          Maybe Double -> Maybe Double -> Maybe Double -> QueryStatistics
QueryStatistics'
            (Maybe Double -> Maybe Double -> Maybe Double -> QueryStatistics)
-> Parser (Maybe Double)
-> Parser (Maybe Double -> Maybe Double -> QueryStatistics)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"recordsScanned")
            Parser (Maybe Double -> Maybe Double -> QueryStatistics)
-> Parser (Maybe Double)
-> Parser (Maybe Double -> QueryStatistics)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"bytesScanned")
            Parser (Maybe Double -> QueryStatistics)
-> Parser (Maybe Double) -> Parser QueryStatistics
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"recordsMatched")
      )

instance Prelude.Hashable QueryStatistics

instance Prelude.NFData QueryStatistics