{-# 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.GetThirdPartyJobDetails
-- 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)
--
-- Requests the details of a job for a third party action. Used for partner
-- actions only.
--
-- When this API is called, AWS CodePipeline returns temporary credentials
-- for the S3 bucket used to store artifacts for the pipeline, if the
-- action requires access to that S3 bucket for input or output artifacts.
-- This API also returns any secret values defined for the action.
module Amazonka.CodePipeline.GetThirdPartyJobDetails
  ( -- * Creating a Request
    GetThirdPartyJobDetails (..),
    newGetThirdPartyJobDetails,

    -- * Request Lenses
    getThirdPartyJobDetails_jobId,
    getThirdPartyJobDetails_clientToken,

    -- * Destructuring the Response
    GetThirdPartyJobDetailsResponse (..),
    newGetThirdPartyJobDetailsResponse,

    -- * Response Lenses
    getThirdPartyJobDetailsResponse_jobDetails,
    getThirdPartyJobDetailsResponse_httpStatus,
  )
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 @GetThirdPartyJobDetails@ action.
--
-- /See:/ 'newGetThirdPartyJobDetails' smart constructor.
data GetThirdPartyJobDetails = GetThirdPartyJobDetails'
  { -- | The unique system-generated ID used for identifying the job.
    GetThirdPartyJobDetails -> Text
jobId :: Prelude.Text,
    -- | The clientToken portion of the clientId and clientToken pair used to
    -- verify that the calling entity is allowed access to the job and its
    -- details.
    GetThirdPartyJobDetails -> Text
clientToken :: Prelude.Text
  }
  deriving (GetThirdPartyJobDetails -> GetThirdPartyJobDetails -> Bool
(GetThirdPartyJobDetails -> GetThirdPartyJobDetails -> Bool)
-> (GetThirdPartyJobDetails -> GetThirdPartyJobDetails -> Bool)
-> Eq GetThirdPartyJobDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetThirdPartyJobDetails -> GetThirdPartyJobDetails -> Bool
$c/= :: GetThirdPartyJobDetails -> GetThirdPartyJobDetails -> Bool
== :: GetThirdPartyJobDetails -> GetThirdPartyJobDetails -> Bool
$c== :: GetThirdPartyJobDetails -> GetThirdPartyJobDetails -> Bool
Prelude.Eq, ReadPrec [GetThirdPartyJobDetails]
ReadPrec GetThirdPartyJobDetails
Int -> ReadS GetThirdPartyJobDetails
ReadS [GetThirdPartyJobDetails]
(Int -> ReadS GetThirdPartyJobDetails)
-> ReadS [GetThirdPartyJobDetails]
-> ReadPrec GetThirdPartyJobDetails
-> ReadPrec [GetThirdPartyJobDetails]
-> Read GetThirdPartyJobDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetThirdPartyJobDetails]
$creadListPrec :: ReadPrec [GetThirdPartyJobDetails]
readPrec :: ReadPrec GetThirdPartyJobDetails
$creadPrec :: ReadPrec GetThirdPartyJobDetails
readList :: ReadS [GetThirdPartyJobDetails]
$creadList :: ReadS [GetThirdPartyJobDetails]
readsPrec :: Int -> ReadS GetThirdPartyJobDetails
$creadsPrec :: Int -> ReadS GetThirdPartyJobDetails
Prelude.Read, Int -> GetThirdPartyJobDetails -> ShowS
[GetThirdPartyJobDetails] -> ShowS
GetThirdPartyJobDetails -> String
(Int -> GetThirdPartyJobDetails -> ShowS)
-> (GetThirdPartyJobDetails -> String)
-> ([GetThirdPartyJobDetails] -> ShowS)
-> Show GetThirdPartyJobDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetThirdPartyJobDetails] -> ShowS
$cshowList :: [GetThirdPartyJobDetails] -> ShowS
show :: GetThirdPartyJobDetails -> String
$cshow :: GetThirdPartyJobDetails -> String
showsPrec :: Int -> GetThirdPartyJobDetails -> ShowS
$cshowsPrec :: Int -> GetThirdPartyJobDetails -> ShowS
Prelude.Show, (forall x.
 GetThirdPartyJobDetails -> Rep GetThirdPartyJobDetails x)
-> (forall x.
    Rep GetThirdPartyJobDetails x -> GetThirdPartyJobDetails)
-> Generic GetThirdPartyJobDetails
forall x. Rep GetThirdPartyJobDetails x -> GetThirdPartyJobDetails
forall x. GetThirdPartyJobDetails -> Rep GetThirdPartyJobDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetThirdPartyJobDetails x -> GetThirdPartyJobDetails
$cfrom :: forall x. GetThirdPartyJobDetails -> Rep GetThirdPartyJobDetails x
Prelude.Generic)

-- |
-- Create a value of 'GetThirdPartyJobDetails' 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', 'getThirdPartyJobDetails_jobId' - The unique system-generated ID used for identifying the job.
--
-- 'clientToken', 'getThirdPartyJobDetails_clientToken' - The clientToken portion of the clientId and clientToken pair used to
-- verify that the calling entity is allowed access to the job and its
-- details.
newGetThirdPartyJobDetails ::
  -- | 'jobId'
  Prelude.Text ->
  -- | 'clientToken'
  Prelude.Text ->
  GetThirdPartyJobDetails
newGetThirdPartyJobDetails :: Text -> Text -> GetThirdPartyJobDetails
newGetThirdPartyJobDetails Text
pJobId_ Text
pClientToken_ =
  GetThirdPartyJobDetails' :: Text -> Text -> GetThirdPartyJobDetails
GetThirdPartyJobDetails'
    { $sel:jobId:GetThirdPartyJobDetails' :: Text
jobId = Text
pJobId_,
      $sel:clientToken:GetThirdPartyJobDetails' :: Text
clientToken = Text
pClientToken_
    }

-- | The unique system-generated ID used for identifying the job.
getThirdPartyJobDetails_jobId :: Lens.Lens' GetThirdPartyJobDetails Prelude.Text
getThirdPartyJobDetails_jobId :: (Text -> f Text)
-> GetThirdPartyJobDetails -> f GetThirdPartyJobDetails
getThirdPartyJobDetails_jobId = (GetThirdPartyJobDetails -> Text)
-> (GetThirdPartyJobDetails -> Text -> GetThirdPartyJobDetails)
-> Lens GetThirdPartyJobDetails GetThirdPartyJobDetails Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetThirdPartyJobDetails' {Text
jobId :: Text
$sel:jobId:GetThirdPartyJobDetails' :: GetThirdPartyJobDetails -> Text
jobId} -> Text
jobId) (\s :: GetThirdPartyJobDetails
s@GetThirdPartyJobDetails' {} Text
a -> GetThirdPartyJobDetails
s {$sel:jobId:GetThirdPartyJobDetails' :: Text
jobId = Text
a} :: GetThirdPartyJobDetails)

-- | The clientToken portion of the clientId and clientToken pair used to
-- verify that the calling entity is allowed access to the job and its
-- details.
getThirdPartyJobDetails_clientToken :: Lens.Lens' GetThirdPartyJobDetails Prelude.Text
getThirdPartyJobDetails_clientToken :: (Text -> f Text)
-> GetThirdPartyJobDetails -> f GetThirdPartyJobDetails
getThirdPartyJobDetails_clientToken = (GetThirdPartyJobDetails -> Text)
-> (GetThirdPartyJobDetails -> Text -> GetThirdPartyJobDetails)
-> Lens GetThirdPartyJobDetails GetThirdPartyJobDetails Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetThirdPartyJobDetails' {Text
clientToken :: Text
$sel:clientToken:GetThirdPartyJobDetails' :: GetThirdPartyJobDetails -> Text
clientToken} -> Text
clientToken) (\s :: GetThirdPartyJobDetails
s@GetThirdPartyJobDetails' {} Text
a -> GetThirdPartyJobDetails
s {$sel:clientToken:GetThirdPartyJobDetails' :: Text
clientToken = Text
a} :: GetThirdPartyJobDetails)

instance Core.AWSRequest GetThirdPartyJobDetails where
  type
    AWSResponse GetThirdPartyJobDetails =
      GetThirdPartyJobDetailsResponse
  request :: GetThirdPartyJobDetails -> Request GetThirdPartyJobDetails
