{-# 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.SamplingStatisticsDocument
-- 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.SamplingStatisticsDocument where

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

-- | Request sampling results for a single rule from a service. Results are
-- for the last 10 seconds unless the service has been assigned a longer
-- reporting interval after a previous call to
-- <https://docs.aws.amazon.com/xray/latest/api/API_GetSamplingTargets.html GetSamplingTargets>.
--
-- /See:/ 'newSamplingStatisticsDocument' smart constructor.
data SamplingStatisticsDocument = SamplingStatisticsDocument'
  { -- | The number of requests recorded with borrowed reservoir quota.
    SamplingStatisticsDocument -> Maybe Natural
borrowCount :: Prelude.Maybe Prelude.Natural,
    -- | The name of the sampling rule.
    SamplingStatisticsDocument -> Text
ruleName :: Prelude.Text,
    -- | A unique identifier for the service in hexadecimal.
    SamplingStatisticsDocument -> Text
clientID :: Prelude.Text,
    -- | The current time.
    SamplingStatisticsDocument -> POSIX
timestamp :: Core.POSIX,
    -- | The number of requests that matched the rule.
    SamplingStatisticsDocument -> Natural
requestCount :: Prelude.Natural,
    -- | The number of requests recorded.
    SamplingStatisticsDocument -> Natural
sampledCount :: Prelude.Natural
  }
  deriving (SamplingStatisticsDocument -> SamplingStatisticsDocument -> Bool
(SamplingStatisticsDocument -> SamplingStatisticsDocument -> Bool)
-> (SamplingStatisticsDocument
    -> SamplingStatisticsDocument -> Bool)
-> Eq SamplingStatisticsDocument
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SamplingStatisticsDocument -> SamplingStatisticsDocument -> Bool
$c/= :: SamplingStatisticsDocument -> SamplingStatisticsDocument -> Bool
== :: SamplingStatisticsDocument -> SamplingStatisticsDocument -> Bool
$c== :: SamplingStatisticsDocument -> SamplingStatisticsDocument -> Bool
Prelude.Eq, ReadPrec [SamplingStatisticsDocument]
ReadPrec SamplingStatisticsDocument
Int -> ReadS SamplingStatisticsDocument
ReadS [SamplingStatisticsDocument]
(Int -> ReadS SamplingStatisticsDocument)
-> ReadS [SamplingStatisticsDocument]
-> ReadPrec SamplingStatisticsDocument
-> ReadPrec [SamplingStatisticsDocument]
-> Read SamplingStatisticsDocument
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SamplingStatisticsDocument]
$creadListPrec :: ReadPrec [SamplingStatisticsDocument]
readPrec :: ReadPrec SamplingStatisticsDocument
$creadPrec :: ReadPrec SamplingStatisticsDocument
readList :: ReadS [SamplingStatisticsDocument]
$creadList :: ReadS [SamplingStatisticsDocument]
readsPrec :: Int -> ReadS SamplingStatisticsDocument
$creadsPrec :: Int -> ReadS SamplingStatisticsDocument
Prelude.Read, Int -> SamplingStatisticsDocument -> ShowS
[SamplingStatisticsDocument] -> ShowS
SamplingStatisticsDocument -> String
(Int -> SamplingStatisticsDocument -> ShowS)
-> (SamplingStatisticsDocument -> String)
-> ([SamplingStatisticsDocument] -> ShowS)
-> Show SamplingStatisticsDocument
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SamplingStatisticsDocument] -> ShowS
$cshowList :: [SamplingStatisticsDocument] -> ShowS
show :: SamplingStatisticsDocument -> String
$cshow :: SamplingStatisticsDocument -> String
showsPrec :: Int -> SamplingStatisticsDocument -> ShowS
$cshowsPrec :: Int -> SamplingStatisticsDocument -> ShowS
Prelude.Show, (forall x.
 SamplingStatisticsDocument -> Rep SamplingStatisticsDocument x)
-> (forall x.
    Rep SamplingStatisticsDocument x -> SamplingStatisticsDocument)
-> Generic SamplingStatisticsDocument
forall x.
Rep SamplingStatisticsDocument x -> SamplingStatisticsDocument
forall x.
SamplingStatisticsDocument -> Rep SamplingStatisticsDocument x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SamplingStatisticsDocument x -> SamplingStatisticsDocument
$cfrom :: forall x.
SamplingStatisticsDocument -> Rep SamplingStatisticsDocument x
Prelude.Generic)

-- |
-- Create a value of 'SamplingStatisticsDocument' 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:
--
-- 'borrowCount', 'samplingStatisticsDocument_borrowCount' - The number of requests recorded with borrowed reservoir quota.
--
-- 'ruleName', 'samplingStatisticsDocument_ruleName' - The name of the sampling rule.
--
-- 'clientID', 'samplingStatisticsDocument_clientID' - A unique identifier for the service in hexadecimal.
--
-- 'timestamp', 'samplingStatisticsDocument_timestamp' - The current time.
--
-- 'requestCount', 'samplingStatisticsDocument_requestCount' - The number of requests that matched the rule.
--
-- 'sampledCount', 'samplingStatisticsDocument_sampledCount' - The number of requests recorded.
newSamplingStatisticsDocument ::
  -- | 'ruleName'
  Prelude.Text ->
  -- | 'clientID'
  Prelude.Text ->
  -- | 'timestamp'
  Prelude.UTCTime ->
  -- | 'requestCount'
  Prelude.Natural ->
  -- | 'sampledCount'
  Prelude.Natural ->
  SamplingStatisticsDocument
