{-# 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.XRay.Types.SamplingStatisticSummary
-- 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.XRay.Types.SamplingStatisticSummary where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Aggregated request sampling data for a sampling rule across all services
-- for a 10-second window.
--
-- /See:/ 'newSamplingStatisticSummary' smart constructor.
data SamplingStatisticSummary = SamplingStatisticSummary'
  { -- | The number of requests that matched the rule.
    SamplingStatisticSummary -> Maybe Int
requestCount :: Prelude.Maybe Prelude.Int,
    -- | The number of requests recorded with borrowed reservoir quota.
    SamplingStatisticSummary -> Maybe Int
borrowCount :: Prelude.Maybe Prelude.Int,
    -- | The name of the sampling rule.
    SamplingStatisticSummary -> Maybe Text
ruleName :: Prelude.Maybe Prelude.Text,
    -- | The start time of the reporting window.
    SamplingStatisticSummary -> Maybe POSIX
timestamp :: Prelude.Maybe Core.POSIX,
    -- | The number of requests recorded.
    SamplingStatisticSummary -> Maybe Int
sampledCount :: Prelude.Maybe Prelude.Int
  }
  deriving (SamplingStatisticSummary -> SamplingStatisticSummary -> Bool
(SamplingStatisticSummary -> SamplingStatisticSummary -> Bool)
-> (SamplingStatisticSummary -> SamplingStatisticSummary -> Bool)
-> Eq SamplingStatisticSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SamplingStatisticSummary -> SamplingStatisticSummary -> Bool
$c/= :: SamplingStatisticSummary -> SamplingStatisticSummary -> Bool
== :: SamplingStatisticSummary -> SamplingStatisticSummary -> Bool
$c== :: SamplingStatisticSummary -> SamplingStatisticSummary -> Bool
Prelude.Eq, ReadPrec [SamplingStatisticSummary]
ReadPrec SamplingStatisticSummary
Int -> ReadS SamplingStatisticSummary
ReadS [SamplingStatisticSummary]
(Int -> ReadS SamplingStatisticSummary)
-> ReadS [SamplingStatisticSummary]
-> ReadPrec SamplingStatisticSummary
-> ReadPrec [SamplingStatisticSummary]
-> Read SamplingStatisticSummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SamplingStatisticSummary]
$creadListPrec :: ReadPrec [SamplingStatisticSummary]
readPrec :: ReadPrec SamplingStatisticSummary
$creadPrec :: ReadPrec SamplingStatisticSummary
readList :: ReadS [SamplingStatisticSummary]
$creadList :: ReadS [SamplingStatisticSummary]
readsPrec :: Int -> ReadS SamplingStatisticSummary
$creadsPrec :: Int -> ReadS SamplingStatisticSummary
Prelude.Read, Int -> SamplingStatisticSummary -> ShowS
[SamplingStatisticSummary] -> ShowS
SamplingStatisticSummary -> String
(Int -> SamplingStatisticSummary -> ShowS)
-> (SamplingStatisticSummary -> String)
-> ([SamplingStatisticSummary] -> ShowS)
-> Show SamplingStatisticSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SamplingStatisticSummary] -> ShowS
$cshowList :: [SamplingStatisticSummary] -> ShowS
show :: SamplingStatisticSummary -> String
$cshow :: SamplingStatisticSummary -> String
showsPrec :: Int -> SamplingStatisticSummary -> ShowS
$cshowsPrec :: Int -> SamplingStatisticSummary -> ShowS
Prelude.Show, (forall x.
 SamplingStatisticSummary -> Rep SamplingStatisticSummary x)
-> (forall x.
    Rep SamplingStatisticSummary x -> SamplingStatisticSummary)
-> Generic SamplingStatisticSummary
forall x.
Rep SamplingStatisticSummary x -> SamplingStatisticSummary
forall x.
SamplingStatisticSummary -> Rep SamplingStatisticSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SamplingStatisticSummary x -> SamplingStatisticSummary
$cfrom :: forall x.
SamplingStatisticSummary -> Rep SamplingStatisticSummary x
Prelude.Generic)

-- |
-- Create a value of 'SamplingStatisticSummary' 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:
--
-- 'requestCount', 'samplingStatisticSummary_requestCount' - The number of requests that matched the rule.
--
-- 'borrowCount', 'samplingStatisticSummary_borrowCount' - The number of requests recorded with borrowed reservoir quota.
--
-- 'ruleName', 'samplingStatisticSummary_ruleName' - The name of the sampling rule.
--
-- 'timestamp', 'samplingStatisticSummary_timestamp' - The start time of the reporting window.
--
-- 'sampledCount', 'samplingStatisticSummary_sampledCount' - The number of requests recorded.
newSamplingStatisticSummary ::
  SamplingStatisticSummary
