{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.PutJobFailureResult
-- 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)
--
-- Represents the failure of a job as returned to the pipeline by a job
-- worker. Used for custom actions only.
module Amazonka.CodePipeline.PutJobFailureResult
  ( -- * Creating a Request
    PutJobFailureResult (..),
    newPutJobFailureResult,

    -- * Request Lenses
    putJobFailureResult_jobId,
    putJobFailureResult_failureDetails,

    -- * Destructuring the Response
    PutJobFailureResultResponse (..),
    newPutJobFailureResultResponse,
  )
where

import Amazonka.CodePipeline.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Represents the input of a @PutJobFailureResult@ action.
--
-- /See:/ 'newPutJobFailureResult' smart constructor.
data PutJobFailureResult = PutJobFailureResult'
  { -- | The unique system-generated ID of the job that failed. This is the same
    -- ID returned from @PollForJobs@.
    PutJobFailureResult -> Text
jobId :: Prelude.Text,
    -- | The details about the failure of a job.
    PutJobFailureResult -> FailureDetails
failureDetails :: FailureDetails
  }
  deriving (PutJobFailureResult -> PutJobFailureResult -> Bool
(PutJobFailureResult -> PutJobFailureResult -> Bool)
-> (PutJobFailureResult -> PutJobFailureResult -> Bool)
-> Eq PutJobFailureResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutJobFailureResult -> PutJobFailureResult -> Bool
$c/= :: PutJobFailureResult -> PutJobFailureResult -> Bool
== :: PutJobFailureResult -> PutJobFailureResult -> Bool
$c== :: PutJobFailureResult -> PutJobFailureResult -> Bool
Prelude.Eq, ReadPrec [PutJobFailureResult]
ReadPrec PutJobFailureResult
Int -> ReadS PutJobFailureResult
ReadS [PutJobFailureResult]
(Int -> ReadS PutJobFailureResult)
-> ReadS [PutJobFailureResult]
-> ReadPrec PutJobFailureResult
-> ReadPrec [PutJobFailureResult]
-> Read PutJobFailureResult
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutJobFailureResult]
$creadListPrec :: ReadPrec [PutJobFailureResult]
readPrec :: ReadPrec PutJobFailureResult
$creadPrec :: ReadPrec PutJobFailureResult
readList :: ReadS [PutJobFailureResult]
$creadList :: ReadS [PutJobFailureResult]
readsPrec :: Int -> ReadS PutJobFailureResult
$creadsPrec :: Int -> ReadS PutJobFailureResult
Prelude.Read, Int -> PutJobFailureResult -> ShowS
[PutJobFailureResult] -> ShowS
PutJobFailureResult -> String
(Int -> PutJobFailureResult -> ShowS)
-> (PutJobFailureResult -> String)
-> ([PutJobFailureResult] -> ShowS)
-> Show PutJobFailureResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutJobFailureResult] -> ShowS
$cshowList :: [PutJobFailureResult] -> ShowS
show :: PutJobFailureResult -> String
$cshow :: PutJobFailureResult -> String
showsPrec :: Int -> PutJobFailureResult -> ShowS
$cshowsPrec :: Int -> PutJobFailureResult -> ShowS
Prelude.Show, (forall x. PutJobFailureResult -> Rep PutJobFailureResult x)
-> (forall x. Rep PutJobFailureResult x -> PutJobFailureResult)
-> Generic PutJobFailureResult
forall x. Rep PutJobFailureResult x -> PutJobFailureResult
forall x. PutJobFailureResult -> Rep PutJobFailureResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutJobFailureResult x -> PutJobFailureResult
$cfrom :: forall x. PutJobFailureResult -> Rep PutJobFailureResult x
Prelude.Generic)

-- |
-- Create a value of 'PutJobFailureResult' 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:
--
-- 'jobId', 'putJobFailureResult_jobId' - The unique system-generated ID of the job that failed. This is the same
-- ID returned from @PollForJobs@.
--
-- 'failureDetails', 'putJobFailureResult_failureDetails' - The details about the failure of a job.
newPutJobFailureResult ::
  -- | 'jobId'
  Prelude.Text ->
  -- | 'failureDetails'
  FailureDetails ->
  PutJobFailureResult
