{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.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 @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
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]
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
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. 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'
      { $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 :: Lens' GetPipelineExecution Text
getPipelineExecution_pipelineName = 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 :: Lens' GetPipelineExecution Text
getPipelineExecution_pipelineExecutionId = 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 :: (Service -> Service)
-> GetPipelineExecution -> Request GetPipelineExecution
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 GetPipelineExecution
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetPipelineExecution)))
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 PipelineExecution -> Int -> GetPipelineExecutionResponse
GetPipelineExecutionResponse'
            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
"pipelineExecution")
            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 GetPipelineExecution where
  hashWithSalt :: Int -> GetPipelineExecution -> Int
hashWithSalt Int
_salt GetPipelineExecution' {Text
pipelineExecutionId :: Text
pipelineName :: Text
$sel:pipelineExecutionId:GetPipelineExecution' :: GetPipelineExecution -> Text
$sel:pipelineName:GetPipelineExecution' :: GetPipelineExecution -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
pipelineName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
pipelineExecutionId

instance Prelude.NFData GetPipelineExecution where
  rnf :: GetPipelineExecution -> ()
rnf GetPipelineExecution' {Text
pipelineExecutionId :: Text
pipelineName :: Text
$sel:pipelineExecutionId:GetPipelineExecution' :: GetPipelineExecution -> Text
$sel:pipelineName:GetPipelineExecution' :: GetPipelineExecution -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
pipelineName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
pipelineExecutionId

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

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

instance Data.ToQuery GetPipelineExecution where
  toQuery :: GetPipelineExecution -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:pipelineExecution:GetPipelineExecutionResponse' :: Maybe PipelineExecution
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 :: Lens' GetPipelineExecutionResponse (Maybe PipelineExecution)
getPipelineExecutionResponse_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 :: Lens' GetPipelineExecutionResponse Int
getPipelineExecutionResponse_httpStatus = 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 where
  rnf :: GetPipelineExecutionResponse -> ()
rnf GetPipelineExecutionResponse' {Int
Maybe PipelineExecution
httpStatus :: Int
pipelineExecution :: Maybe PipelineExecution
$sel:httpStatus:GetPipelineExecutionResponse' :: GetPipelineExecutionResponse -> Int
$sel:pipelineExecution:GetPipelineExecutionResponse' :: GetPipelineExecutionResponse -> Maybe PipelineExecution
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe PipelineExecution
pipelineExecution
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus