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

import Amazonka.CodePipeline.Types.FailureType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents information about failure details.
--
-- /See:/ 'newFailureDetails' smart constructor.
data FailureDetails = FailureDetails'
  { -- | The external ID of the run of the action that failed.
    FailureDetails -> Maybe Text
externalExecutionId :: Prelude.Maybe Prelude.Text,
    -- | The type of the failure.
    FailureDetails -> FailureType
type' :: FailureType,
    -- | The message about the failure.
    FailureDetails -> Text
message :: 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:
--
-- 'externalExecutionId', 'failureDetails_externalExecutionId' - The external ID of the run of the action that failed.
--
-- 'type'', 'failureDetails_type' - The type of the failure.
--
-- 'message', 'failureDetails_message' - The message about the failure.
newFailureDetails ::
  -- | 'type''
  FailureType ->
  -- | 'message'
  Prelude.Text ->
  FailureDetails
newFailureDetails :: FailureType -> Text -> FailureDetails
newFailureDetails FailureType
pType_ Text
pMessage_ =
  FailureDetails' :: Maybe Text -> FailureType -> Text -> FailureDetails
FailureDetails'
    { $sel:externalExecutionId:FailureDetails' :: Maybe Text
externalExecutionId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':FailureDetails' :: FailureType
type' = FailureType
pType_,
      $sel:message:FailureDetails' :: Text
message = Text
pMessage_
    }

-- | The external ID of the run of the action that failed.
failureDetails_externalExecutionId :: Lens.Lens' FailureDetails (Prelude.Maybe Prelude.Text)
failureDetails_externalExecutionId :: (Maybe Text -> f (Maybe Text))
-> FailureDetails -> f FailureDetails
failureDetails_externalExecutionId = (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
externalExecutionId :: Maybe Text
$sel:externalExecutionId:FailureDetails' :: FailureDetails -> Maybe Text
externalExecutionId} -> Maybe Text
externalExecutionId) (\s :: FailureDetails
s@FailureDetails' {} Maybe Text
a -> FailureDetails
s {$sel:externalExecutionId:FailureDetails' :: Maybe Text
externalExecutionId = Maybe Text
a} :: FailureDetails)

-- | The type of the failure.
failureDetails_type :: Lens.Lens' FailureDetails FailureType
failureDetails_type :: (FailureType -> f FailureType)
-> FailureDetails -> f FailureDetails
failureDetails_type = (FailureDetails -> FailureType)
-> (FailureDetails -> FailureType -> FailureDetails)
-> Lens FailureDetails FailureDetails FailureType FailureType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailureDetails' {FailureType
type' :: FailureType
$sel:type':FailureDetails' :: FailureDetails -> FailureType
type'} -> FailureType
type') (\s :: FailureDetails
s@FailureDetails' {} FailureType
a -> FailureDetails
s {$sel:type':FailureDetails' :: FailureType
type' = FailureType
a} :: FailureDetails)

-- | The message about the failure.
failureDetails_message :: Lens.Lens' FailureDetails Prelude.Text
failureDetails_message :: (Text -> f Text) -> FailureDetails -> f FailureDetails
failureDetails_message = (FailureDetails -> Text)
-> (FailureDetails -> Text -> FailureDetails)
-> Lens FailureDetails FailureDetails Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailureDetails' {Text
message :: Text
$sel:message:FailureDetails' :: FailureDetails -> Text
message} -> Text
message) (\s :: FailureDetails
s@FailureDetails' {} Text
a -> FailureDetails
s {$sel:message:FailureDetails' :: Text
message = Text
a} :: FailureDetails)

instance Prelude.Hashable FailureDetails

instance Prelude.NFData FailureDetails

instance Core.ToJSON FailureDetails where
  toJSON :: FailureDetails -> Value
toJSON FailureDetails' {Maybe Text
Text
FailureType
message :: Text
type' :: FailureType
externalExecutionId :: Maybe Text
$sel:message:FailureDetails' :: FailureDetails -> Text
$sel:type':FailureDetails' :: FailureDetails -> FailureType
$sel:externalExecutionId:FailureDetails' :: FailureDetails -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"externalExecutionId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
externalExecutionId,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"type" Text -> FailureType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= FailureType
type'),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"message" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
message)
          ]
      )