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

-- | The types and messages of the exceptions.
faultRootCauseEntity_exceptions :: Lens.Lens' FaultRootCauseEntity (Prelude.Maybe [RootCauseException])
faultRootCauseEntity_exceptions :: Lens' FaultRootCauseEntity (Maybe [RootCauseException])
faultRootCauseEntity_exceptions = 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) 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

-- | The name of the entity.
faultRootCauseEntity_name :: Lens.Lens' FaultRootCauseEntity (Prelude.Maybe Prelude.Text)
faultRootCauseEntity_name :: Lens' FaultRootCauseEntity (Maybe Text)
faultRootCauseEntity_name = 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)

-- | A flag that denotes a remote subsegment.
faultRootCauseEntity_remote :: Lens.Lens' FaultRootCauseEntity (Prelude.Maybe Prelude.Bool)
faultRootCauseEntity_remote :: Lens' FaultRootCauseEntity (Maybe Bool)
faultRootCauseEntity_remote = 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)

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

instance Prelude.Hashable FaultRootCauseEntity where
  hashWithSalt :: Int -> FaultRootCauseEntity -> Int
hashWithSalt Int
_salt FaultRootCauseEntity' {Maybe Bool
Maybe [RootCauseException]
Maybe Text
remote :: Maybe Bool
name :: Maybe Text
exceptions :: Maybe [RootCauseException]
$sel:remote:FaultRootCauseEntity' :: FaultRootCauseEntity -> Maybe Bool
$sel:name:FaultRootCauseEntity' :: FaultRootCauseEntity -> Maybe Text
$sel:exceptions:FaultRootCauseEntity' :: FaultRootCauseEntity -> Maybe [RootCauseException]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [RootCauseException]
exceptions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
remote

instance Prelude.NFData FaultRootCauseEntity where
  rnf :: FaultRootCauseEntity -> ()
rnf FaultRootCauseEntity' {Maybe Bool
Maybe [RootCauseException]
Maybe Text
remote :: Maybe Bool
name :: Maybe Text
exceptions :: Maybe [RootCauseException]
$sel:remote:FaultRootCauseEntity' :: FaultRootCauseEntity -> Maybe Bool
$sel:name:FaultRootCauseEntity' :: FaultRootCauseEntity -> Maybe Text
$sel:exceptions:FaultRootCauseEntity' :: FaultRootCauseEntity -> Maybe [RootCauseException]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [RootCauseException]
exceptions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
remote