request = Service
-> GetThirdPartyJobDetails -> Request GetThirdPartyJobDetails
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetThirdPartyJobDetails
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetThirdPartyJobDetails)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetThirdPartyJobDetails))
-> Logger
-> Service
-> Proxy GetThirdPartyJobDetails
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetThirdPartyJobDetails)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe ThirdPartyJobDetails
-> Int -> GetThirdPartyJobDetailsResponse
GetThirdPartyJobDetailsResponse'
            (Maybe ThirdPartyJobDetails
 -> Int -> GetThirdPartyJobDetailsResponse)
-> Either String (Maybe ThirdPartyJobDetails)
-> Either String (Int -> GetThirdPartyJobDetailsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe ThirdPartyJobDetails)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"jobDetails")
            Either String (Int -> GetThirdPartyJobDetailsResponse)
-> Either String Int
-> Either String GetThirdPartyJobDetailsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetThirdPartyJobDetails

instance Prelude.NFData GetThirdPartyJobDetails

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

instance Core.ToJSON GetThirdPartyJobDetails where
  toJSON :: GetThirdPartyJobDetails -> Value
toJSON GetThirdPartyJobDetails' {Text
clientToken :: Text
jobId :: Text
$sel:clientToken:GetThirdPartyJobDetails' :: GetThirdPartyJobDetails -> Text
$sel:jobId:GetThirdPartyJobDetails' :: GetThirdPartyJobDetails -> 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
"clientToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
clientToken)
          ]
      )

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

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

-- | Represents the output of a @GetThirdPartyJobDetails@ action.
--
-- /See:/ 'newGetThirdPartyJobDetailsResponse' smart constructor.
data GetThirdPartyJobDetailsResponse = GetThirdPartyJobDetailsResponse'
  { -- | The details of the job, including any protected values defined for the
    -- job.
    GetThirdPartyJobDetailsResponse -> Maybe ThirdPartyJobDetails
jobDetails :: Prelude.Maybe ThirdPartyJobDetails,
    -- | The response's http status code.
    GetThirdPartyJobDetailsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetThirdPartyJobDetailsResponse
-> GetThirdPartyJobDetailsResponse -> Bool
(GetThirdPartyJobDetailsResponse
 -> GetThirdPartyJobDetailsResponse -> Bool)
-> (GetThirdPartyJobDetailsResponse
    -> GetThirdPartyJobDetailsResponse -> Bool)
-> Eq GetThirdPartyJobDetailsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetThirdPartyJobDetailsResponse
-> GetThirdPartyJobDetailsResponse -> Bool
$c/= :: GetThirdPartyJobDetailsResponse
-> GetThirdPartyJobDetailsResponse -> Bool
== :: GetThirdPartyJobDetailsResponse
-> GetThirdPartyJobDetailsResponse -> Bool
$c== :: GetThirdPartyJobDetailsResponse
-> GetThirdPartyJobDetailsResponse -> Bool
Prelude.Eq, Int -> GetThirdPartyJobDetailsResponse -> ShowS
[GetThirdPartyJobDetailsResponse] -> ShowS
GetThirdPartyJobDetailsResponse -> String
(Int -> GetThirdPartyJobDetailsResponse -> ShowS)
-> (GetThirdPartyJobDetailsResponse -> String)
-> ([GetThirdPartyJobDetailsResponse] -> ShowS)
-> Show GetThirdPartyJobDetailsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetThirdPartyJobDetailsResponse] -> ShowS
$cshowList :: [GetThirdPartyJobDetailsResponse] -> ShowS
show :: GetThirdPartyJobDetailsResponse -> String
$cshow :: GetThirdPartyJobDetailsResponse -> String
showsPrec :: Int -> GetThirdPartyJobDetailsResponse -> ShowS
$cshowsPrec :: Int -> GetThirdPartyJobDetailsResponse -> ShowS
Prelude.Show, (forall x.
 GetThirdPartyJobDetailsResponse
 -> Rep GetThirdPartyJobDetailsResponse x)
-> (forall x.
    Rep GetThirdPartyJobDetailsResponse x
    -> GetThirdPartyJobDetailsResponse)
