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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.XRay.Types.BackendConnectionErrors

-- |
--
-- /See:/ 'newTelemetryRecord' smart constructor.
data TelemetryRecord = TelemetryRecord'
  { TelemetryRecord -> Maybe Int
segmentsReceivedCount :: Prelude.Maybe Prelude.Int,
    TelemetryRecord -> Maybe Int
segmentsSentCount :: Prelude.Maybe Prelude.Int,
    TelemetryRecord -> Maybe Int
segmentsSpilloverCount :: Prelude.Maybe Prelude.Int,
    TelemetryRecord -> Maybe Int
segmentsRejectedCount :: Prelude.Maybe Prelude.Int,
    TelemetryRecord -> Maybe BackendConnectionErrors
backendConnectionErrors :: Prelude.Maybe BackendConnectionErrors,
    TelemetryRecord -> POSIX
timestamp :: Core.POSIX
  }
  deriving (TelemetryRecord -> TelemetryRecord -> Bool
(TelemetryRecord -> TelemetryRecord -> Bool)
-> (TelemetryRecord -> TelemetryRecord -> Bool)
-> Eq TelemetryRecord
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TelemetryRecord -> TelemetryRecord -> Bool
$c/= :: TelemetryRecord -> TelemetryRecord -> Bool
== :: TelemetryRecord -> TelemetryRecord -> Bool
$c== :: TelemetryRecord -> TelemetryRecord -> Bool
Prelude.Eq, ReadPrec [TelemetryRecord]
ReadPrec TelemetryRecord
Int -> ReadS TelemetryRecord
ReadS [TelemetryRecord]
(Int -> ReadS TelemetryRecord)
-> ReadS [TelemetryRecord]
-> ReadPrec TelemetryRecord
-> ReadPrec [TelemetryRecord]
-> Read TelemetryRecord
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TelemetryRecord]
$creadListPrec :: ReadPrec [TelemetryRecord]
readPrec :: ReadPrec TelemetryRecord
$creadPrec :: ReadPrec TelemetryRecord
readList :: ReadS [TelemetryRecord]
$creadList :: ReadS [TelemetryRecord]
readsPrec :: Int -> ReadS TelemetryRecord
$creadsPrec :: Int -> ReadS TelemetryRecord
Prelude.Read, Int -> TelemetryRecord -> ShowS
[TelemetryRecord] -> ShowS
TelemetryRecord -> String
(Int -> TelemetryRecord -> ShowS)
-> (TelemetryRecord -> String)
-> ([TelemetryRecord] -> ShowS)
-> Show TelemetryRecord
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TelemetryRecord] -> ShowS
$cshowList :: [TelemetryRecord] -> ShowS
show :: TelemetryRecord -> String
$cshow :: TelemetryRecord -> String
showsPrec :: Int -> TelemetryRecord -> ShowS
$cshowsPrec :: Int -> TelemetryRecord -> ShowS
Prelude.Show, (forall x. TelemetryRecord -> Rep TelemetryRecord x)
-> (forall x. Rep TelemetryRecord x -> TelemetryRecord)
-> Generic TelemetryRecord
forall x. Rep TelemetryRecord x -> TelemetryRecord
forall x. TelemetryRecord -> Rep TelemetryRecord x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TelemetryRecord x -> TelemetryRecord
$cfrom :: forall x. TelemetryRecord -> Rep TelemetryRecord x
Prelude.Generic)

-- |
-- Create a value of 'TelemetryRecord' 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:
--
-- 'segmentsReceivedCount', 'telemetryRecord_segmentsReceivedCount' -
--
-- 'segmentsSentCount', 'telemetryRecord_segmentsSentCount' -
--
-- 'segmentsSpilloverCount', 'telemetryRecord_segmentsSpilloverCount' -
--
-- 'segmentsRejectedCount', 'telemetryRecord_segmentsRejectedCount' -
--
-- 'backendConnectionErrors', 'telemetryRecord_backendConnectionErrors' -
--
-- 'timestamp', 'telemetryRecord_timestamp' -
newTelemetryRecord ::
  -- | 'timestamp'
  Prelude.UTCTime ->
  TelemetryRecord
newTelemetryRecord :: UTCTime -> TelemetryRecord
newTelemetryRecord UTCTime
pTimestamp_ =
  TelemetryRecord' :: Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe BackendConnectionErrors
