{-# 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.GetPipelineExecution
-- 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)
--
-- Returns information about an execution of a pipeline, including details
-- about artifacts, the pipeline execution ID, and the name, version, and
-- status of the pipeline.
module Amazonka.CodePipeline.GetPipelineExecution
  ( -- * Creating a Request
    GetPipelineExecution (..),
    newGetPipelineExecution,

    -- * Request Lenses
    getPipelineExecution_pipelineName,
    getPipelineExecution_pipelineExecutionId,

    -- * Destructuring the Response
    GetPipelineExecutionResponse (..),
    newGetPipelineExecutionResponse,

    -- * Response Lenses
    getPipelineExecutionResponse_pipelineExecution,
    getPipelineExecutionResponse_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 @GetPipelineExecution@ action.
--
-- /See:/ 'newGetPipelineExecution' smart constructor.
data GetPipelineExecution = GetPipelineExecution'
  { -- | The name of the pipeline about which you want to get execution details.
    GetPipelineExecution -> Text
pipelineName :: Prelude.Text,
    -- | The ID of the pipeline execution about which you want to get execution
    -- details.
    GetPipelineExecution -> Text
pipelineExecutionId :: Prelude.Text
  }
  deriving (GetPipelineExecution -> GetPipelineExecution -> Bool
(GetPipelineExecution -> GetPipelineExecution -> Bool)
-> (GetPipelineExecution -> GetPipelineExecution -> Bool)
-> Eq GetPipelineExecution
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetPipelineExecution -> GetPipelineExecution -> Bool
$c/= :: GetPipelineExecution -> GetPipelineExecution -> Bool
== :: GetPipelineExecution -> GetPipelineExecution -> Bool
$c== :: GetPipelineExecution -> GetPipelineExecution -> Bool
Prelude.Eq, ReadPrec [GetPipelineExecution]
ReadPrec GetPipelineExecution
Int -> ReadS GetPipelineExecution
ReadS [GetPipelineExecution]
(Int -> ReadS GetPipelineExecution)
-> ReadS [GetPipelineExecution]
-> ReadPrec GetPipelineExecution
-> ReadPrec [GetPipelineExecution]
-> Read GetPipelineExecution
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetPipelineExecution]
$creadListPrec :: ReadPrec [GetPipelineExecution]
readPrec :: ReadPrec GetPipelineExecution
$creadPrec :: ReadPrec GetPipelineExecution
readList :: ReadS [GetPipelineExecution]
$creadList :: ReadS [GetPipelineExecution]
readsPrec :: Int -> ReadS GetPipelineExecution
$creadsPrec :: Int -> ReadS GetPipelineExecution
Prelude.Read, Int -> GetPipelineExecution -> ShowS
[GetPipelineExecution] -> ShowS
GetPipelineExecution -> String
(Int -> GetPipelineExecution -> ShowS)
-> (GetPipelineExecution -> String)
-> ([GetPipelineExecution] -> ShowS)
-> Show GetPipelineExecution
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetPipelineExecution] -> ShowS
$cshowList :: [GetPipelineExecution] -> ShowS
show :: GetPipelineExecution -> String
$cshow :: GetPipelineExecution -> String
showsPrec :: Int -> GetPipelineExecution -> ShowS
$cshowsPrec :: Int -> GetPipelineExecution -> ShowS
Prelude.Show, (forall x. GetPipelineExecution -> Rep GetPipelineExecution x)
-> (forall x. Rep GetPipelineExecution x -> GetPipelineExecution)
-> Generic GetPipelineExecution
forall x. Rep GetPipelineExecution x -> GetPipelineExecution
forall x. GetPipelineExecution -> Rep GetPipelineExecution x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetPipelineExecution x -> GetPipelineExecution
$cfrom :: forall x. GetPipelineExecution -> Rep GetPipelineExecution x
Prelude.Generic)

-- |
-- Create a value of 'GetPipelineExecution' 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:
--
-- 'pipelineName', 'getPipelineExecution_pipelineName' - The name of the pipeline about which you want to get execution details.
--
-- 'pipelineExecutionId', 'getPipelineExecution_pipelineExecutionId' - The ID of the pipeline execution about which you want to get execution
-- details.
newGetPipelineExecution ::
  -- | 'pipelineName'
  Prelude.Text ->
  -- | 'pipelineExecutionId'
  Prelude.Text ->
  GetPipelineExecution
newGetPipelineExecution :: Text -> Text -> GetPipelineExecution
newGetPipelineExecution
  Text
pPipelineName_
  Text
pPipelineExecutionId_ =
    GetPipelineExecution' :: Text -> Text -> GetPipelineExecution
GetPipelineExecution'
      { $sel:pipelineName:GetPipelineExecution' :: Text
pipelineName =
          Text
pPipelineName_,
        $sel:pipelineExecutionId:GetPipelineExecution' :: Text
pipelineExecutionId = Text
pPipelineExecutionId_
      }

