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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(FaultStatistics -> FaultStatistics -> Bool)
-> (FaultStatistics -> FaultStatistics -> Bool)
-> Eq FaultStatistics
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]
(Int -> ReadS FaultStatistics)
-> ReadS [FaultStatistics]
-> ReadPrec FaultStatistics
-> ReadPrec [FaultStatistics]
-> Read 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
(Int -> FaultStatistics -> ShowS)
-> (FaultStatistics -> String)
-> ([FaultStatistics] -> ShowS)
-> Show FaultStatistics
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. FaultStatistics -> Rep FaultStatistics x)
-> (forall x. Rep FaultStatistics x -> FaultStatistics)
-> Generic FaultStatistics
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' :: Maybe Integer -> Maybe Integer -> FaultStatistics
FaultStatistics'
    { $sel:otherCount:FaultStatistics' :: Maybe Integer
otherCount = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:totalCount:FaultStatistics' :: Maybe Integer
totalCount = Maybe Integer
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 :: (Maybe Integer -> f (Maybe Integer))
-> FaultStatistics -> f FaultStatistics
faultStatistics_otherCount = (FaultStatistics -> Maybe Integer)
-> (FaultStatistics -> Maybe Integer -> FaultStatistics)
-> Lens
     FaultStatistics FaultStatistics (Maybe Integer) (Maybe Integer)
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 :: (Maybe Integer -> f (Maybe Integer))
-> FaultStatistics -> f FaultStatistics
faultStatistics_totalCount = (FaultStatistics -> Maybe Integer)
-> (FaultStatistics -> Maybe Integer -> FaultStatistics)
-> Lens
     FaultStatistics FaultStatistics (Maybe Integer) (Maybe Integer)
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 Core.FromJSON FaultStatistics where
  parseJSON :: Value -> Parser FaultStatistics
parseJSON =
    String
-> (Object -> Parser FaultStatistics)
-> Value
-> Parser FaultStatistics
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FaultStatistics"
      ( \Object
x ->
          Maybe Integer -> Maybe Integer -> FaultStatistics
FaultStatistics'
            (Maybe Integer -> Maybe Integer -> FaultStatistics)
-> Parser (Maybe Integer)
-> Parser (Maybe Integer -> FaultStatistics)
forall (f :: * -> *) a b. Functor 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
"OtherCount")
            Parser (Maybe Integer -> FaultStatistics)
-> Parser (Maybe Integer) -> Parser FaultStatistics
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 FaultStatistics

instance Prelude.NFData FaultStatistics