{-# 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.ErrorRootCauseEntity
-- 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.ErrorRootCauseEntity 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 error.
--
-- /See:/ 'newErrorRootCauseEntity' smart constructor.
data ErrorRootCauseEntity = ErrorRootCauseEntity'
  { -- | The types and messages of the exceptions.
    ErrorRootCauseEntity -> Maybe [RootCauseException]
exceptions :: Prelude.Maybe [RootCauseException],
    -- | The name of the entity.
    ErrorRootCauseEntity -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | A flag that denotes a remote subsegment.
    ErrorRootCauseEntity -> Maybe Bool
remote :: Prelude.Maybe Prelude.Bool
  }
  deriving (ErrorRootCauseEntity -> ErrorRootCauseEntity -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ErrorRootCauseEntity -> ErrorRootCauseEntity -> Bool
$c/= :: ErrorRootCauseEntity -> ErrorRootCauseEntity -> Bool
== :: ErrorRootCauseEntity -> ErrorRootCauseEntity -> Bool
$c== :: ErrorRootCauseEntity -> ErrorRootCauseEntity -> Bool
Prelude.Eq, ReadPrec [ErrorRootCauseEntity]
ReadPrec ErrorRootCauseEntity
Int -> ReadS ErrorRootCauseEntity
ReadS [ErrorRootCauseEntity]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ErrorRootCauseEntity]
$creadListPrec :: ReadPrec [ErrorRootCauseEntity]
readPrec :: ReadPrec ErrorRootCauseEntity
$creadPrec :: ReadPrec ErrorRootCauseEntity
readList :: ReadS [ErrorRootCauseEntity]
$creadList :: ReadS [ErrorRootCauseEntity]
readsPrec :: Int -> ReadS ErrorRootCauseEntity
$creadsPrec :: Int -> ReadS ErrorRootCauseEntity
Prelude.Read, Int -> ErrorRootCauseEntity -> ShowS
[ErrorRootCauseEntity] -> ShowS
ErrorRootCauseEntity -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ErrorRootCauseEntity] -> ShowS
$cshowList :: [ErrorRootCauseEntity] -> ShowS
show :: ErrorRootCauseEntity -> String
$cshow :: ErrorRootCauseEntity -> String
showsPrec :: Int -> ErrorRootCauseEntity -> ShowS
$cshowsPrec :: Int -> ErrorRootCauseEntity -> ShowS
Prelude.Show, forall x. Rep ErrorRootCauseEntity x -> ErrorRootCauseEntity
forall x. ErrorRootCauseEntity -> Rep ErrorRootCauseEntity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ErrorRootCauseEntity x -> ErrorRootCauseEntity
$cfrom :: forall x. ErrorRootCauseEntity -> Rep ErrorRootCauseEntity x
Prelude.Generic)

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

-- | The types and messages of the exceptions.
errorRootCauseEntity_exceptions :: Lens.Lens' ErrorRootCauseEntity (Prelude.Maybe [RootCauseException])
errorRootCauseEntity_exceptions :: Lens' ErrorRootCauseEntity (Maybe [RootCauseException])
errorRootCauseEntity_exceptions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ErrorRootCauseEntity' {Maybe [RootCauseException]
exceptions :: Maybe [RootCauseException]
$sel:exceptions:ErrorRootCauseEntity' :: ErrorRootCauseEntity -> Maybe [RootCauseException]
exceptions} -> Maybe [RootCauseException]
exceptions) (\s :: ErrorRootCauseEntity
s@ErrorRootCauseEntity' {} Maybe [RootCauseException]
a -> ErrorRootCauseEntity
s {$sel:exceptions:ErrorRootCauseEntity' :: Maybe [RootCauseException]
exceptions = Maybe [RootCauseException]
a} :: ErrorRootCauseEntity) 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.
errorRootCauseEntity_name :: Lens.Lens' ErrorRootCauseEntity (Prelude.Maybe Prelude.Text)
errorRootCauseEntity_name :: Lens' ErrorRootCauseEntity (Maybe Text)
errorRootCauseEntity_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ErrorRootCauseEntity' {Maybe Text
name :: Maybe Text
$sel:name:ErrorRootCauseEntity' :: ErrorRootCauseEntity -> Maybe Text
name} -> Maybe Text
name) (\s :: ErrorRootCauseEntity
s@ErrorRootCauseEntity' {} Maybe Text
a -> ErrorRootCauseEntity
s {$sel:name:ErrorRootCauseEntity' :: Maybe Text
name = Maybe Text
a} :: ErrorRootCauseEntity)

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

instance Data.FromJSON ErrorRootCauseEntity where
  parseJSON :: Value -> Parser ErrorRootCauseEntity
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ErrorRootCauseEntity"
      ( \Object
x ->
          Maybe [RootCauseException]
-> Maybe Text -> Maybe Bool -> ErrorRootCauseEntity
ErrorRootCauseEntity'
            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 ErrorRootCauseEntity where
  hashWithSalt :: Int -> ErrorRootCauseEntity -> Int
hashWithSalt Int
_salt ErrorRootCauseEntity' {Maybe Bool
Maybe [RootCauseException]
Maybe Text
remote :: Maybe Bool
name :: Maybe Text
exceptions :: Maybe [RootCauseException]
$sel:remote:ErrorRootCauseEntity' :: ErrorRootCauseEntity -> Maybe Bool
$sel:name:ErrorRootCauseEntity' :: ErrorRootCauseEntity -> Maybe Text
$sel:exceptions:ErrorRootCauseEntity' :: ErrorRootCauseEntity -> 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 ErrorRootCauseEntity where
  rnf :: ErrorRootCauseEntity -> ()
rnf ErrorRootCauseEntity' {Maybe Bool
Maybe [RootCauseException]
Maybe Text
remote :: Maybe Bool
name :: Maybe Text
exceptions :: Maybe [RootCauseException]
$sel:remote:ErrorRootCauseEntity' :: ErrorRootCauseEntity -> Maybe Bool
$sel:name:ErrorRootCauseEntity' :: ErrorRootCauseEntity -> Maybe Text
$sel:exceptions:ErrorRootCauseEntity' :: ErrorRootCauseEntity -> 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