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

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

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

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

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

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

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

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

instance Prelude.NFData ServiceStatistics