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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(ErrorRootCause -> ErrorRootCause -> Bool)
-> (ErrorRootCause -> ErrorRootCause -> Bool) -> Eq ErrorRootCause
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]
(Int -> ReadS ErrorRootCause)
-> ReadS [ErrorRootCause]
-> ReadPrec ErrorRootCause
-> ReadPrec [ErrorRootCause]
-> Read 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
(Int -> ErrorRootCause -> ShowS)
-> (ErrorRootCause -> String)
-> ([ErrorRootCause] -> ShowS)
-> Show ErrorRootCause
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. ErrorRootCause -> Rep ErrorRootCause x)
-> (forall x. Rep ErrorRootCause x -> ErrorRootCause)
-> Generic ErrorRootCause
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' :: Maybe Bool -> Maybe [ErrorRootCauseService] -> ErrorRootCause
ErrorRootCause'
    { $sel:clientImpacting:ErrorRootCause' :: Maybe Bool
clientImpacting = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:services:ErrorRootCause' :: Maybe [ErrorRootCauseService]
services = Maybe [ErrorRootCauseService]
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 :: (Maybe Bool -> f (Maybe Bool))
-> ErrorRootCause -> f ErrorRootCause
errorRootCause_clientImpacting = (ErrorRootCause -> Maybe Bool)
-> (ErrorRootCause -> Maybe Bool -> ErrorRootCause)
-> Lens ErrorRootCause ErrorRootCause (Maybe Bool) (Maybe Bool)
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 :: (Maybe [ErrorRootCauseService]
 -> f (Maybe [ErrorRootCauseService]))
-> ErrorRootCause -> f ErrorRootCause
errorRootCause_services = (ErrorRootCause -> Maybe [ErrorRootCauseService])
-> (ErrorRootCause
    -> Maybe [ErrorRootCauseService] -> ErrorRootCause)
-> Lens
     ErrorRootCause
     ErrorRootCause
     (Maybe [ErrorRootCauseService])
     (Maybe [ErrorRootCauseService])
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) ((Maybe [ErrorRootCauseService]
  -> f (Maybe [ErrorRootCauseService]))
 -> ErrorRootCause -> f ErrorRootCause)
-> ((Maybe [ErrorRootCauseService]
     -> f (Maybe [ErrorRootCauseService]))
    -> Maybe [ErrorRootCauseService]
    -> f (Maybe [ErrorRootCauseService]))
-> (Maybe [ErrorRootCauseService]
    -> f (Maybe [ErrorRootCauseService]))
-> ErrorRootCause
-> f ErrorRootCause
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ErrorRootCauseService]
  [ErrorRootCauseService]
  [ErrorRootCauseService]
  [ErrorRootCauseService]
-> Iso
     (Maybe [ErrorRootCauseService])
     (Maybe [ErrorRootCauseService])
     (Maybe [ErrorRootCauseService])
     (Maybe [ErrorRootCauseService])
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 AnIso
  [ErrorRootCauseService]
  [ErrorRootCauseService]
  [ErrorRootCauseService]
  [ErrorRootCauseService]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON ErrorRootCause where
  parseJSON :: Value -> Parser ErrorRootCause
parseJSON =
    String
-> (Object -> Parser ErrorRootCause)
-> Value
-> Parser ErrorRootCause
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ErrorRootCause"
      ( \Object
x ->
          Maybe Bool -> Maybe [ErrorRootCauseService] -> ErrorRootCause
ErrorRootCause'
            (Maybe Bool -> Maybe [ErrorRootCauseService] -> ErrorRootCause)
-> Parser (Maybe Bool)
-> Parser (Maybe [ErrorRootCauseService] -> ErrorRootCause)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ClientImpacting")
            Parser (Maybe [ErrorRootCauseService] -> ErrorRootCause)
-> Parser (Maybe [ErrorRootCauseService]) -> Parser ErrorRootCause
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [ErrorRootCauseService]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Services" Parser (Maybe (Maybe [ErrorRootCauseService]))
-> Maybe [ErrorRootCauseService]
-> Parser (Maybe [ErrorRootCauseService])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [ErrorRootCauseService]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ErrorRootCause

instance Prelude.NFData ErrorRootCause