{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $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 :: Lens' GetThirdPartyJobDetails Text
getThirdPartyJobDetails_jobId = 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 :: Lens' GetThirdPartyJobDetails Text
getThirdPartyJobDetails_clientToken = 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 :: (Service -> Service)
-> GetThirdPartyJobDetails -> Request GetThirdPartyJobDetails
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetThirdPartyJobDetails
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetThirdPartyJobDetails)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe ThirdPartyJobDetails
-> Int -> GetThirdPartyJobDetailsResponse
GetThirdPartyJobDetailsResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"jobDetails")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetThirdPartyJobDetails where
  hashWithSalt :: Int -> GetThirdPartyJobDetails -> Int
hashWithSalt Int
_salt GetThirdPartyJobDetails' {Text
clientToken :: Text
jobId :: Text
$sel:clientToken:GetThirdPartyJobDetails' :: GetThirdPartyJobDetails -> Text
$sel:jobId:GetThirdPartyJobDetails' :: GetThirdPartyJobDetails -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
jobId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
clientToken

instance Prelude.NFData GetThirdPartyJobDetails where
  rnf :: GetThirdPartyJobDetails -> ()
rnf GetThirdPartyJobDetails' {Text
clientToken :: Text
jobId :: Text
$sel:clientToken:GetThirdPartyJobDetails' :: GetThirdPartyJobDetails -> Text
$sel:jobId:GetThirdPartyJobDetails' :: GetThirdPartyJobDetails -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
jobId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
clientToken

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

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"jobId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
jobId),
            forall a. a -> Maybe a
Prelude.Just (Key
"clientToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
clientToken)
          ]
      )

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

instance Data.ToQuery GetThirdPartyJobDetails where
  toQuery :: GetThirdPartyJobDetails -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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
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.
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'
    { $sel:jobDetails:GetThirdPartyJobDetailsResponse' :: Maybe ThirdPartyJobDetails
jobDetails =
        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 :: Lens' GetThirdPartyJobDetailsResponse (Maybe ThirdPartyJobDetails)
getThirdPartyJobDetailsResponse_jobDetails = 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 :: Lens' GetThirdPartyJobDetailsResponse Int
getThirdPartyJobDetailsResponse_httpStatus = 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
  where
  rnf :: GetThirdPartyJobDetailsResponse -> ()
rnf GetThirdPartyJobDetailsResponse' {Int
Maybe ThirdPartyJobDetails
httpStatus :: Int
jobDetails :: Maybe ThirdPartyJobDetails
$sel:httpStatus:GetThirdPartyJobDetailsResponse' :: GetThirdPartyJobDetailsResponse -> Int
$sel:jobDetails:GetThirdPartyJobDetailsResponse' :: GetThirdPartyJobDetailsResponse -> Maybe ThirdPartyJobDetails
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ThirdPartyJobDetails
jobDetails
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus