{-# 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.ErrorRootCause
-- 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.ErrorRootCause 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
import Amazonka.XRay.Types.ErrorRootCauseService

-- | The root cause of a trace summary error.
--
-- /See:/ 'newErrorRootCause' smart constructor.
data ErrorRootCause = ErrorRootCause'
  { -- | A flag that denotes that the root cause impacts the trace client.
    ErrorRootCause -> Maybe Bool
clientImpacting :: Prelude.Maybe Prelude.Bool,
    -- | A list of services corresponding to an error. A service identifies a
    -- segment and it contains a name, account ID, type, and inferred flag.
    ErrorRootCause -> Maybe [ErrorRootCauseService]
services :: Prelude.Maybe [ErrorRootCauseService]
  }
  deriving (ErrorRootCause -> ErrorRootCause -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ErrorRootCause -> ErrorRootCause -> Bool
$c/= :: ErrorRootCause -> ErrorRootCause -> Bool
== :: ErrorRootCause -> ErrorRootCause -> Bool
$c== :: ErrorRootCause -> ErrorRootCause -> Bool
Prelude.Eq, ReadPrec [ErrorRootCause]
ReadPrec ErrorRootCause
Int -> ReadS ErrorRootCause
ReadS [ErrorRootCause]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ErrorRootCause]
$creadListPrec :: ReadPrec [ErrorRootCause]
readPrec :: ReadPrec ErrorRootCause
$creadPrec :: ReadPrec ErrorRootCause
readList :: ReadS [ErrorRootCause]
$creadList :: ReadS [ErrorRootCause]
readsPrec :: Int -> ReadS ErrorRootCause
$creadsPrec :: Int -> ReadS ErrorRootCause
Prelude.Read, Int -> ErrorRootCause -> ShowS
[ErrorRootCause] -> ShowS
ErrorRootCause -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ErrorRootCause] -> ShowS
$cshowList :: [ErrorRootCause] -> ShowS
show :: ErrorRootCause -> String
$cshow :: ErrorRootCause -> String
showsPrec :: Int -> ErrorRootCause -> ShowS
$cshowsPrec :: Int -> ErrorRootCause -> ShowS
Prelude.Show, forall x. Rep ErrorRootCause x -> ErrorRootCause
forall x. ErrorRootCause -> Rep ErrorRootCause x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ErrorRootCause x -> ErrorRootCause
$cfrom :: forall x. ErrorRootCause -> Rep ErrorRootCause x
Prelude.Generic)

-- |
-- Create a value of 'ErrorRootCause' 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:
--
-- 'clientImpacting', 'errorRootCause_clientImpacting' - A flag that denotes that the root cause impacts the trace client.
--
-- 'services', 'errorRootCause_services' - A list of services corresponding to an error. A service identifies a
-- segment and it contains a name, account ID, type, and inferred flag.
newErrorRootCause ::
  ErrorRootCause
newErrorRootCause :: ErrorRootCause
newErrorRootCause =
  ErrorRootCause'
    { $sel:clientImpacting:ErrorRootCause' :: Maybe Bool
clientImpacting = forall a. Maybe a
Prelude.Nothing,
      $sel:services:ErrorRootCause' :: Maybe [ErrorRootCauseService]
services = forall a. Maybe a
Prelude.Nothing
    }

-- | A flag that denotes that the root cause impacts the trace client.
errorRootCause_clientImpacting :: Lens.Lens' ErrorRootCause (Prelude.Maybe Prelude.Bool)
errorRootCause_clientImpacting :: Lens' ErrorRootCause (Maybe Bool)
errorRootCause_clientImpacting = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ErrorRootCause' {Maybe Bool
clientImpacting :: Maybe Bool
$sel:clientImpacting:ErrorRootCause' :: ErrorRootCause -> Maybe Bool
clientImpacting} -> Maybe Bool
clientImpacting) (\s :: ErrorRootCause
s@ErrorRootCause' {} Maybe Bool
a -> ErrorRootCause
s {$sel:clientImpacting:ErrorRootCause' :: Maybe Bool
clientImpacting = Maybe Bool
a} :: ErrorRootCause)

-- | A list of services corresponding to an error. A service identifies a
-- segment and it contains a name, account ID, type, and inferred flag.
errorRootCause_services :: Lens.Lens' ErrorRootCause (Prelude.Maybe [ErrorRootCauseService])
errorRootCause_services :: Lens' ErrorRootCause (Maybe [ErrorRootCauseService])
errorRootCause_services = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ErrorRootCause' {Maybe [ErrorRootCauseService]
services :: Maybe [ErrorRootCauseService]
$sel:services:ErrorRootCause' :: ErrorRootCause -> Maybe [ErrorRootCauseService]
services} -> Maybe [ErrorRootCauseService]
services) (\s :: ErrorRootCause
s@ErrorRootCause' {} Maybe [ErrorRootCauseService]
a -> ErrorRootCause
s {$sel:services:ErrorRootCause' :: Maybe [ErrorRootCauseService]
services = Maybe [ErrorRootCauseService]
a} :: ErrorRootCause) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON ErrorRootCause where
  parseJSON :: Value -> Parser ErrorRootCause
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ErrorRootCause"
      ( \Object
x ->
          Maybe Bool -> Maybe [ErrorRootCauseService] -> ErrorRootCause
ErrorRootCause'
            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
"ClientImpacting")
            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
"Services" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ErrorRootCause where
  hashWithSalt :: Int -> ErrorRootCause -> Int
hashWithSalt Int
_salt ErrorRootCause' {Maybe Bool
Maybe [ErrorRootCauseService]
services :: Maybe [ErrorRootCauseService]
clientImpacting :: Maybe Bool
$sel:services:ErrorRootCause' :: ErrorRootCause -> Maybe [ErrorRootCauseService]
$sel:clientImpacting:ErrorRootCause' :: ErrorRootCause -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
clientImpacting
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [ErrorRootCauseService]
services

instance Prelude.NFData ErrorRootCause where
  rnf :: ErrorRootCause -> ()
rnf ErrorRootCause' {Maybe Bool
Maybe [ErrorRootCauseService]
services :: Maybe [ErrorRootCauseService]
clientImpacting :: Maybe Bool
$sel:services:ErrorRootCause' :: ErrorRootCause -> Maybe [ErrorRootCauseService]
$sel:clientImpacting:ErrorRootCause' :: ErrorRootCause -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
clientImpacting
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [ErrorRootCauseService]
services