-> Generic GetThirdPartyJobDetailsResponse
forall x.
Rep GetThirdPartyJobDetailsResponse x
-> GetThirdPartyJobDetailsResponse
forall x.
GetThirdPartyJobDetailsResponse
-> Rep GetThirdPartyJobDetailsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetThirdPartyJobDetailsResponse x
-> GetThirdPartyJobDetailsResponse
$cfrom :: forall x.
GetThirdPartyJobDetailsResponse
-> Rep GetThirdPartyJobDetailsResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetThirdPartyJobDetailsResponse' 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:
--
-- 'jobDetails', 'getThirdPartyJobDetailsResponse_jobDetails' - The details of the job, including any protected values defined for the
-- job.
--
-- 'httpStatus', 'getThirdPartyJobDetailsResponse_httpStatus' - The response's http status code.
newGetThirdPartyJobDetailsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetThirdPartyJobDetailsResponse
newGetThirdPartyJobDetailsResponse :: Int -> GetThirdPartyJobDetailsResponse
newGetThirdPartyJobDetailsResponse Int
pHttpStatus_ =
  GetThirdPartyJobDetailsResponse' :: Maybe ThirdPartyJobDetails
-> Int -> GetThirdPartyJobDetailsResponse
GetThirdPartyJobDetailsResponse'
    { $sel:jobDetails:GetThirdPartyJobDetailsResponse' :: Maybe ThirdPartyJobDetails
jobDetails =
        Maybe ThirdPartyJobDetails
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetThirdPartyJobDetailsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The details of the job, including any protected values defined for the
-- job.
getThirdPartyJobDetailsResponse_jobDetails :: Lens.Lens' GetThirdPartyJobDetailsResponse (Prelude.Maybe ThirdPartyJobDetails)
getThirdPartyJobDetailsResponse_jobDetails :: (Maybe ThirdPartyJobDetails -> f (Maybe ThirdPartyJobDetails))
-> GetThirdPartyJobDetailsResponse
-> f GetThirdPartyJobDetailsResponse
getThirdPartyJobDetailsResponse_jobDetails = (GetThirdPartyJobDetailsResponse -> Maybe ThirdPartyJobDetails)
-> (GetThirdPartyJobDetailsResponse
    -> Maybe ThirdPartyJobDetails -> GetThirdPartyJobDetailsResponse)
-> Lens
     GetThirdPartyJobDetailsResponse
     GetThirdPartyJobDetailsResponse
     (Maybe ThirdPartyJobDetails)
     (Maybe ThirdPartyJobDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetThirdPartyJobDetailsResponse' {Maybe ThirdPartyJobDetails
jobDetails :: Maybe ThirdPartyJobDetails
$sel:jobDetails:GetThirdPartyJobDetailsResponse' :: GetThirdPartyJobDetailsResponse -> Maybe ThirdPartyJobDetails
jobDetails} -> Maybe ThirdPartyJobDetails
jobDetails) (\s :: GetThirdPartyJobDetailsResponse
s@GetThirdPartyJobDetailsResponse' {} Maybe ThirdPartyJobDetails
a -> GetThirdPartyJobDetailsResponse
s {$sel:jobDetails:GetThirdPartyJobDetailsResponse' :: Maybe ThirdPartyJobDetails
jobDetails = Maybe ThirdPartyJobDetails
a} :: GetThirdPartyJobDetailsResponse)

-- | The response's http status code.
getThirdPartyJobDetailsResponse_httpStatus :: Lens.Lens' GetThirdPartyJobDetailsResponse Prelude.Int
getThirdPartyJobDetailsResponse_httpStatus :: (Int -> f Int)
-> GetThirdPartyJobDetailsResponse
-> f GetThirdPartyJobDetailsResponse
getThirdPartyJobDetailsResponse_httpStatus = (GetThirdPartyJobDetailsResponse -> Int)
-> (GetThirdPartyJobDetailsResponse
    -> Int -> GetThirdPartyJobDetailsResponse)
-> Lens
     GetThirdPartyJobDetailsResponse
     GetThirdPartyJobDetailsResponse
     Int
     Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetThirdPartyJobDetailsResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetThirdPartyJobDetailsResponse' :: GetThirdPartyJobDetailsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetThirdPartyJobDetailsResponse
s@GetThirdPartyJobDetailsResponse' {} Int
a -> GetThirdPartyJobDetailsResponse
s {$sel:httpStatus:GetThirdPartyJobDetailsResponse' :: Int
httpStatus = Int
a} :: GetThirdPartyJobDetailsResponse)

instance
  Prelude.NFData
    GetThirdPartyJobDetailsResponse