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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 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 aggregate response time of completed requests.
    EdgeStatistics -> Maybe Double
totalResponseTime :: Prelude.Maybe Prelude.Double,
    -- | Information about requests that failed with a 4xx Client Error status
    -- code.
    EdgeStatistics -> Maybe ErrorStatistics
errorStatistics :: Prelude.Maybe ErrorStatistics,
    -- | The total number of completed requests.
    EdgeStatistics -> Maybe Integer
totalCount :: Prelude.Maybe Prelude.Integer
  }
  deriving (EdgeStatistics -> EdgeStatistics -> Bool
(EdgeStatistics -> EdgeStatistics -> Bool)
-> (EdgeStatistics -> EdgeStatistics -> Bool) -> Eq EdgeStatistics
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]
(Int -> ReadS EdgeStatistics)
-> ReadS [EdgeStatistics]
-> ReadPrec EdgeStatistics
-> ReadPrec [EdgeStatistics]
-> Read 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
(Int -> EdgeStatistics -> ShowS)
-> (EdgeStatistics -> String)
-> ([EdgeStatistics] -> ShowS)
-> Show EdgeStatistics
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. EdgeStatistics -> Rep EdgeStatistics x)
-> (forall x. Rep EdgeStatistics x -> EdgeStatistics)
-> Generic EdgeStatistics
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:
--
-- '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.
--
-- 'totalResponseTime', 'edgeStatistics_totalResponseTime' - The aggregate response time of completed requests.
--
-- 'errorStatistics', 'edgeStatistics_errorStatistics' - Information about requests that failed with a 4xx Client Error status
-- code.
--
-- 'totalCount', 'edgeStatistics_totalCount' - The total number of completed requests.
newEdgeStatistics ::
  EdgeStatistics
newEdgeStatistics :: EdgeStatistics
newEdgeStatistics =
  EdgeStatistics' :: Maybe FaultStatistics
-> Maybe Integer
-> Maybe Double
-> Maybe ErrorStatistics
-> Maybe Integer
-> EdgeStatistics
EdgeStatistics'
    { $sel:faultStatistics:EdgeStatistics' :: Maybe FaultStatistics
faultStatistics = Maybe FaultStatistics
forall a. Maybe a
Prelude.Nothing,
      $sel:okCount:EdgeStatistics' :: Maybe Integer
okCount = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:totalResponseTime:EdgeStatistics' :: Maybe Double
totalResponseTime = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:errorStatistics:EdgeStatistics' :: Maybe ErrorStatistics
errorStatistics = Maybe ErrorStatistics
forall a. Maybe a
Prelude.Nothing,
      $sel:totalCount:EdgeStatistics' :: Maybe Integer
totalCount = Maybe Integer
forall a. Maybe a
Prelude.Nothing
    }

-- | Information about requests that failed with a 5xx Server Error status
-- code.
edgeStatistics_faultStatistics :: Lens.Lens' EdgeStatistics (Prelude.Maybe FaultStatistics)
edgeStatistics_faultStatistics :: (Maybe FaultStatistics -> f (Maybe FaultStatistics))
-> EdgeStatistics -> f EdgeStatistics
edgeStatistics_faultStatistics = (EdgeStatistics -> Maybe FaultStatistics)
-> (EdgeStatistics -> Maybe FaultStatistics -> EdgeStatistics)
-> Lens
     EdgeStatistics
     EdgeStatistics
     (Maybe FaultStatistics)
     (Maybe 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 :: (Maybe Integer -> f (Maybe Integer))
-> EdgeStatistics -> f EdgeStatistics
edgeStatistics_okCount = (EdgeStatistics -> Maybe Integer)
-> (EdgeStatistics -> Maybe Integer -> EdgeStatistics)
-> Lens
     EdgeStatistics EdgeStatistics (Maybe Integer) (Maybe Integer)
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 aggregate response time of completed requests.
edgeStatistics_totalResponseTime :: Lens.Lens' EdgeStatistics (Prelude.Maybe Prelude.Double)
edgeStatistics_totalResponseTime :: (Maybe Double -> f (Maybe Double))
-> EdgeStatistics -> f EdgeStatistics
edgeStatistics_totalResponseTime = (EdgeStatistics -> Maybe Double)
-> (EdgeStatistics -> Maybe Double -> EdgeStatistics)
-> Lens EdgeStatistics EdgeStatistics (Maybe Double) (Maybe Double)
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)

