{-# 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.EMR.Types.FailureDetails
-- 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.EMR.Types.FailureDetails where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The details of the step failure. The service attempts to detect the root
-- cause for many common failures.
--
-- /See:/ 'newFailureDetails' smart constructor.
data FailureDetails = FailureDetails'
  { -- | The path to the log file where the step failure root cause was
    -- originally recorded.
    FailureDetails -> Maybe Text
logFile :: Prelude.Maybe Prelude.Text,
    -- | The reason for the step failure. In the case where the service cannot
    -- successfully determine the root cause of the failure, it returns
    -- \"Unknown Error\" as a reason.
    FailureDetails -> Maybe Text
reason :: Prelude.Maybe Prelude.Text,
    -- | The descriptive message including the error the Amazon EMR service has
    -- identified as the cause of step failure. This is text from an error log
    -- that describes the root cause of the failure.
    FailureDetails -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (FailureDetails -> FailureDetails -> Bool
(FailureDetails -> FailureDetails -> Bool)
-> (FailureDetails -> FailureDetails -> Bool) -> Eq FailureDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FailureDetails -> FailureDetails -> Bool
$c/= :: FailureDetails -> FailureDetails -> Bool
== :: FailureDetails -> FailureDetails -> Bool
$c== :: FailureDetails -> FailureDetails -> Bool
Prelude.Eq, ReadPrec [FailureDetails]
ReadPrec FailureDetails
Int -> ReadS FailureDetails
ReadS [FailureDetails]
(Int -> ReadS FailureDetails)
-> ReadS [FailureDetails]
-> ReadPrec FailureDetails
-> ReadPrec [FailureDetails]
-> Read FailureDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FailureDetails]
$creadListPrec :: ReadPrec [FailureDetails]
readPrec :: ReadPrec FailureDetails
$creadPrec :: ReadPrec FailureDetails
readList :: ReadS [FailureDetails]
$creadList :: ReadS [FailureDetails]
readsPrec :: Int -> ReadS FailureDetails
$creadsPrec :: Int -> ReadS FailureDetails
Prelude.Read, Int -> FailureDetails -> ShowS
[FailureDetails] -> ShowS
FailureDetails -> String
(Int -> FailureDetails -> ShowS)
-> (FailureDetails -> String)
-> ([FailureDetails] -> ShowS)
-> Show FailureDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FailureDetails] -> ShowS
$cshowList :: [FailureDetails] -> ShowS
show :: FailureDetails -> String
$cshow :: FailureDetails -> String
showsPrec :: Int -> FailureDetails -> ShowS
$cshowsPrec :: Int -> FailureDetails -> ShowS
Prelude.Show, (forall x. FailureDetails -> Rep FailureDetails x)
-> (forall x. Rep FailureDetails x -> FailureDetails)
-> Generic FailureDetails
forall x. Rep FailureDetails x -> FailureDetails
forall x. FailureDetails -> Rep FailureDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FailureDetails x -> FailureDetails
$cfrom :: forall x. FailureDetails -> Rep FailureDetails x
Prelude.Generic)

-- |
-- Create a value of 'FailureDetails' 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:
--
-- 'logFile', 'failureDetails_logFile' - The path to the log file where the step failure root cause was
-- originally recorded.
--
-- 'reason', 'failureDetails_reason' - The reason for the step failure. In the case where the service cannot
-- successfully determine the root cause of the failure, it returns
-- \"Unknown Error\" as a reason.
--
-- 'message', 'failureDetails_message' - The descriptive message including the error the Amazon EMR service has
-- identified as the cause of step failure. This is text from an error log
-- that describes the root cause of the failure.
newFailureDetails ::
  FailureDetails
newFailureDetails :: FailureDetails
newFailureDetails =
  FailureDetails' :: Maybe Text -> Maybe Text -> Maybe Text -> FailureDetails
FailureDetails'
    { $sel:logFile:FailureDetails' :: Maybe Text
logFile = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:reason:FailureDetails' :: Maybe Text
reason = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:message:FailureDetails' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The path to the log file where the step failure root cause was
-- originally recorded.
failureDetails_logFile :: Lens.Lens' FailureDetails (Prelude.Maybe Prelude.Text)
failureDetails_logFile :: (Maybe Text -> f (Maybe Text))
-> FailureDetails -> f FailureDetails
failureDetails_logFile = (FailureDetails -> Maybe Text)
-> (FailureDetails -> Maybe Text -> FailureDetails)
-> Lens FailureDetails FailureDetails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailureDetails' {Maybe Text
logFile :: Maybe Text
$sel:logFile:FailureDetails' :: FailureDetails -> Maybe Text
logFile} -> Maybe Text
logFile) (\s :: FailureDetails
s@FailureDetails' {} Maybe Text
a -> FailureDetails
s {$sel:logFile:FailureDetails' :: Maybe Text
logFile = Maybe Text
a} :: FailureDetails)

-- | The reason for the step failure. In the case where the service cannot
-- successfully determine the root cause of the failure, it returns
-- \"Unknown Error\" as a reason.
failureDetails_reason :: Lens.Lens' FailureDetails (Prelude.Maybe Prelude.Text)
failureDetails_reason :: (Maybe Text -> f (Maybe Text))
-> FailureDetails -> f FailureDetails
failureDetails_reason = (FailureDetails -> Maybe Text)
-> (FailureDetails -> Maybe Text -> FailureDetails)
-> Lens FailureDetails FailureDetails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailureDetails' {Maybe Text
reason :: Maybe Text
$sel:reason:FailureDetails' :: FailureDetails -> Maybe Text
reason} -> Maybe Text
reason) (\s :: FailureDetails
s@FailureDetails' {} Maybe Text
a -> FailureDetails
s {$sel:reason:FailureDetails' :: Maybe Text
reason = Maybe Text
a} :: FailureDetails)

-- | The descriptive message including the error the Amazon EMR service has
-- identified as the cause of step failure. This is text from an error log
-- that describes the root cause of the failure.
failureDetails_message :: Lens.Lens' FailureDetails (Prelude.Maybe Prelude.Text)
failureDetails_message :: (Maybe Text -> f (Maybe Text))
-> FailureDetails -> f FailureDetails
failureDetails_message = (FailureDetails -> Maybe Text)
-> (FailureDetails -> Maybe Text -> FailureDetails)
-> Lens FailureDetails FailureDetails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailureDetails' {Maybe Text
message :: Maybe Text
$sel:message:FailureDetails' :: FailureDetails -> Maybe Text
message} -> Maybe Text
message) (\s :: FailureDetails
s@FailureDetails' {} Maybe Text
a -> FailureDetails
s {$sel:message:FailureDetails' :: Maybe Text
message = Maybe Text
a} :: FailureDetails)

instance Core.FromJSON FailureDetails where
  parseJSON :: Value -> Parser FailureDetails
parseJSON =
    String
-> (Object -> Parser FailureDetails)
-> Value
-> Parser FailureDetails
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FailureDetails"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> FailureDetails
FailureDetails'
            (Maybe Text -> Maybe Text -> Maybe Text -> FailureDetails)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> FailureDetails)
forall (f :: * -> *) a b. Functor 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
"LogFile")
            Parser (Maybe Text -> Maybe Text -> FailureDetails)
-> Parser (Maybe Text) -> Parser (Maybe Text -> FailureDetails)
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
"Reason")
            Parser (Maybe Text -> FailureDetails)
-> Parser (Maybe Text) -> Parser FailureDetails
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
"Message")
      )

instance Prelude.Hashable FailureDetails

instance Prelude.NFData FailureDetails