newSamplingStatisticSummary :: SamplingStatisticSummary
newSamplingStatisticSummary =
  SamplingStatisticSummary' :: Maybe Int
-> Maybe Int
-> Maybe Text
-> Maybe POSIX
-> Maybe Int
-> SamplingStatisticSummary
SamplingStatisticSummary'
    { $sel:requestCount:SamplingStatisticSummary' :: Maybe Int
requestCount =
        Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:borrowCount:SamplingStatisticSummary' :: Maybe Int
borrowCount = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:ruleName:SamplingStatisticSummary' :: Maybe Text
ruleName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:timestamp:SamplingStatisticSummary' :: Maybe POSIX
timestamp = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:sampledCount:SamplingStatisticSummary' :: Maybe Int
sampledCount = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The number of requests that matched the rule.
samplingStatisticSummary_requestCount :: Lens.Lens' SamplingStatisticSummary (Prelude.Maybe Prelude.Int)
samplingStatisticSummary_requestCount :: (Maybe Int -> f (Maybe Int))
-> SamplingStatisticSummary -> f SamplingStatisticSummary
samplingStatisticSummary_requestCount = (SamplingStatisticSummary -> Maybe Int)
-> (SamplingStatisticSummary
    -> Maybe Int -> SamplingStatisticSummary)
-> Lens
     SamplingStatisticSummary
     SamplingStatisticSummary
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamplingStatisticSummary' {Maybe Int
requestCount :: Maybe Int
$sel:requestCount:SamplingStatisticSummary' :: SamplingStatisticSummary -> Maybe Int
requestCount} -> Maybe Int
requestCount) (\s :: SamplingStatisticSummary
s@SamplingStatisticSummary' {} Maybe Int
a -> SamplingStatisticSummary
s {$sel:requestCount:SamplingStatisticSummary' :: Maybe Int
requestCount = Maybe Int
a} :: SamplingStatisticSummary)

-- | The number of requests recorded with borrowed reservoir quota.
samplingStatisticSummary_borrowCount :: Lens.Lens' SamplingStatisticSummary (Prelude.Maybe Prelude.Int)
samplingStatisticSummary_borrowCount :: (Maybe Int -> f (Maybe Int))
-> SamplingStatisticSummary -> f SamplingStatisticSummary
samplingStatisticSummary_borrowCount = (SamplingStatisticSummary -> Maybe Int)
-> (SamplingStatisticSummary
    -> Maybe Int -> SamplingStatisticSummary)
-> Lens
     SamplingStatisticSummary
     SamplingStatisticSummary
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamplingStatisticSummary' {Maybe Int
borrowCount :: Maybe Int
$sel:borrowCount:SamplingStatisticSummary' :: SamplingStatisticSummary -> Maybe Int
borrowCount} -> Maybe Int
borrowCount) (\s :: SamplingStatisticSummary
s@SamplingStatisticSummary' {} Maybe Int
a -> SamplingStatisticSummary
s {$sel:borrowCount:SamplingStatisticSummary' :: Maybe Int
borrowCount = Maybe Int
a} :: SamplingStatisticSummary)

-- | The name of the sampling rule.
samplingStatisticSummary_ruleName :: Lens.Lens' SamplingStatisticSummary (Prelude.Maybe Prelude.Text)
samplingStatisticSummary_ruleName :: (Maybe Text -> f (Maybe Text))
-> SamplingStatisticSummary -> f SamplingStatisticSummary
samplingStatisticSummary_ruleName = (SamplingStatisticSummary -> Maybe Text)
-> (SamplingStatisticSummary
    -> Maybe Text -> SamplingStatisticSummary)
-> Lens
     SamplingStatisticSummary
     SamplingStatisticSummary
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamplingStatisticSummary' {Maybe Text
ruleName :: Maybe Text
$sel:ruleName:SamplingStatisticSummary' :: SamplingStatisticSummary -> Maybe Text
ruleName} -> Maybe Text
ruleName) (\s :: SamplingStatisticSummary
s@SamplingStatisticSummary' {} Maybe Text
a -> SamplingStatisticSummary
s {$sel:ruleName:SamplingStatisticSummary' :: Maybe Text
ruleName = Maybe Text
a} :: SamplingStatisticSummary)

-- | The start time of the reporting window.
samplingStatisticSummary_timestamp :: Lens.Lens' SamplingStatisticSummary (Prelude.Maybe Prelude.UTCTime)
samplingStatisticSummary_timestamp :: (Maybe UTCTime -> f (Maybe UTCTime))
-> SamplingStatisticSummary -> f SamplingStatisticSummary
samplingStatisticSummary_timestamp = (SamplingStatisticSummary -> Maybe POSIX)
-> (SamplingStatisticSummary
    -> Maybe POSIX -> SamplingStatisticSummary)
-> Lens
     SamplingStatisticSummary
     SamplingStatisticSummary
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamplingStatisticSummary' {Maybe POSIX
timestamp :: Maybe POSIX
$sel:timestamp:SamplingStatisticSummary' :: SamplingStatisticSummary -> Maybe POSIX
timestamp} -> Maybe POSIX
timestamp) (\s :: SamplingStatisticSummary
s@SamplingStatisticSummary' {} Maybe POSIX
a -> SamplingStatisticSummary
s {$sel:timestamp:SamplingStatisticSummary' :: Maybe POSIX
timestamp = Maybe POSIX
a} :: SamplingStatisticSummary) ((Maybe POSIX -> f (Maybe POSIX))
 -> SamplingStatisticSummary -> f SamplingStatisticSummary)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> SamplingStatisticSummary
-> f SamplingStatisticSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The number of requests recorded.
samplingStatisticSummary_sampledCount :: Lens.Lens' SamplingStatisticSummary (Prelude.Maybe Prelude.Int)
samplingStatisticSummary_sampledCount :: (Maybe Int -> f (Maybe Int))
-> SamplingStatisticSummary -> f SamplingStatisticSummary
samplingStatisticSummary_sampledCount = (SamplingStatisticSummary -> Maybe Int)
-> (SamplingStatisticSummary
    -> Maybe Int -> SamplingStatisticSummary)
-> Lens
     SamplingStatisticSummary
     SamplingStatisticSummary
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamplingStatisticSummary' {Maybe Int
sampledCount :: Maybe Int
$sel:sampledCount:SamplingStatisticSummary' :: SamplingStatisticSummary -> Maybe Int
sampledCount} -> Maybe Int
sampledCount) (\s :: SamplingStatisticSummary
s@SamplingStatisticSummary' {} Maybe Int
a -> SamplingStatisticSummary
s {$sel:sampledCount:SamplingStatisticSummary' :: Maybe Int
sampledCount = Maybe Int
a} :: SamplingStatisticSummary)

instance Core.FromJSON SamplingStatisticSummary where
  parseJSON :: Value -> Parser SamplingStatisticSummary
parseJSON =
    String
-> (Object -> Parser SamplingStatisticSummary)
-> Value
-> Parser SamplingStatisticSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SamplingStatisticSummary"
      ( \Object
x ->
          Maybe Int
-> Maybe Int
-> Maybe Text
-> Maybe POSIX
-> Maybe Int
-> SamplingStatisticSummary
SamplingStatisticSummary'
            (Maybe Int
 -> Maybe Int
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe Int
 -> SamplingStatisticSummary)
-> Parser (Maybe Int)
-> Parser
     (Maybe Int
      -> Maybe Text
      -> Maybe POSIX
      -> Maybe Int
      -> SamplingStatisticSummary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RequestCount")
            Parser
  (Maybe Int
   -> Maybe Text
   -> Maybe POSIX
   -> Maybe Int
   -> SamplingStatisticSummary)
-> Parser (Maybe Int)
-> Parser
     (Maybe Text
      -> Maybe POSIX -> Maybe Int -> SamplingStatisticSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"BorrowCount")
            Parser
  (Maybe Text
   -> Maybe POSIX -> Maybe Int -> SamplingStatisticSummary)
-> Parser (Maybe Text)
-> Parser (Maybe POSIX -> Maybe Int -> SamplingStatisticSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RuleName")
            Parser (Maybe POSIX -> Maybe Int -> SamplingStatisticSummary)
-> Parser (Maybe POSIX)
-> Parser (Maybe Int -> SamplingStatisticSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Timestamp")
            Parser (Maybe Int -> SamplingStatisticSummary)
-> Parser (Maybe Int) -> Parser SamplingStatisticSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SampledCount")
      )

instance Prelude.Hashable SamplingStatisticSummary

instance Prelude.NFData SamplingStatisticSummary