{-# 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.ErrorStatistics
-- 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.ErrorStatistics 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 4xx Client Error status
-- code.
--
-- /See:/ 'newErrorStatistics' smart constructor.
data ErrorStatistics = ErrorStatistics'
  { -- | The number of requests that failed with untracked 4xx Client Error
    -- status codes.
    ErrorStatistics -> Maybe Integer
otherCount :: Prelude.Maybe Prelude.Integer,
    -- | The number of requests that failed with a 419 throttling status code.
    ErrorStatistics -> Maybe Integer
throttleCount :: Prelude.Maybe Prelude.Integer,
    -- | The total number of requests that failed with a 4xx Client Error status
    -- code.
    ErrorStatistics -> Maybe Integer
totalCount :: Prelude.Maybe Prelude.Integer
  }
  deriving (ErrorStatistics -> ErrorStatistics -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ErrorStatistics -> ErrorStatistics -> Bool
$c/= :: ErrorStatistics -> ErrorStatistics -> Bool
== :: ErrorStatistics -> ErrorStatistics -> Bool
$c== :: ErrorStatistics -> ErrorStatistics -> Bool
Prelude.Eq, ReadPrec [ErrorStatistics]
ReadPrec ErrorStatistics
Int -> ReadS ErrorStatistics
ReadS [ErrorStatistics]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ErrorStatistics]
$creadListPrec :: ReadPrec [ErrorStatistics]
readPrec :: ReadPrec ErrorStatistics
$creadPrec :: ReadPrec ErrorStatistics
readList :: ReadS [ErrorStatistics]
$creadList :: ReadS [ErrorStatistics]
readsPrec :: Int -> ReadS ErrorStatistics
$creadsPrec :: Int -> ReadS ErrorStatistics
Prelude.Read, Int -> ErrorStatistics -> ShowS
[ErrorStatistics] -> ShowS
ErrorStatistics -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ErrorStatistics] -> ShowS
$cshowList :: [ErrorStatistics] -> ShowS
show :: ErrorStatistics -> String
$cshow :: ErrorStatistics -> String
showsPrec :: Int -> ErrorStatistics -> ShowS
$cshowsPrec :: Int -> ErrorStatistics -> ShowS
Prelude.Show, forall x. Rep ErrorStatistics x -> ErrorStatistics
forall x. ErrorStatistics -> Rep ErrorStatistics x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ErrorStatistics x -> ErrorStatistics
$cfrom :: forall x. ErrorStatistics -> Rep ErrorStatistics x
Prelude.Generic)

-- |
-- Create a value of 'ErrorStatistics' 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', 'errorStatistics_otherCount' - The number of requests that failed with untracked 4xx Client Error
-- status codes.
--
-- 'throttleCount', 'errorStatistics_throttleCount' - The number of requests that failed with a 419 throttling status code.
--
-- 'totalCount', 'errorStatistics_totalCount' - The total number of requests that failed with a 4xx Client Error status
-- code.
newErrorStatistics ::
  ErrorStatistics
newErrorStatistics :: ErrorStatistics
newErrorStatistics =
  ErrorStatistics'
    { $sel:otherCount:ErrorStatistics' :: Maybe Integer
otherCount = forall a. Maybe a
Prelude.Nothing,
      $sel:throttleCount:ErrorStatistics' :: Maybe Integer
throttleCount = forall a. Maybe a
Prelude.Nothing,
      $sel:totalCount:ErrorStatistics' :: Maybe Integer
totalCount = forall a. Maybe a
Prelude.Nothing
    }

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

-- | The number of requests that failed with a 419 throttling status code.
errorStatistics_throttleCount :: Lens.Lens' ErrorStatistics (Prelude.Maybe Prelude.Integer)
errorStatistics_throttleCount :: Lens' ErrorStatistics (Maybe Integer)
errorStatistics_throttleCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ErrorStatistics' {Maybe Integer
throttleCount :: Maybe Integer
$sel:throttleCount:ErrorStatistics' :: ErrorStatistics -> Maybe Integer
throttleCount} -> Maybe Integer
throttleCount) (\s :: ErrorStatistics
s@ErrorStatistics' {} Maybe Integer
a -> ErrorStatistics
s {$sel:throttleCount:ErrorStatistics' :: Maybe Integer
throttleCount = Maybe Integer
a} :: ErrorStatistics)

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

instance Data.FromJSON ErrorStatistics where
  parseJSON :: Value -> Parser ErrorStatistics
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ErrorStatistics"
      ( \Object
x ->
          Maybe Integer -> Maybe Integer -> Maybe Integer -> ErrorStatistics
ErrorStatistics'
            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
"ThrottleCount")
            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 ErrorStatistics where
  hashWithSalt :: Int -> ErrorStatistics -> Int
hashWithSalt Int
_salt ErrorStatistics' {Maybe Integer
totalCount :: Maybe Integer
throttleCount :: Maybe Integer
otherCount :: Maybe Integer
$sel:totalCount:ErrorStatistics' :: ErrorStatistics -> Maybe Integer
$sel:throttleCount:ErrorStatistics' :: ErrorStatistics -> Maybe Integer
$sel:otherCount:ErrorStatistics' :: ErrorStatistics -> 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
throttleCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
totalCount

instance Prelude.NFData ErrorStatistics where
  rnf :: ErrorStatistics -> ()
rnf ErrorStatistics' {Maybe Integer
totalCount :: Maybe Integer
throttleCount :: Maybe Integer
otherCount :: Maybe Integer
$sel:totalCount:ErrorStatistics' :: ErrorStatistics -> Maybe Integer
$sel:throttleCount:ErrorStatistics' :: ErrorStatistics -> Maybe Integer
$sel:otherCount:ErrorStatistics' :: ErrorStatistics -> 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
throttleCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
totalCount