-- | The name of the pipeline about which you want to get execution details.
getPipelineExecution_pipelineName :: Lens.Lens' GetPipelineExecution Prelude.Text
getPipelineExecution_pipelineName :: (Text -> f Text) -> GetPipelineExecution -> f GetPipelineExecution
getPipelineExecution_pipelineName = (GetPipelineExecution -> Text)
-> (GetPipelineExecution -> Text -> GetPipelineExecution)
-> Lens GetPipelineExecution GetPipelineExecution Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPipelineExecution' {Text
pipelineName :: Text
$sel:pipelineName:GetPipelineExecution' :: GetPipelineExecution -> Text
pipelineName} -> Text
pipelineName) (\s :: GetPipelineExecution
s@GetPipelineExecution' {} Text
a -> GetPipelineExecution
s {$sel:pipelineName:GetPipelineExecution' :: Text
pipelineName = Text
a} :: GetPipelineExecution)

-- | The ID of the pipeline execution about which you want to get execution
-- details.
getPipelineExecution_pipelineExecutionId :: Lens.Lens' GetPipelineExecution Prelude.Text
getPipelineExecution_pipelineExecutionId :: (Text -> f Text) -> GetPipelineExecution -> f GetPipelineExecution
getPipelineExecution_pipelineExecutionId = (GetPipelineExecution -> Text)
-> (GetPipelineExecution -> Text -> GetPipelineExecution)
-> Lens GetPipelineExecution GetPipelineExecution Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPipelineExecution' {Text
pipelineExecutionId :: Text
$sel:pipelineExecutionId:GetPipelineExecution' :: GetPipelineExecution -> Text
pipelineExecutionId} -> Text
pipelineExecutionId) (\s :: GetPipelineExecution
s@GetPipelineExecution' {} Text
a -> GetPipelineExecution
s {$sel:pipelineExecutionId:GetPipelineExecution' :: Text
pipelineExecutionId = Text
a} :: GetPipelineExecution)

instance Core.AWSRequest GetPipelineExecution where
  type
    AWSResponse GetPipelineExecution =
      GetPipelineExecutionResponse
  request :: GetPipelineExecution -> Request GetPipelineExecution
request = Service -> GetPipelineExecution -> Request GetPipelineExecution
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetPipelineExecution
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetPipelineExecution)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetPipelineExecution))
-> Logger
-> Service
-> Proxy GetPipelineExecution
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetPipelineExecution)))
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 PipelineExecution -> Int -> GetPipelineExecutionResponse
GetPipelineExecutionResponse'
            (Maybe PipelineExecution -> Int -> GetPipelineExecutionResponse)
-> Either String (Maybe PipelineExecution)
-> Either String (Int -> GetPipelineExecutionResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe PipelineExecution)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"pipelineExecution")
            Either String (Int -> GetPipelineExecutionResponse)
-> Either String Int -> Either String GetPipelineExecutionResponse
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 GetPipelineExecution

instance Prelude.NFData GetPipelineExecution

instance Core.ToHeaders GetPipelineExecution where
  toHeaders :: GetPipelineExecution -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetPipelineExecution -> 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.GetPipelineExecution" ::
                          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 GetPipelineExecution where
  toJSON :: GetPipelineExecution -> Value
toJSON GetPipelineExecution' {Text
pipelineExecutionId :: Text
pipelineName :: Text
$sel:pipelineExecutionId:GetPipelineExecution' :: GetPipelineExecution -> Text
$sel:pipelineName:GetPipelineExecution' :: GetPipelineExecution -> 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
"pipelineName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
pipelineName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"pipelineExecutionId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
pipelineExecutionId)
          ]
      )

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

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

