{-# 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-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.ErrorStatistics 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 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
(ErrorStatistics -> ErrorStatistics -> Bool)
-> (ErrorStatistics -> ErrorStatistics -> Bool)
-> Eq ErrorStatistics
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]
(Int -> ReadS ErrorStatistics)
-> ReadS [ErrorStatistics]
-> ReadPrec ErrorStatistics
-> ReadPrec [ErrorStatistics]
-> Read 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
(Int -> ErrorStatistics -> ShowS)
-> (ErrorStatistics -> String)
-> ([ErrorStatistics] -> ShowS)
-> Show ErrorStatistics
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. ErrorStatistics -> Rep ErrorStatistics x)
-> (forall x. Rep ErrorStatistics x -> ErrorStatistics)
-> Generic ErrorStatistics
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' :: Maybe Integer -> Maybe Integer -> Maybe Integer -> ErrorStatistics
ErrorStatistics'
    { $sel:otherCount:ErrorStatistics' :: Maybe Integer
otherCount = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:throttleCount:ErrorStatistics' :: Maybe Integer
throttleCount = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:totalCount:ErrorStatistics' :: Maybe Integer
totalCount = Maybe Integer
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 :: (Maybe Integer -> f (Maybe Integer))
-> ErrorStatistics -> f ErrorStatistics
errorStatistics_otherCount = (ErrorStatistics -> Maybe Integer)
-> (ErrorStatistics -> Maybe Integer -> ErrorStatistics)
-> Lens
     ErrorStatistics ErrorStatistics (Maybe Integer) (Maybe Integer)
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 :: (Maybe Integer -> f (Maybe Integer))
-> ErrorStatistics -> f ErrorStatistics
errorStatistics_throttleCount = (ErrorStatistics -> Maybe Integer)
-> (ErrorStatistics -> Maybe Integer -> ErrorStatistics)
-> Lens
     ErrorStatistics ErrorStatistics (Maybe Integer) (Maybe Integer)
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 :: (Maybe Integer -> f (Maybe Integer))
-> ErrorStatistics -> f ErrorStatistics
errorStatistics_totalCount = (ErrorStatistics -> Maybe Integer)
-> (ErrorStatistics -> Maybe Integer -> ErrorStatistics)
-> Lens
     ErrorStatistics ErrorStatistics (Maybe Integer) (Maybe Integer)
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 Core.FromJSON ErrorStatistics where
  parseJSON :: Value -> Parser ErrorStatistics
parseJSON =
    String
-> (Object -> Parser ErrorStatistics)
-> Value
-> Parser ErrorStatistics
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ErrorStatistics"
      ( \Object
x ->
          Maybe Integer -> Maybe Integer -> Maybe Integer -> ErrorStatistics
ErrorStatistics'
            (Maybe Integer
 -> Maybe Integer -> Maybe Integer -> ErrorStatistics)
-> Parser (Maybe Integer)
-> Parser (Maybe Integer -> Maybe Integer -> ErrorStatistics)
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 -> Maybe Integer -> ErrorStatistics)
-> Parser (Maybe Integer)
-> Parser (Maybe Integer -> ErrorStatistics)
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
"ThrottleCount")
            Parser (Maybe Integer -> ErrorStatistics)
-> Parser (Maybe Integer) -> Parser ErrorStatistics
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 ErrorStatistics

instance Prelude.NFData ErrorStatistics