{-# 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-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.ErrorRootCauseEntity 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 error.
--
-- /See:/ 'newErrorRootCauseEntity' smart constructor.
data ErrorRootCauseEntity = ErrorRootCauseEntity'
  { -- | The types and messages of the exceptions.
    ErrorRootCauseEntity -> Maybe [RootCauseException]
exceptions :: Prelude.Maybe [RootCauseException],
    -- | A flag that denotes a remote subsegment.
    ErrorRootCauseEntity -> Maybe Bool
remote :: Prelude.Maybe Prelude.Bool,
    -- | The name of the entity.
    ErrorRootCauseEntity -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (ErrorRootCauseEntity -> ErrorRootCauseEntity -> Bool
(ErrorRootCauseEntity -> ErrorRootCauseEntity -> Bool)
-> (ErrorRootCauseEntity -> ErrorRootCauseEntity -> Bool)
-> Eq ErrorRootCauseEntity
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]
(Int -> ReadS ErrorRootCauseEntity)
-> ReadS [ErrorRootCauseEntity]
-> ReadPrec ErrorRootCauseEntity
-> ReadPrec [ErrorRootCauseEntity]
-> Read 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
(Int -> ErrorRootCauseEntity -> ShowS)
-> (ErrorRootCauseEntity -> String)
-> ([ErrorRootCauseEntity] -> ShowS)
-> Show ErrorRootCauseEntity
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. ErrorRootCauseEntity -> Rep ErrorRootCauseEntity x)
-> (forall x. Rep ErrorRootCauseEntity x -> ErrorRootCauseEntity)
-> Generic ErrorRootCauseEntity
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.
--
-- 'remote', 'errorRootCauseEntity_remote' - A flag that denotes a remote subsegment.
--
-- 'name', 'errorRootCauseEntity_name' - The name of the entity.
newErrorRootCauseEntity ::
  ErrorRootCauseEntity
newErrorRootCauseEntity :: ErrorRootCauseEntity
newErrorRootCauseEntity =
  ErrorRootCauseEntity' :: Maybe [RootCauseException]
-> Maybe Bool -> Maybe Text -> ErrorRootCauseEntity
ErrorRootCauseEntity'
    { $sel:exceptions:ErrorRootCauseEntity' :: Maybe [RootCauseException]
exceptions = Maybe [RootCauseException]
forall a. Maybe a
Prelude.Nothing,
      $sel:remote:ErrorRootCauseEntity' :: Maybe Bool
remote = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:name:ErrorRootCauseEntity' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The types and messages of the exceptions.
errorRootCauseEntity_exceptions :: Lens.Lens' ErrorRootCauseEntity (Prelude.Maybe [RootCauseException])
errorRootCauseEntity_exceptions :: (Maybe [RootCauseException] -> f (Maybe [RootCauseException]))
-> ErrorRootCauseEntity -> f ErrorRootCauseEntity
errorRootCauseEntity_exceptions = (ErrorRootCauseEntity -> Maybe [RootCauseException])
-> (ErrorRootCauseEntity
    -> Maybe [RootCauseException] -> ErrorRootCauseEntity)
-> Lens
     ErrorRootCauseEntity
     ErrorRootCauseEntity
     (Maybe [RootCauseException])
     (Maybe [RootCauseException])
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) ((Maybe [RootCauseException] -> f (Maybe [RootCauseException]))
 -> ErrorRootCauseEntity -> f ErrorRootCauseEntity)
-> ((Maybe [RootCauseException] -> f (Maybe [RootCauseException]))
    -> Maybe [RootCauseException] -> f (Maybe [RootCauseException]))
-> (Maybe [RootCauseException] -> f (Maybe [RootCauseException]))
-> ErrorRootCauseEntity
-> f ErrorRootCauseEntity
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.
errorRootCauseEntity_remote :: Lens.Lens' ErrorRootCauseEntity (Prelude.Maybe Prelude.Bool)
errorRootCauseEntity_remote :: (Maybe Bool -> f (Maybe Bool))
-> ErrorRootCauseEntity -> f ErrorRootCauseEntity
errorRootCauseEntity_remote = (ErrorRootCauseEntity -> Maybe Bool)
-> (ErrorRootCauseEntity -> Maybe Bool -> ErrorRootCauseEntity)
-> Lens
     ErrorRootCauseEntity ErrorRootCauseEntity (Maybe Bool) (Maybe Bool)
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)

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

instance Core.FromJSON ErrorRootCauseEntity where
  parseJSON :: Value -> Parser ErrorRootCauseEntity
parseJSON =
    String
-> (Object -> Parser ErrorRootCauseEntity)
-> Value
-> Parser ErrorRootCauseEntity
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ErrorRootCauseEntity"
      ( \Object
x ->
          Maybe [RootCauseException]
-> Maybe Bool -> Maybe Text -> ErrorRootCauseEntity
ErrorRootCauseEntity'
            (Maybe [RootCauseException]
 -> Maybe Bool -> Maybe Text -> ErrorRootCauseEntity)
-> Parser (Maybe [RootCauseException])
-> Parser (Maybe Bool -> Maybe Text -> ErrorRootCauseEntity)
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 -> ErrorRootCauseEntity)
-> Parser (Maybe Bool)
-> Parser (Maybe Text -> ErrorRootCauseEntity)
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 -> ErrorRootCauseEntity)
-> Parser (Maybe Text) -> Parser ErrorRootCauseEntity
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 ErrorRootCauseEntity

instance Prelude.NFData ErrorRootCauseEntity