{-# 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.EdgeStatistics
-- 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.XRay.Types.EdgeStatistics 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
import Amazonka.XRay.Types.ErrorStatistics
import Amazonka.XRay.Types.FaultStatistics

-- | Response statistics for an edge.
--
-- /See:/ 'newEdgeStatistics' smart constructor.
data EdgeStatistics = EdgeStatistics'
  { -- | Information about requests that failed with a 4xx Client Error status
    -- code.
    EdgeStatistics -> Maybe ErrorStatistics
errorStatistics :: Prelude.Maybe ErrorStatistics,
    -- | Information about requests that failed with a 5xx Server Error status
    -- code.
    EdgeStatistics -> Maybe FaultStatistics
faultStatistics :: Prelude.Maybe FaultStatistics,
    -- | The number of requests that completed with a 2xx Success status code.
    EdgeStatistics -> Maybe Integer
okCount :: Prelude.Maybe Prelude.Integer,
    -- | The total number of completed requests.
    EdgeStatistics -> Maybe Integer
totalCount :: Prelude.Maybe Prelude.Integer,
    -- | The aggregate response time of completed requests.
    EdgeStatistics -> Maybe Double
totalResponseTime :: Prelude.Maybe Prelude.Double
  }
  deriving (EdgeStatistics -> EdgeStatistics -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EdgeStatistics -> EdgeStatistics -> Bool
$c/= :: EdgeStatistics -> EdgeStatistics -> Bool
== :: EdgeStatistics -> EdgeStatistics -> Bool
$c== :: EdgeStatistics -> EdgeStatistics -> Bool
Prelude.Eq, ReadPrec [EdgeStatistics]
ReadPrec EdgeStatistics
Int -> ReadS EdgeStatistics
ReadS [EdgeStatistics]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EdgeStatistics]
$creadListPrec :: ReadPrec [EdgeStatistics]
readPrec :: ReadPrec EdgeStatistics
$creadPrec :: ReadPrec EdgeStatistics
readList :: ReadS [EdgeStatistics]
$creadList :: ReadS [EdgeStatistics]
readsPrec :: Int -> ReadS EdgeStatistics
$creadsPrec :: Int -> ReadS EdgeStatistics
Prelude.Read, Int -> EdgeStatistics -> ShowS
[EdgeStatistics] -> ShowS
EdgeStatistics -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EdgeStatistics] -> ShowS
$cshowList :: [EdgeStatistics] -> ShowS
show :: EdgeStatistics -> String
$cshow :: EdgeStatistics -> String
showsPrec :: Int -> EdgeStatistics -> ShowS
$cshowsPrec :: Int -> EdgeStatistics -> ShowS
Prelude.Show, forall x. Rep EdgeStatistics x -> EdgeStatistics
forall x. EdgeStatistics -> Rep EdgeStatistics x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EdgeStatistics x -> EdgeStatistics
$cfrom :: forall x. EdgeStatistics -> Rep EdgeStatistics x
Prelude.Generic)

-- |
-- Create a value of 'EdgeStatistics' 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:
--
-- 'errorStatistics', 'edgeStatistics_errorStatistics' - Information about requests that failed with a 4xx Client Error status
-- code.
--
-- 'faultStatistics', 'edgeStatistics_faultStatistics' - Information about requests that failed with a 5xx Server Error status
-- code.
--
-- 'okCount', 'edgeStatistics_okCount' - The number of requests that completed with a 2xx Success status code.
--
-- 'totalCount', 'edgeStatistics_totalCount' - The total number of completed requests.
--
-- 'totalResponseTime', 'edgeStatistics_totalResponseTime' - The aggregate response time of completed requests.
newEdgeStatistics ::
  EdgeStatistics
newEdgeStatistics :: EdgeStatistics
newEdgeStatistics =
  EdgeStatistics'
    { $sel:errorStatistics:EdgeStatistics' :: Maybe ErrorStatistics
errorStatistics = forall a. Maybe a
Prelude.Nothing,
      $sel:faultStatistics:EdgeStatistics' :: Maybe FaultStatistics
faultStatistics = forall a. Maybe a
Prelude.Nothing,
      $sel:okCount:EdgeStatistics' :: Maybe Integer
okCount = forall a. Maybe a
Prelude.Nothing,
      $sel:totalCount:EdgeStatistics' :: Maybe Integer
totalCount = forall a. Maybe a
Prelude.Nothing,
      $sel:totalResponseTime:EdgeStatistics' :: Maybe Double
totalResponseTime = forall a. Maybe a
Prelude.Nothing
    }

-- | Information about requests that failed with a 4xx Client Error status
-- code.
edgeStatistics_errorStatistics :: Lens.Lens' EdgeStatistics (Prelude.Maybe ErrorStatistics)
edgeStatistics_errorStatistics :: Lens' EdgeStatistics (Maybe ErrorStatistics)
edgeStatistics_errorStatistics = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EdgeStatistics' {Maybe ErrorStatistics
errorStatistics :: Maybe ErrorStatistics
$sel:errorStatistics:EdgeStatistics' :: EdgeStatistics -> Maybe ErrorStatistics
errorStatistics} -> Maybe ErrorStatistics
errorStatistics) (\s :: EdgeStatistics
s@EdgeStatistics' {} Maybe ErrorStatistics
a -> EdgeStatistics
s {$sel:errorStatistics:EdgeStatistics' :: Maybe ErrorStatistics
errorStatistics = Maybe ErrorStatistics
a} :: EdgeStatistics)