-> POSIX
-> TelemetryRecord
TelemetryRecord'
    { $sel:segmentsReceivedCount:TelemetryRecord' :: Maybe Int
segmentsReceivedCount =
        Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:segmentsSentCount:TelemetryRecord' :: Maybe Int
segmentsSentCount = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:segmentsSpilloverCount:TelemetryRecord' :: Maybe Int
segmentsSpilloverCount = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:segmentsRejectedCount:TelemetryRecord' :: Maybe Int
segmentsRejectedCount = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:backendConnectionErrors:TelemetryRecord' :: Maybe BackendConnectionErrors
backendConnectionErrors = Maybe BackendConnectionErrors
forall a. Maybe a
Prelude.Nothing,
      $sel:timestamp:TelemetryRecord' :: 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_
    }

-- |
telemetryRecord_segmentsReceivedCount :: Lens.Lens' TelemetryRecord (Prelude.Maybe Prelude.Int)
telemetryRecord_segmentsReceivedCount :: (Maybe Int -> f (Maybe Int))
-> TelemetryRecord -> f TelemetryRecord
telemetryRecord_segmentsReceivedCount = (TelemetryRecord -> Maybe Int)
-> (TelemetryRecord -> Maybe Int -> TelemetryRecord)
-> Lens TelemetryRecord TelemetryRecord (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TelemetryRecord' {Maybe Int
segmentsReceivedCount :: Maybe Int
$sel:segmentsReceivedCount:TelemetryRecord' :: TelemetryRecord -> Maybe Int
segmentsReceivedCount} -> Maybe Int
segmentsReceivedCount) (\s :: TelemetryRecord
s@TelemetryRecord' {} Maybe Int
a -> TelemetryRecord
s {$sel:segmentsReceivedCount:TelemetryRecord' :: Maybe Int
segmentsReceivedCount = Maybe Int
a} :: TelemetryRecord)

-- |
telemetryRecord_segmentsSentCount :: Lens.Lens' TelemetryRecord (Prelude.Maybe Prelude.Int)
telemetryRecord_segmentsSentCount :: (Maybe Int -> f (Maybe Int))
-> TelemetryRecord -> f TelemetryRecord
telemetryRecord_segmentsSentCount = (TelemetryRecord -> Maybe Int)
-> (TelemetryRecord -> Maybe Int -> TelemetryRecord)
-> Lens TelemetryRecord TelemetryRecord (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TelemetryRecord' {Maybe Int
segmentsSentCount :: Maybe Int
$sel:segmentsSentCount:TelemetryRecord' :: TelemetryRecord -> Maybe Int
segmentsSentCount} -> Maybe Int
segmentsSentCount) (\s :: TelemetryRecord
s@TelemetryRecord' {} Maybe Int
a -> TelemetryRecord
s {$sel:segmentsSentCount:TelemetryRecord' :: Maybe Int
segmentsSentCount = Maybe Int
a} :: TelemetryRecord)

-- |
telemetryRecord_segmentsSpilloverCount :: Lens.Lens' TelemetryRecord (Prelude.Maybe Prelude.Int)
telemetryRecord_segmentsSpilloverCount :: (Maybe Int -> f (Maybe Int))
-> TelemetryRecord -> f TelemetryRecord
telemetryRecord_segmentsSpilloverCount = (TelemetryRecord -> Maybe Int)
-> (TelemetryRecord -> Maybe Int -> TelemetryRecord)
-> Lens TelemetryRecord TelemetryRecord (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TelemetryRecord' {Maybe Int
segmentsSpilloverCount :: Maybe Int
$sel:segmentsSpilloverCount:TelemetryRecord' :: TelemetryRecord -> Maybe Int
segmentsSpilloverCount} -> Maybe Int
segmentsSpilloverCount) (\s :: TelemetryRecord
s@TelemetryRecord' {} Maybe Int
a -> TelemetryRecord
s {$sel:segmentsSpilloverCount:TelemetryRecord' :: Maybe Int
segmentsSpilloverCount = Maybe Int
a} :: TelemetryRecord)

-- |
telemetryRecord_segmentsRejectedCount :: Lens.Lens' TelemetryRecord (Prelude.Maybe Prelude.Int)
telemetryRecord_segmentsRejectedCount :: (Maybe Int -> f (Maybe Int))
-> TelemetryRecord -> f TelemetryRecord
telemetryRecord_segmentsRejectedCount = (TelemetryRecord -> Maybe Int)
-> (TelemetryRecord -> Maybe Int -> TelemetryRecord)
-> Lens TelemetryRecord TelemetryRecord (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TelemetryRecord' {Maybe Int
segmentsRejectedCount :: Maybe Int
$sel:segmentsRejectedCount:TelemetryRecord' :: TelemetryRecord -> Maybe Int
segmentsRejectedCount} -> Maybe Int
segmentsRejectedCount) (\s :: TelemetryRecord
s@TelemetryRecord' {} Maybe Int
a -> TelemetryRecord
s {$sel:segmentsRejectedCount:TelemetryRecord' :: Maybe Int
segmentsRejectedCount = Maybe Int
a} :: TelemetryRecord)

