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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.XRay.Types.FaultRootCauseService

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

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

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

-- | A list of corresponding services. A service identifies a segment and it
-- contains a name, account ID, type, and inferred flag.
faultRootCause_services :: Lens.Lens' FaultRootCause (Prelude.Maybe [FaultRootCauseService])
faultRootCause_services :: (Maybe [FaultRootCauseService]
 -> f (Maybe [FaultRootCauseService]))
-> FaultRootCause -> f FaultRootCause
faultRootCause_services = (FaultRootCause -> Maybe [FaultRootCauseService])
-> (FaultRootCause
    -> Maybe [FaultRootCauseService] -> FaultRootCause)
-> Lens
     FaultRootCause
     FaultRootCause
     (Maybe [FaultRootCauseService])
     (Maybe [FaultRootCauseService])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FaultRootCause' {Maybe [FaultRootCauseService]
services :: Maybe [FaultRootCauseService]
$sel:services:FaultRootCause' :: FaultRootCause -> Maybe [FaultRootCauseService]
services} -> Maybe [FaultRootCauseService]
services) (\s :: FaultRootCause
s@FaultRootCause' {} Maybe [FaultRootCauseService]
a -> FaultRootCause
s {$sel:services:FaultRootCause' :: Maybe [FaultRootCauseService]
services = Maybe [FaultRootCauseService]
a} :: FaultRootCause) ((Maybe [FaultRootCauseService]
  -> f (Maybe [FaultRootCauseService]))
 -> FaultRootCause -> f FaultRootCause)
-> ((Maybe [FaultRootCauseService]
     -> f (Maybe [FaultRootCauseService]))
    -> Maybe [FaultRootCauseService]
    -> f (Maybe [FaultRootCauseService]))
-> (Maybe [FaultRootCauseService]
    -> f (Maybe [FaultRootCauseService]))
-> FaultRootCause
-> f FaultRootCause
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [FaultRootCauseService]
  [FaultRootCauseService]
  [FaultRootCauseService]
  [FaultRootCauseService]
-> Iso
     (Maybe [FaultRootCauseService])
     (Maybe [FaultRootCauseService])
     (Maybe [FaultRootCauseService])
     (Maybe [FaultRootCauseService])
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
  [FaultRootCauseService]
  [FaultRootCauseService]
  [FaultRootCauseService]
  [FaultRootCauseService]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON FaultRootCause where
  parseJSON :: Value -> Parser FaultRootCause
parseJSON =
    String
-> (Object -> Parser FaultRootCause)
-> Value
-> Parser FaultRootCause
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FaultRootCause"
      ( \Object
x ->
          Maybe Bool -> Maybe [FaultRootCauseService] -> FaultRootCause
FaultRootCause'
            (Maybe Bool -> Maybe [FaultRootCauseService] -> FaultRootCause)
-> Parser (Maybe Bool)
-> Parser (Maybe [FaultRootCauseService] -> FaultRootCause)
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 [FaultRootCauseService] -> FaultRootCause)
-> Parser (Maybe [FaultRootCauseService]) -> Parser FaultRootCause
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [FaultRootCauseService]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Services" Parser (Maybe (Maybe [FaultRootCauseService]))
-> Maybe [FaultRootCauseService]
-> Parser (Maybe [FaultRootCauseService])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [FaultRootCauseService]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable FaultRootCause

instance Prelude.NFData FaultRootCause