-- | Information about requests that failed with a 5xx Server Error status
-- code.
edgeStatistics_faultStatistics :: Lens.Lens' EdgeStatistics (Prelude.Maybe FaultStatistics)
edgeStatistics_faultStatistics :: Lens' EdgeStatistics (Maybe FaultStatistics)
edgeStatistics_faultStatistics = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EdgeStatistics' {Maybe FaultStatistics
faultStatistics :: Maybe FaultStatistics
$sel:faultStatistics:EdgeStatistics' :: EdgeStatistics -> Maybe FaultStatistics
faultStatistics} -> Maybe FaultStatistics
faultStatistics) (\s :: EdgeStatistics
s@EdgeStatistics' {} Maybe FaultStatistics
a -> EdgeStatistics
s {$sel:faultStatistics:EdgeStatistics' :: Maybe FaultStatistics
faultStatistics = Maybe FaultStatistics
a} :: EdgeStatistics)

-- | The number of requests that completed with a 2xx Success status code.
edgeStatistics_okCount :: Lens.Lens' EdgeStatistics (Prelude.Maybe Prelude.Integer)
edgeStatistics_okCount :: Lens' EdgeStatistics (Maybe Integer)
edgeStatistics_okCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EdgeStatistics' {Maybe Integer
okCount :: Maybe Integer
$sel:okCount:EdgeStatistics' :: EdgeStatistics -> Maybe Integer
okCount} -> Maybe Integer
okCount) (\s :: EdgeStatistics
s@EdgeStatistics' {} Maybe Integer
a -> EdgeStatistics
s {$sel:okCount:EdgeStatistics' :: Maybe Integer
okCount = Maybe Integer
a} :: EdgeStatistics)

-- | The total number of completed requests.
edgeStatistics_totalCount :: Lens.Lens' EdgeStatistics (Prelude.Maybe Prelude.Integer)
edgeStatistics_totalCount :: Lens' EdgeStatistics (Maybe Integer)
edgeStatistics_totalCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EdgeStatistics' {Maybe Integer
totalCount :: Maybe Integer
$sel:totalCount:EdgeStatistics' :: EdgeStatistics -> Maybe Integer
totalCount} -> Maybe Integer
totalCount) (\s :: EdgeStatistics
s@EdgeStatistics' {} Maybe Integer
a -> EdgeStatistics
s {$sel:totalCount:EdgeStatistics' :: Maybe Integer
totalCount = Maybe Integer
a} :: EdgeStatistics)

-- | The aggregate response time of completed requests.
edgeStatistics_totalResponseTime :: Lens.Lens' EdgeStatistics (Prelude.Maybe Prelude.Double)
edgeStatistics_totalResponseTime :: Lens' EdgeStatistics (Maybe Double)
edgeStatistics_totalResponseTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EdgeStatistics' {Maybe Double
totalResponseTime :: Maybe Double
$sel:totalResponseTime:EdgeStatistics' :: EdgeStatistics -> Maybe Double
totalResponseTime} -> Maybe Double
totalResponseTime) (\s :: EdgeStatistics
s@EdgeStatistics' {} Maybe Double
a -> EdgeStatistics
s {$sel:totalResponseTime:EdgeStatistics' :: Maybe Double
totalResponseTime = Maybe Double
a} :: EdgeStatistics)

instance Data.FromJSON EdgeStatistics where
  parseJSON :: Value -> Parser EdgeStatistics
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EdgeStatistics"
      ( \Object
x ->
          Maybe ErrorStatistics
-> Maybe FaultStatistics
-> Maybe Integer
-> Maybe Integer
-> Maybe Double
-> EdgeStatistics
EdgeStatistics'
            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
"ErrorStatistics")
            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
"FaultStatistics")
            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
"OkCount")
            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
"TotalCount")
            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
"TotalResponseTime")
      )

instance Prelude.Hashable EdgeStatistics where
  hashWithSalt :: Int -> EdgeStatistics -> Int
hashWithSalt Int
_salt EdgeStatistics' {Maybe Double
Maybe Integer
Maybe ErrorStatistics
Maybe FaultStatistics
totalResponseTime :: Maybe Double
totalCount :: Maybe Integer
okCount :: Maybe Integer
faultStatistics :: Maybe FaultStatistics
errorStatistics :: Maybe ErrorStatistics
$sel:totalResponseTime:EdgeStatistics' :: EdgeStatistics -> Maybe Double
$sel:totalCount:EdgeStatistics' :: EdgeStatistics -> Maybe Integer
$sel:okCount:EdgeStatistics' :: EdgeStatistics -> Maybe Integer
$sel:faultStatistics:EdgeStatistics' :: EdgeStatistics -> Maybe FaultStatistics
$sel:errorStatistics:EdgeStatistics' :: EdgeStatistics -> Maybe ErrorStatistics
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ErrorStatistics
errorStatistics
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FaultStatistics
faultStatistics
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
okCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
totalCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
totalResponseTime

instance Prelude.NFData EdgeStatistics where
  rnf :: EdgeStatistics -> ()
rnf EdgeStatistics' {Maybe Double
Maybe Integer
Maybe ErrorStatistics
Maybe FaultStatistics
totalResponseTime :: Maybe Double
totalCount :: Maybe Integer
okCount :: Maybe Integer
faultStatistics :: Maybe FaultStatistics
errorStatistics :: Maybe ErrorStatistics
$sel:totalResponseTime:EdgeStatistics' :: EdgeStatistics -> Maybe Double
$sel:totalCount:EdgeStatistics' :: EdgeStatistics -> Maybe Integer
$sel:okCount:EdgeStatistics' :: EdgeStatistics -> Maybe Integer
$sel:faultStatistics:EdgeStatistics' :: EdgeStatistics -> Maybe FaultStatistics
$sel:errorStatistics:EdgeStatistics' :: EdgeStatistics -> Maybe ErrorStatistics
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ErrorStatistics
errorStatistics
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe FaultStatistics
faultStatistics
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
okCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
totalCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
totalResponseTime