-- | Represents the output of a @GetPipelineExecution@ action.
--
-- /See:/ 'newGetPipelineExecutionResponse' smart constructor.
data GetPipelineExecutionResponse = GetPipelineExecutionResponse'
  { -- | Represents information about the execution of a pipeline.
    GetPipelineExecutionResponse -> Maybe PipelineExecution
pipelineExecution :: Prelude.Maybe PipelineExecution,
    -- | The response's http status code.
    GetPipelineExecutionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetPipelineExecutionResponse
-> GetPipelineExecutionResponse -> Bool
(GetPipelineExecutionResponse
 -> GetPipelineExecutionResponse -> Bool)
-> (GetPipelineExecutionResponse
    -> GetPipelineExecutionResponse -> Bool)
-> Eq GetPipelineExecutionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetPipelineExecutionResponse
-> GetPipelineExecutionResponse -> Bool
$c/= :: GetPipelineExecutionResponse
-> GetPipelineExecutionResponse -> Bool
== :: GetPipelineExecutionResponse
-> GetPipelineExecutionResponse -> Bool
$c== :: GetPipelineExecutionResponse
-> GetPipelineExecutionResponse -> Bool
Prelude.Eq, ReadPrec [GetPipelineExecutionResponse]
ReadPrec GetPipelineExecutionResponse
Int -> ReadS GetPipelineExecutionResponse
ReadS [GetPipelineExecutionResponse]
(Int -> ReadS GetPipelineExecutionResponse)
-> ReadS [GetPipelineExecutionResponse]
-> ReadPrec GetPipelineExecutionResponse
-> ReadPrec [GetPipelineExecutionResponse]
-> Read GetPipelineExecutionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetPipelineExecutionResponse]
$creadListPrec :: ReadPrec [GetPipelineExecutionResponse]
readPrec :: ReadPrec GetPipelineExecutionResponse
$creadPrec :: ReadPrec GetPipelineExecutionResponse
readList :: ReadS [GetPipelineExecutionResponse]
$creadList :: ReadS [GetPipelineExecutionResponse]
readsPrec :: Int -> ReadS GetPipelineExecutionResponse
$creadsPrec :: Int -> ReadS GetPipelineExecutionResponse
Prelude.Read, Int -> GetPipelineExecutionResponse -> ShowS
[GetPipelineExecutionResponse] -> ShowS
GetPipelineExecutionResponse -> String
(Int -> GetPipelineExecutionResponse -> ShowS)
-> (GetPipelineExecutionResponse -> String)
-> ([GetPipelineExecutionResponse] -> ShowS)
-> Show GetPipelineExecutionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetPipelineExecutionResponse] -> ShowS
$cshowList :: [GetPipelineExecutionResponse] -> ShowS
show :: GetPipelineExecutionResponse -> String
$cshow :: GetPipelineExecutionResponse -> String
showsPrec :: Int -> GetPipelineExecutionResponse -> ShowS
$cshowsPrec :: Int -> GetPipelineExecutionResponse -> ShowS
Prelude.Show, (forall x.
 GetPipelineExecutionResponse -> Rep GetPipelineExecutionResponse x)
-> (forall x.
    Rep GetPipelineExecutionResponse x -> GetPipelineExecutionResponse)
-> Generic GetPipelineExecutionResponse
forall x.
Rep GetPipelineExecutionResponse x -> GetPipelineExecutionResponse
forall x.
GetPipelineExecutionResponse -> Rep GetPipelineExecutionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetPipelineExecutionResponse x -> GetPipelineExecutionResponse
$cfrom :: forall x.
GetPipelineExecutionResponse -> Rep GetPipelineExecutionResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetPipelineExecutionResponse' 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:
--
-- 'pipelineExecution', 'getPipelineExecutionResponse_pipelineExecution' - Represents information about the execution of a pipeline.
--
-- 'httpStatus', 'getPipelineExecutionResponse_httpStatus' - The response's http status code.
newGetPipelineExecutionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetPipelineExecutionResponse
newGetPipelineExecutionResponse :: Int -> GetPipelineExecutionResponse
newGetPipelineExecutionResponse Int
pHttpStatus_ =
  GetPipelineExecutionResponse' :: Maybe PipelineExecution -> Int -> GetPipelineExecutionResponse
GetPipelineExecutionResponse'
    { $sel:pipelineExecution:GetPipelineExecutionResponse' :: Maybe PipelineExecution
pipelineExecution =
        Maybe PipelineExecution
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetPipelineExecutionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Represents information about the execution of a pipeline.
getPipelineExecutionResponse_pipelineExecution :: Lens.Lens' GetPipelineExecutionResponse (Prelude.Maybe PipelineExecution)
getPipelineExecutionResponse_pipelineExecution :: (Maybe PipelineExecution -> f (Maybe PipelineExecution))
-> GetPipelineExecutionResponse -> f GetPipelineExecutionResponse
getPipelineExecutionResponse_pipelineExecution = (GetPipelineExecutionResponse -> Maybe PipelineExecution)
-> (GetPipelineExecutionResponse
    -> Maybe PipelineExecution -> GetPipelineExecutionResponse)
-> Lens
     GetPipelineExecutionResponse
     GetPipelineExecutionResponse
     (Maybe PipelineExecution)
     (Maybe PipelineExecution)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPipelineExecutionResponse' {Maybe PipelineExecution
pipelineExecution :: Maybe PipelineExecution
$sel:pipelineExecution:GetPipelineExecutionResponse' :: GetPipelineExecutionResponse -> Maybe PipelineExecution
pipelineExecution} -> Maybe PipelineExecution
pipelineExecution) (\s :: GetPipelineExecutionResponse
s@GetPipelineExecutionResponse' {} Maybe PipelineExecution
a -> GetPipelineExecutionResponse
s {$sel:pipelineExecution:GetPipelineExecutionResponse' :: Maybe PipelineExecution
pipelineExecution = Maybe PipelineExecution
a} :: GetPipelineExecutionResponse)

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

instance Prelude.NFData GetPipelineExecutionResponse