newPutJobFailureResult :: Text -> FailureDetails -> PutJobFailureResult
newPutJobFailureResult Text
pJobId_ FailureDetails
pFailureDetails_ =
  PutJobFailureResult' :: Text -> FailureDetails -> PutJobFailureResult
PutJobFailureResult'
    { $sel:jobId:PutJobFailureResult' :: Text
jobId = Text
pJobId_,
      $sel:failureDetails:PutJobFailureResult' :: FailureDetails
failureDetails = FailureDetails
pFailureDetails_
    }

-- | The unique system-generated ID of the job that failed. This is the same
-- ID returned from @PollForJobs@.
putJobFailureResult_jobId :: Lens.Lens' PutJobFailureResult Prelude.Text
putJobFailureResult_jobId :: (Text -> f Text) -> PutJobFailureResult -> f PutJobFailureResult
putJobFailureResult_jobId = (PutJobFailureResult -> Text)
-> (PutJobFailureResult -> Text -> PutJobFailureResult)
-> Lens PutJobFailureResult PutJobFailureResult Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutJobFailureResult' {Text
jobId :: Text
$sel:jobId:PutJobFailureResult' :: PutJobFailureResult -> Text
jobId} -> Text
jobId) (\s :: PutJobFailureResult
s@PutJobFailureResult' {} Text
a -> PutJobFailureResult
s {$sel:jobId:PutJobFailureResult' :: Text
jobId = Text
a} :: PutJobFailureResult)

-- | The details about the failure of a job.
putJobFailureResult_failureDetails :: Lens.Lens' PutJobFailureResult FailureDetails
putJobFailureResult_failureDetails :: (FailureDetails -> f FailureDetails)
-> PutJobFailureResult -> f PutJobFailureResult
putJobFailureResult_failureDetails = (PutJobFailureResult -> FailureDetails)
-> (PutJobFailureResult -> FailureDetails -> PutJobFailureResult)
-> Lens
     PutJobFailureResult
     PutJobFailureResult
     FailureDetails
     FailureDetails
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutJobFailureResult' {FailureDetails
failureDetails :: FailureDetails
$sel:failureDetails:PutJobFailureResult' :: PutJobFailureResult -> FailureDetails
failureDetails} -> FailureDetails
failureDetails) (\s :: PutJobFailureResult
s@PutJobFailureResult' {} FailureDetails
a -> PutJobFailureResult
s {$sel:failureDetails:PutJobFailureResult' :: FailureDetails
failureDetails = FailureDetails
a} :: PutJobFailureResult)

instance Core.AWSRequest PutJobFailureResult where
  type
    AWSResponse PutJobFailureResult =
      PutJobFailureResultResponse
  request :: PutJobFailureResult -> Request PutJobFailureResult
request = Service -> PutJobFailureResult -> Request PutJobFailureResult
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PutJobFailureResult
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutJobFailureResult)))
response =
    AWSResponse PutJobFailureResult
-> Logger
-> Service
-> Proxy PutJobFailureResult
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutJobFailureResult)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse PutJobFailureResult
PutJobFailureResultResponse
PutJobFailureResultResponse'

instance Prelude.Hashable PutJobFailureResult

instance Prelude.NFData PutJobFailureResult

instance Core.ToHeaders PutJobFailureResult where
  toHeaders :: PutJobFailureResult -> [Header]
toHeaders =
    [Header] -> PutJobFailureResult -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"CodePipeline_20150709.PutJobFailureResult" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON PutJobFailureResult where
  toJSON :: PutJobFailureResult -> Value
toJSON PutJobFailureResult' {Text
FailureDetails
failureDetails :: FailureDetails
jobId :: Text
$sel:failureDetails:PutJobFailureResult' :: PutJobFailureResult -> FailureDetails
$sel:jobId:PutJobFailureResult' :: PutJobFailureResult -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"jobId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
jobId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"failureDetails" Text -> FailureDetails -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= FailureDetails
failureDetails)
          ]
      )