newSamplingStatisticsDocument :: Text
-> Text
-> UTCTime
-> Natural
-> Natural
-> SamplingStatisticsDocument
newSamplingStatisticsDocument
  Text
pRuleName_
  Text
pClientID_
  UTCTime
pTimestamp_
  Natural
pRequestCount_
  Natural
pSampledCount_ =
    SamplingStatisticsDocument' :: Maybe Natural
-> Text
-> Text
-> POSIX
-> Natural
-> Natural
-> SamplingStatisticsDocument
SamplingStatisticsDocument'
      { $sel:borrowCount:SamplingStatisticsDocument' :: Maybe Natural
borrowCount =
          Maybe Natural
forall a. Maybe a
Prelude.Nothing,
        $sel:ruleName:SamplingStatisticsDocument' :: Text
ruleName = Text
pRuleName_,
        $sel:clientID:SamplingStatisticsDocument' :: Text
clientID = Text
pClientID_,
        $sel:timestamp:SamplingStatisticsDocument' :: POSIX
timestamp = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pTimestamp_,
        $sel:requestCount:SamplingStatisticsDocument' :: Natural
requestCount = Natural
pRequestCount_,
        $sel:sampledCount:SamplingStatisticsDocument' :: Natural
sampledCount = Natural
pSampledCount_
      }

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

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

-- | A unique identifier for the service in hexadecimal.
samplingStatisticsDocument_clientID :: Lens.Lens' SamplingStatisticsDocument Prelude.Text
samplingStatisticsDocument_clientID :: (Text -> f Text)
-> SamplingStatisticsDocument -> f SamplingStatisticsDocument
samplingStatisticsDocument_clientID = (SamplingStatisticsDocument -> Text)
-> (SamplingStatisticsDocument
    -> Text -> SamplingStatisticsDocument)
-> Lens
     SamplingStatisticsDocument SamplingStatisticsDocument Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamplingStatisticsDocument' {Text
clientID :: Text
$sel:clientID:SamplingStatisticsDocument' :: SamplingStatisticsDocument -> Text
clientID} -> Text
clientID) (\s :: SamplingStatisticsDocument
s@SamplingStatisticsDocument' {} Text
a -> SamplingStatisticsDocument
s {$sel:clientID:SamplingStatisticsDocument' :: Text
clientID = Text
a} :: SamplingStatisticsDocument)

-- | The current time.
samplingStatisticsDocument_timestamp :: Lens.Lens' SamplingStatisticsDocument Prelude.UTCTime
samplingStatisticsDocument_timestamp :: (UTCTime -> f UTCTime)
-> SamplingStatisticsDocument -> f SamplingStatisticsDocument
samplingStatisticsDocument_timestamp = (SamplingStatisticsDocument -> POSIX)
-> (SamplingStatisticsDocument
    -> POSIX -> SamplingStatisticsDocument)
-> Lens
     SamplingStatisticsDocument SamplingStatisticsDocument POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamplingStatisticsDocument' {POSIX
timestamp :: POSIX
$sel:timestamp:SamplingStatisticsDocument' :: SamplingStatisticsDocument -> POSIX
timestamp} -> POSIX
timestamp) (\s :: SamplingStatisticsDocument
s@SamplingStatisticsDocument' {} POSIX
a -> SamplingStatisticsDocument
s {$sel:timestamp:SamplingStatisticsDocument' :: POSIX
timestamp = POSIX
a} :: SamplingStatisticsDocument) ((POSIX -> f POSIX)
 -> SamplingStatisticsDocument -> f SamplingStatisticsDocument)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> SamplingStatisticsDocument
-> f SamplingStatisticsDocument
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

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

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

instance Prelude.Hashable SamplingStatisticsDocument

instance Prelude.NFData SamplingStatisticsDocument

instance Core.ToJSON SamplingStatisticsDocument where
  toJSON :: SamplingStatisticsDocument -> Value
toJSON SamplingStatisticsDocument' {Natural
Maybe Natural
Text
POSIX
sampledCount :: Natural
requestCount :: Natural
timestamp :: POSIX
clientID :: Text
ruleName :: Text
borrowCount :: Maybe Natural
$sel:sampledCount:SamplingStatisticsDocument' :: SamplingStatisticsDocument -> Natural
$sel:requestCount:SamplingStatisticsDocument' :: SamplingStatisticsDocument -> Natural
$sel:timestamp:SamplingStatisticsDocument' :: SamplingStatisticsDocument -> POSIX
$sel:clientID:SamplingStatisticsDocument' :: SamplingStatisticsDocument -> Text
$sel:ruleName:SamplingStatisticsDocument' :: SamplingStatisticsDocument -> Text
$sel:borrowCount:SamplingStatisticsDocument' :: SamplingStatisticsDocument -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"BorrowCount" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
borrowCount,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"RuleName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
ruleName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ClientID" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
clientID),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Timestamp" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= POSIX
timestamp),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"RequestCount" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
requestCount),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"SampledCount" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
sampledCount)
          ]
      )