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

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

-- | A collection of segments and corresponding subsegments associated to a
-- trace summary fault error.
--
-- /See:/ 'newFaultRootCauseEntity' smart constructor.
data FaultRootCauseEntity = FaultRootCauseEntity'
  { -- | The types and messages of the exceptions.
    FaultRootCauseEntity -> Maybe [RootCauseException]
exceptions :: Prelude.Maybe [RootCauseException],
    -- | A flag that denotes a remote subsegment.
    FaultRootCauseEntity -> Maybe Bool
remote :: Prelude.Maybe Prelude.Bool,
    -- | The name of the entity.
    FaultRootCauseEntity -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (FaultRootCauseEntity -> FaultRootCauseEntity -> Bool
(FaultRootCauseEntity -> FaultRootCauseEntity -> Bool)
-> (FaultRootCauseEntity -> FaultRootCauseEntity -> Bool)
-> Eq FaultRootCauseEntity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FaultRootCauseEntity -> FaultRootCauseEntity -> Bool
$c/= :: FaultRootCauseEntity -> FaultRootCauseEntity -> Bool
== :: FaultRootCauseEntity -> FaultRootCauseEntity -> Bool
$c== :: FaultRootCauseEntity -> FaultRootCauseEntity -> Bool
Prelude.Eq, ReadPrec [FaultRootCauseEntity]
ReadPrec FaultRootCauseEntity
Int -> ReadS FaultRootCauseEntity
ReadS [FaultRootCauseEntity]
(Int -> ReadS FaultRootCauseEntity)
-> ReadS [FaultRootCauseEntity]
-> ReadPrec FaultRootCauseEntity
-> ReadPrec [FaultRootCauseEntity]
-> Read FaultRootCauseEntity
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FaultRootCauseEntity]
$creadListPrec :: ReadPrec [FaultRootCauseEntity]
readPrec :: ReadPrec FaultRootCauseEntity
$creadPrec :: ReadPrec FaultRootCauseEntity
readList :: ReadS [FaultRootCauseEntity]
$creadList :: ReadS [FaultRootCauseEntity]
readsPrec :: Int -> ReadS FaultRootCauseEntity
$creadsPrec :: Int -> ReadS FaultRootCauseEntity
Prelude.Read, Int -> FaultRootCauseEntity -> ShowS
[FaultRootCauseEntity] -> ShowS
FaultRootCauseEntity -> String
(Int -> FaultRootCauseEntity -> ShowS)
-> (FaultRootCauseEntity -> String)
-> ([FaultRootCauseEntity] -> ShowS)
-> Show FaultRootCauseEntity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FaultRootCauseEntity] -> ShowS
$cshowList :: [FaultRootCauseEntity] -> ShowS
show :: FaultRootCauseEntity -> String
$cshow :: FaultRootCauseEntity -> String
showsPrec :: Int -> FaultRootCauseEntity -> ShowS
$cshowsPrec :: Int -> FaultRootCauseEntity -> ShowS
Prelude.Show, (forall x. FaultRootCauseEntity -> Rep FaultRootCauseEntity x)
-> (forall x. Rep FaultRootCauseEntity x -> FaultRootCauseEntity)
-> Generic FaultRootCauseEntity
forall x. Rep FaultRootCauseEntity x -> FaultRootCauseEntity
forall x. FaultRootCauseEntity -> Rep FaultRootCauseEntity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FaultRootCauseEntity x -> FaultRootCauseEntity
$cfrom :: forall x. FaultRootCauseEntity -> Rep FaultRootCauseEntity x
Prelude.Generic)

-- |
-- Create a value of 'FaultRootCauseEntity' 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:
--
-- 'exceptions', 'faultRootCauseEntity_exceptions' - The types and messages of the exceptions.
--
-- 'remote', 'faultRootCauseEntity_remote' - A flag that denotes a remote subsegment.
--
-- 'name', 'faultRootCauseEntity_name' - The name of the entity.
newFaultRootCauseEntity ::
  FaultRootCauseEntity
newFaultRootCauseEntity :: FaultRootCauseEntity
newFaultRootCauseEntity =
  FaultRootCauseEntity' :: Maybe [RootCauseException]
-> Maybe Bool -> Maybe Text -> FaultRootCauseEntity
FaultRootCauseEntity'
    { $sel:exceptions:FaultRootCauseEntity' :: Maybe [RootCauseException]
exceptions = Maybe [RootCauseException]
forall a. Maybe a
Prelude.Nothing,
      $sel:remote:FaultRootCauseEntity' :: Maybe Bool
remote = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:name:FaultRootCauseEntity' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The types and messages of the exceptions.
faultRootCauseEntity_exceptions :: Lens.Lens' FaultRootCauseEntity (Prelude.Maybe [RootCauseException])
faultRootCauseEntity_exceptions :: (Maybe [RootCauseException] -> f (Maybe [RootCauseException]))
-> FaultRootCauseEntity -> f FaultRootCauseEntity
faultRootCauseEntity_exceptions = (FaultRootCauseEntity -> Maybe [RootCauseException])
-> (FaultRootCauseEntity
    -> Maybe [RootCauseException] -> FaultRootCauseEntity)
-> Lens
     FaultRootCauseEntity
     FaultRootCauseEntity
     (Maybe [RootCauseException])
     (Maybe [RootCauseException])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FaultRootCauseEntity' {Maybe [RootCauseException]
exceptions :: Maybe [RootCauseException]
$sel:exceptions:FaultRootCauseEntity' :: FaultRootCauseEntity -> Maybe [RootCauseException]
exceptions} -> Maybe [RootCauseException]
exceptions) (\s :: FaultRootCauseEntity
s@FaultRootCauseEntity' {} Maybe [RootCauseException]
a -> FaultRootCauseEntity
s {$sel:exceptions:FaultRootCauseEntity' :: Maybe [RootCauseException]
exceptions = Maybe [RootCauseException]
a} :: FaultRootCauseEntity) ((Maybe [RootCauseException] -> f (Maybe [RootCauseException]))
 -> FaultRootCauseEntity -> f FaultRootCauseEntity)
-> ((Maybe [RootCauseException] -> f (Maybe [RootCauseException]))
    -> Maybe [RootCauseException] -> f (Maybe [RootCauseException]))
-> (Maybe [RootCauseException] -> f (Maybe [RootCauseException]))
-> FaultRootCauseEntity
-> f FaultRootCauseEntity
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [RootCauseException]
  [RootCauseException]
  [RootCauseException]
  [RootCauseException]
-> Iso
     (Maybe [RootCauseException])
     (Maybe [RootCauseException])
     (Maybe [RootCauseException])
     (Maybe [RootCauseException])
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
  [RootCauseException]
  [RootCauseException]
  [RootCauseException]
  [RootCauseException]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A flag that denotes a remote subsegment.
faultRootCauseEntity_remote :: Lens.Lens' FaultRootCauseEntity (Prelude.Maybe Prelude.Bool)
faultRootCauseEntity_remote :: (Maybe Bool -> f (Maybe Bool))
-> FaultRootCauseEntity -> f FaultRootCauseEntity
faultRootCauseEntity_remote = (FaultRootCauseEntity -> Maybe Bool)
-> (FaultRootCauseEntity -> Maybe Bool -> FaultRootCauseEntity)
-> Lens
     FaultRootCauseEntity FaultRootCauseEntity (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FaultRootCauseEntity' {Maybe Bool
remote :: Maybe Bool
$sel:remote:FaultRootCauseEntity' :: FaultRootCauseEntity -> Maybe Bool
remote} -> Maybe Bool
remote) (\s :: FaultRootCauseEntity
s@FaultRootCauseEntity' {} Maybe Bool
a -> FaultRootCauseEntity
s {$sel:remote:FaultRootCauseEntity' :: Maybe Bool
remote = Maybe Bool
a} :: FaultRootCauseEntity)

-- | The name of the entity.
faultRootCauseEntity_name :: Lens.Lens' FaultRootCauseEntity (Prelude.Maybe Prelude.Text)
faultRootCauseEntity_name :: (Maybe Text -> f (Maybe Text))
-> FaultRootCauseEntity -> f FaultRootCauseEntity
faultRootCauseEntity_name = (FaultRootCauseEntity -> Maybe Text)
-> (FaultRootCauseEntity -> Maybe Text -> FaultRootCauseEntity)
-> Lens
     FaultRootCauseEntity FaultRootCauseEntity (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FaultRootCauseEntity' {Maybe Text
name :: Maybe Text
$sel:name:FaultRootCauseEntity' :: FaultRootCauseEntity -> Maybe Text
name} -> Maybe Text
name) (\s :: FaultRootCauseEntity
s@FaultRootCauseEntity' {} Maybe Text
a -> FaultRootCauseEntity
s {$sel:name:FaultRootCauseEntity' :: Maybe Text
name = Maybe Text
a} :: FaultRootCauseEntity)

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

instance Prelude.Hashable FaultRootCauseEntity

instance Prelude.NFData FaultRootCauseEntity