-- | Information about requests that failed with a 4xx Client Error status
-- code.
edgeStatistics_errorStatistics :: Lens.Lens' EdgeStatistics (Prelude.Maybe ErrorStatistics)
edgeStatistics_errorStatistics :: (Maybe ErrorStatistics -> f (Maybe ErrorStatistics))
-> EdgeStatistics -> f EdgeStatistics
edgeStatistics_errorStatistics = (EdgeStatistics -> Maybe ErrorStatistics)
-> (EdgeStatistics -> Maybe ErrorStatistics -> EdgeStatistics)
-> Lens
     EdgeStatistics
     EdgeStatistics
     (Maybe ErrorStatistics)
     (Maybe 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)

-- | The total number of completed requests.
edgeStatistics_totalCount :: Lens.Lens' EdgeStatistics (Prelude.Maybe Prelude.Integer)
edgeStatistics_totalCount :: (Maybe Integer -> f (Maybe Integer))
-> EdgeStatistics -> f EdgeStatistics
edgeStatistics_totalCount = (EdgeStatistics -> Maybe Integer)
-> (EdgeStatistics -> Maybe Integer -> EdgeStatistics)
-> Lens
     EdgeStatistics EdgeStatistics (Maybe Integer) (Maybe Integer)
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)

instance Core.FromJSON EdgeStatistics where
  parseJSON :: Value -> Parser EdgeStatistics
parseJSON =
    String
-> (Object -> Parser EdgeStatistics)
-> Value
-> Parser EdgeStatistics
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EdgeStatistics"
      ( \Object
x ->
          Maybe FaultStatistics
-> Maybe Integer
-> Maybe Double
-> Maybe ErrorStatistics
-> Maybe Integer
-> EdgeStatistics
EdgeStatistics'
            (Maybe FaultStatistics
 -> Maybe Integer
 -> Maybe Double
 -> Maybe ErrorStatistics
 -> Maybe Integer
 -> EdgeStatistics)
-> Parser (Maybe FaultStatistics)
-> Parser
     (Maybe Integer
      -> Maybe Double
      -> Maybe ErrorStatistics
      -> Maybe Integer
      -> EdgeStatistics)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe FaultStatistics)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FaultStatistics")
            Parser
  (Maybe Integer
   -> Maybe Double
   -> Maybe ErrorStatistics
   -> Maybe Integer
   -> EdgeStatistics)
-> Parser (Maybe Integer)
-> Parser
     (Maybe Double
      -> Maybe ErrorStatistics -> Maybe Integer -> EdgeStatistics)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"OkCount")
            Parser
  (Maybe Double
   -> Maybe ErrorStatistics -> Maybe Integer -> EdgeStatistics)
-> Parser (Maybe Double)
-> Parser
     (Maybe ErrorStatistics -> Maybe Integer -> EdgeStatistics)
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
"TotalResponseTime")
            Parser (Maybe ErrorStatistics -> Maybe Integer -> EdgeStatistics)
-> Parser (Maybe ErrorStatistics)
-> Parser (Maybe Integer -> EdgeStatistics)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ErrorStatistics)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ErrorStatistics")
            Parser (Maybe Integer -> EdgeStatistics)
-> Parser (Maybe Integer) -> Parser EdgeStatistics
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TotalCount")
      )

instance Prelude.Hashable EdgeStatistics

instance Prelude.NFData EdgeStatistics