{-# 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.FaultStatistics
-- 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.FaultStatistics 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

-- | Information about requests that failed with a 5xx Server Error status
-- code.
--
-- /See:/ 'newFaultStatistics' smart constructor.
data FaultStatistics = FaultStatistics'
  { -- | The number of requests that failed with untracked 5xx Server Error
    -- status codes.
    FaultStatistics -> Maybe Integer
otherCount :: Prelude.Maybe Prelude.Integer,
    -- | The total number of requests that failed with a 5xx Server Error status
    -- code.
    FaultStatistics -> Maybe Integer
totalCount :: Prelude.Maybe Prelude.Integer
  }
  deriving (FaultStatistics -> FaultStatistics -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FaultStatistics -> FaultStatistics -> Bool
$c/= :: FaultStatistics -> FaultStatistics -> Bool
== :: FaultStatistics -> FaultStatistics -> Bool
$c== :: FaultStatistics -> FaultStatistics -> Bool
Prelude.Eq, ReadPrec [FaultStatistics]
ReadPrec FaultStatistics
Int -> ReadS FaultStatistics
ReadS [FaultStatistics]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FaultStatistics]
$creadListPrec :: ReadPrec [FaultStatistics]
readPrec :: ReadPrec FaultStatistics
$creadPrec :: ReadPrec FaultStatistics
readList :: ReadS [FaultStatistics]
$creadList :: ReadS [FaultStatistics]
readsPrec :: Int -> ReadS FaultStatistics
$creadsPrec :: Int -> ReadS FaultStatistics
Prelude.Read, Int -> FaultStatistics -> ShowS
[FaultStatistics] -> ShowS
FaultStatistics -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FaultStatistics] -> ShowS
$cshowList :: [FaultStatistics] -> ShowS
show :: FaultStatistics -> String
$cshow :: FaultStatistics -> String
showsPrec :: Int -> FaultStatistics -> ShowS
$cshowsPrec :: Int -> FaultStatistics -> ShowS
Prelude.Show, forall x. Rep FaultStatistics x -> FaultStatistics
forall x. FaultStatistics -> Rep FaultStatistics x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FaultStatistics x -> FaultStatistics
$cfrom :: forall x. FaultStatistics -> Rep FaultStatistics x
Prelude.Generic)

-- |
-- Create a value of 'FaultStatistics' 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:
--
-- 'otherCount', 'faultStatistics_otherCount' - The number of requests that failed with untracked 5xx Server Error
-- status codes.
--
-- 'totalCount', 'faultStatistics_totalCount' - The total number of requests that failed with a 5xx Server Error status
-- code.
newFaultStatistics ::
  FaultStatistics
newFaultStatistics :: FaultStatistics
newFaultStatistics =
  FaultStatistics'
    { $sel:otherCount:FaultStatistics' :: Maybe Integer
otherCount = forall a. Maybe a
Prelude.Nothing,
      $sel:totalCount:FaultStatistics' :: Maybe Integer
totalCount = forall a. Maybe a
Prelude.Nothing
    }

-- | The number of requests that failed with untracked 5xx Server Error
-- status codes.
faultStatistics_otherCount :: Lens.Lens' FaultStatistics (Prelude.Maybe Prelude.Integer)
faultStatistics_otherCount :: Lens' FaultStatistics (Maybe Integer)
faultStatistics_otherCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FaultStatistics' {Maybe Integer
otherCount :: Maybe Integer
$sel:otherCount:FaultStatistics' :: FaultStatistics -> Maybe Integer
otherCount} -> Maybe Integer
otherCount) (\s :: FaultStatistics
s@FaultStatistics' {} Maybe Integer
a -> FaultStatistics
s {$sel:otherCount:FaultStatistics' :: Maybe Integer
otherCount = Maybe Integer
a} :: FaultStatistics)

-- | The total number of requests that failed with a 5xx Server Error status
-- code.
faultStatistics_totalCount :: Lens.Lens' FaultStatistics (Prelude.Maybe Prelude.Integer)
faultStatistics_totalCount :: Lens' FaultStatistics (Maybe Integer)
faultStatistics_totalCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FaultStatistics' {Maybe Integer
totalCount :: Maybe Integer
$sel:totalCount:FaultStatistics' :: FaultStatistics -> Maybe Integer
totalCount} -> Maybe Integer
totalCount) (\s :: FaultStatistics
s@FaultStatistics' {} Maybe Integer
a -> FaultStatistics
s {$sel:totalCount:FaultStatistics' :: Maybe Integer
totalCount = Maybe Integer
a} :: FaultStatistics)

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

instance Prelude.Hashable FaultStatistics where
  hashWithSalt :: Int -> FaultStatistics -> Int
hashWithSalt Int
_salt FaultStatistics' {Maybe Integer
totalCount :: Maybe Integer
otherCount :: Maybe Integer
$sel:totalCount:FaultStatistics' :: FaultStatistics -> Maybe Integer
$sel:otherCount:FaultStatistics' :: FaultStatistics -> Maybe Integer
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
otherCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
totalCount

instance Prelude.NFData FaultStatistics where
  rnf :: FaultStatistics -> ()
rnf FaultStatistics' {Maybe Integer
totalCount :: Maybe Integer
otherCount :: Maybe Integer
$sel:totalCount:FaultStatistics' :: FaultStatistics -> Maybe Integer
$sel:otherCount:FaultStatistics' :: FaultStatistics -> Maybe Integer
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
otherCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
totalCount