-- |
telemetryRecord_backendConnectionErrors :: Lens.Lens' TelemetryRecord (Prelude.Maybe BackendConnectionErrors)
telemetryRecord_backendConnectionErrors :: (Maybe BackendConnectionErrors
 -> f (Maybe BackendConnectionErrors))
-> TelemetryRecord -> f TelemetryRecord
telemetryRecord_backendConnectionErrors = (TelemetryRecord -> Maybe BackendConnectionErrors)
-> (TelemetryRecord
    -> Maybe BackendConnectionErrors -> TelemetryRecord)
-> Lens
     TelemetryRecord
     TelemetryRecord
     (Maybe BackendConnectionErrors)
     (Maybe BackendConnectionErrors)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TelemetryRecord' {Maybe BackendConnectionErrors
backendConnectionErrors :: Maybe BackendConnectionErrors
$sel:backendConnectionErrors:TelemetryRecord' :: TelemetryRecord -> Maybe BackendConnectionErrors
backendConnectionErrors} -> Maybe BackendConnectionErrors
backendConnectionErrors) (\s :: TelemetryRecord
s@TelemetryRecord' {} Maybe BackendConnectionErrors
a -> TelemetryRecord
s {$sel:backendConnectionErrors:TelemetryRecord' :: Maybe BackendConnectionErrors
backendConnectionErrors = Maybe BackendConnectionErrors
a} :: TelemetryRecord)

-- |
telemetryRecord_timestamp :: Lens.Lens' TelemetryRecord Prelude.UTCTime
telemetryRecord_timestamp :: (UTCTime -> f UTCTime) -> TelemetryRecord -> f TelemetryRecord
telemetryRecord_timestamp = (TelemetryRecord -> POSIX)
-> (TelemetryRecord -> POSIX -> TelemetryRecord)
-> Lens TelemetryRecord TelemetryRecord POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TelemetryRecord' {POSIX
timestamp :: POSIX
$sel:timestamp:TelemetryRecord' :: TelemetryRecord -> POSIX
timestamp} -> POSIX
timestamp) (\s :: TelemetryRecord
s@TelemetryRecord' {} POSIX
a -> TelemetryRecord
s {$sel:timestamp:TelemetryRecord' :: POSIX
timestamp = POSIX
a} :: TelemetryRecord) ((POSIX -> f POSIX) -> TelemetryRecord -> f TelemetryRecord)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> TelemetryRecord
-> f TelemetryRecord
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

instance Prelude.Hashable TelemetryRecord

instance Prelude.NFData TelemetryRecord

instance Core.ToJSON TelemetryRecord where
  toJSON :: TelemetryRecord -> Value
toJSON TelemetryRecord' {Maybe Int
Maybe BackendConnectionErrors
POSIX
timestamp :: POSIX
backendConnectionErrors :: Maybe BackendConnectionErrors
segmentsRejectedCount :: Maybe Int
segmentsSpilloverCount :: Maybe Int
segmentsSentCount :: Maybe Int
segmentsReceivedCount :: Maybe Int
$sel:timestamp:TelemetryRecord' :: TelemetryRecord -> POSIX
$sel:backendConnectionErrors:TelemetryRecord' :: TelemetryRecord -> Maybe BackendConnectionErrors
$sel:segmentsRejectedCount:TelemetryRecord' :: TelemetryRecord -> Maybe Int
$sel:segmentsSpilloverCount:TelemetryRecord' :: TelemetryRecord -> Maybe Int
$sel:segmentsSentCount:TelemetryRecord' :: TelemetryRecord -> Maybe Int
$sel:segmentsReceivedCount:TelemetryRecord' :: TelemetryRecord -> Maybe Int
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"SegmentsReceivedCount" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
segmentsReceivedCount,
            (Text
"SegmentsSentCount" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
segmentsSentCount,
            (Text
"SegmentsSpilloverCount" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
segmentsSpilloverCount,
            (Text
"SegmentsRejectedCount" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
segmentsRejectedCount,
            (Text
"BackendConnectionErrors" Text -> BackendConnectionErrors -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (BackendConnectionErrors -> Pair)
-> Maybe BackendConnectionErrors -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe BackendConnectionErrors
backendConnectionErrors,
            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)
          ]
      )