instance Core.ToPath PutJobFailureResult where
  toPath :: PutJobFailureResult -> ByteString
toPath = ByteString -> PutJobFailureResult -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery PutJobFailureResult where
  toQuery :: PutJobFailureResult -> QueryString
toQuery = QueryString -> PutJobFailureResult -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newPutJobFailureResultResponse' smart constructor.
data PutJobFailureResultResponse = PutJobFailureResultResponse'
  {
  }
  deriving (PutJobFailureResultResponse -> PutJobFailureResultResponse -> Bool
(PutJobFailureResultResponse
 -> PutJobFailureResultResponse -> Bool)
-> (PutJobFailureResultResponse
    -> PutJobFailureResultResponse -> Bool)
-> Eq PutJobFailureResultResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutJobFailureResultResponse -> PutJobFailureResultResponse -> Bool
$c/= :: PutJobFailureResultResponse -> PutJobFailureResultResponse -> Bool
== :: PutJobFailureResultResponse -> PutJobFailureResultResponse -> Bool
$c== :: PutJobFailureResultResponse -> PutJobFailureResultResponse -> Bool
Prelude.Eq, ReadPrec [PutJobFailureResultResponse]
ReadPrec PutJobFailureResultResponse
Int -> ReadS PutJobFailureResultResponse
ReadS [PutJobFailureResultResponse]
(Int -> ReadS PutJobFailureResultResponse)
-> ReadS [PutJobFailureResultResponse]
-> ReadPrec PutJobFailureResultResponse
-> ReadPrec [PutJobFailureResultResponse]
-> Read PutJobFailureResultResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutJobFailureResultResponse]
$creadListPrec :: ReadPrec [PutJobFailureResultResponse]
readPrec :: ReadPrec PutJobFailureResultResponse
$creadPrec :: ReadPrec PutJobFailureResultResponse
readList :: ReadS [PutJobFailureResultResponse]
$creadList :: ReadS [PutJobFailureResultResponse]
readsPrec :: Int -> ReadS PutJobFailureResultResponse
$creadsPrec :: Int -> ReadS PutJobFailureResultResponse
Prelude.Read, Int -> PutJobFailureResultResponse -> ShowS
[PutJobFailureResultResponse] -> ShowS
PutJobFailureResultResponse -> String
(Int -> PutJobFailureResultResponse -> ShowS)
-> (PutJobFailureResultResponse -> String)
-> ([PutJobFailureResultResponse] -> ShowS)
-> Show PutJobFailureResultResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutJobFailureResultResponse] -> ShowS
$cshowList :: [PutJobFailureResultResponse] -> ShowS
show :: PutJobFailureResultResponse -> String
$cshow :: PutJobFailureResultResponse -> String
showsPrec :: Int -> PutJobFailureResultResponse -> ShowS
$cshowsPrec :: Int -> PutJobFailureResultResponse -> ShowS
Prelude.Show, (forall x.
 PutJobFailureResultResponse -> Rep PutJobFailureResultResponse x)
-> (forall x.
    Rep PutJobFailureResultResponse x -> PutJobFailureResultResponse)
-> Generic PutJobFailureResultResponse
forall x.
Rep PutJobFailureResultResponse x -> PutJobFailureResultResponse
forall x.
PutJobFailureResultResponse -> Rep PutJobFailureResultResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutJobFailureResultResponse x -> PutJobFailureResultResponse
$cfrom :: forall x.
PutJobFailureResultResponse -> Rep PutJobFailureResultResponse x
Prelude.Generic)

-- |
-- Create a value of 'PutJobFailureResultResponse' 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.
newPutJobFailureResultResponse ::
  PutJobFailureResultResponse
newPutJobFailureResultResponse :: PutJobFailureResultResponse
newPutJobFailureResultResponse =
  PutJobFailureResultResponse
PutJobFailureResultResponse'

instance Prelude.NFData PutJobFailureResultResponse