Skip to content

Commit

Permalink
feat(client-codepipeline): Add ability to manually and automatically …
Browse files Browse the repository at this point in the history
…roll back a pipeline stage to a previously successful execution.
  • Loading branch information
awstools committed Apr 26, 2024
1 parent 231317d commit 27a9b33
Show file tree
Hide file tree
Showing 14 changed files with 726 additions and 2 deletions.
8 changes: 8 additions & 0 deletions clients/client-codepipeline/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,14 @@ RetryStageExecution

[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/codepipeline/command/RetryStageExecutionCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-codepipeline/Interface/RetryStageExecutionCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-codepipeline/Interface/RetryStageExecutionCommandOutput/)

</details>
<details>
<summary>
RollbackStage
</summary>

[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/codepipeline/command/RollbackStageCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-codepipeline/Interface/RollbackStageCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-codepipeline/Interface/RollbackStageCommandOutput/)

</details>
<details>
<summary>
Expand Down
17 changes: 17 additions & 0 deletions clients/client-codepipeline/src/CodePipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ import {
RetryStageExecutionCommandInput,
RetryStageExecutionCommandOutput,
} from "./commands/RetryStageExecutionCommand";
import {
RollbackStageCommand,
RollbackStageCommandInput,
RollbackStageCommandOutput,
} from "./commands/RollbackStageCommand";
import {
StartPipelineExecutionCommand,
StartPipelineExecutionCommandInput,
Expand Down Expand Up @@ -217,6 +222,7 @@ const commands = {
PutWebhookCommand,
RegisterWebhookWithThirdPartyCommand,
RetryStageExecutionCommand,
RollbackStageCommand,
StartPipelineExecutionCommand,
StopPipelineExecutionCommand,
TagResourceCommand,
Expand Down Expand Up @@ -732,6 +738,17 @@ export interface CodePipeline {
cb: (err: any, data?: RetryStageExecutionCommandOutput) => void
): void;

/**
* @see {@link RollbackStageCommand}
*/
rollbackStage(args: RollbackStageCommandInput, options?: __HttpHandlerOptions): Promise<RollbackStageCommandOutput>;
rollbackStage(args: RollbackStageCommandInput, cb: (err: any, data?: RollbackStageCommandOutput) => void): void;
rollbackStage(
args: RollbackStageCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: RollbackStageCommandOutput) => void
): void;

/**
* @see {@link StartPipelineExecutionCommand}
*/
Expand Down
3 changes: 3 additions & 0 deletions clients/client-codepipeline/src/CodePipelineClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ import {
RetryStageExecutionCommandInput,
RetryStageExecutionCommandOutput,
} from "./commands/RetryStageExecutionCommand";
import { RollbackStageCommandInput, RollbackStageCommandOutput } from "./commands/RollbackStageCommand";
import {
StartPipelineExecutionCommandInput,
StartPipelineExecutionCommandOutput,
Expand Down Expand Up @@ -200,6 +201,7 @@ export type ServiceInputTypes =
| PutWebhookCommandInput
| RegisterWebhookWithThirdPartyCommandInput
| RetryStageExecutionCommandInput
| RollbackStageCommandInput
| StartPipelineExecutionCommandInput
| StopPipelineExecutionCommandInput
| TagResourceCommandInput
Expand Down Expand Up @@ -244,6 +246,7 @@ export type ServiceOutputTypes =
| PutWebhookCommandOutput
| RegisterWebhookWithThirdPartyCommandOutput
| RetryStageExecutionCommandOutput
| RollbackStageCommandOutput
| StartPipelineExecutionCommandOutput
| StopPipelineExecutionCommandOutput
| TagResourceCommandOutput
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ export interface CreatePipelineCommandOutput extends CreatePipelineOutput, __Met
* timeoutInMinutes: Number("int"),
* },
* ],
* onFailure: { // FailureConditions
* result: "ROLLBACK",
* },
* },
* ],
* version: Number("int"),
Expand Down Expand Up @@ -241,6 +244,9 @@ export interface CreatePipelineCommandOutput extends CreatePipelineOutput, __Met
* // timeoutInMinutes: Number("int"),
* // },
* // ],
* // onFailure: { // FailureConditions
* // result: "ROLLBACK",
* // },
* // },
* // ],
* // version: Number("int"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ export interface GetPipelineCommandOutput extends GetPipelineOutput, __MetadataB
* // timeoutInMinutes: Number("int"),
* // },
* // ],
* // onFailure: { // FailureConditions
* // result: "ROLLBACK",
* // },
* // },
* // ],
* // version: Number("int"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,14 @@ export interface GetPipelineExecutionCommandOutput extends GetPipelineExecutionO
* // },
* // ],
* // trigger: { // ExecutionTrigger
* // triggerType: "CreatePipeline" || "StartPipelineExecution" || "PollForSourceChanges" || "Webhook" || "CloudWatchEvent" || "PutActionRevision" || "WebhookV2",
* // triggerType: "CreatePipeline" || "StartPipelineExecution" || "PollForSourceChanges" || "Webhook" || "CloudWatchEvent" || "PutActionRevision" || "WebhookV2" || "ManualRollback" || "AutomatedRollback",
* // triggerDetail: "STRING_VALUE",
* // },
* // executionMode: "QUEUED" || "SUPERSEDED" || "PARALLEL",
* // executionType: "STANDARD" || "ROLLBACK",
* // rollbackMetadata: { // PipelineRollbackMetadata
* // rollbackTargetPipelineExecutionId: "STRING_VALUE",
* // },
* // },
* // };
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ export interface GetPipelineStateCommandOutput extends GetPipelineStateOutput, _
* // inboundExecution: { // StageExecution
* // pipelineExecutionId: "STRING_VALUE", // required
* // status: "Cancelled" || "InProgress" || "Failed" || "Stopped" || "Stopping" || "Succeeded", // required
* // type: "STANDARD" || "ROLLBACK",
* // },
* // inboundExecutions: [ // StageExecutionList
* // {
* // pipelineExecutionId: "STRING_VALUE", // required
* // status: "Cancelled" || "InProgress" || "Failed" || "Stopped" || "Stopping" || "Succeeded", // required
* // type: "STANDARD" || "ROLLBACK",
* // },
* // ],
* // inboundTransitionState: { // TransitionState
Expand Down Expand Up @@ -97,6 +99,7 @@ export interface GetPipelineStateCommandOutput extends GetPipelineStateOutput, _
* // latestExecution: {
* // pipelineExecutionId: "STRING_VALUE", // required
* // status: "Cancelled" || "InProgress" || "Failed" || "Stopped" || "Stopping" || "Succeeded", // required
* // type: "STANDARD" || "ROLLBACK",
* // },
* // },
* // ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ export interface ListPipelineExecutionsCommandOutput extends ListPipelineExecuti
* const input = { // ListPipelineExecutionsInput
* pipelineName: "STRING_VALUE", // required
* maxResults: Number("int"),
* filter: { // PipelineExecutionFilter
* succeededInStage: { // SucceededInStageFilter
* stageName: "STRING_VALUE",
* },
* },
* nextToken: "STRING_VALUE",
* };
* const command = new ListPipelineExecutionsCommand(input);
Expand All @@ -46,6 +51,7 @@ export interface ListPipelineExecutionsCommandOutput extends ListPipelineExecuti
* // { // PipelineExecutionSummary
* // pipelineExecutionId: "STRING_VALUE",
* // status: "Cancelled" || "InProgress" || "Stopped" || "Stopping" || "Succeeded" || "Superseded" || "Failed",
* // statusSummary: "STRING_VALUE",
* // startTime: new Date("TIMESTAMP"),
* // lastUpdateTime: new Date("TIMESTAMP"),
* // sourceRevisions: [ // SourceRevisionList
Expand All @@ -57,13 +63,17 @@ export interface ListPipelineExecutionsCommandOutput extends ListPipelineExecuti
* // },
* // ],
* // trigger: { // ExecutionTrigger
* // triggerType: "CreatePipeline" || "StartPipelineExecution" || "PollForSourceChanges" || "Webhook" || "CloudWatchEvent" || "PutActionRevision" || "WebhookV2",
* // triggerType: "CreatePipeline" || "StartPipelineExecution" || "PollForSourceChanges" || "Webhook" || "CloudWatchEvent" || "PutActionRevision" || "WebhookV2" || "ManualRollback" || "AutomatedRollback",
* // triggerDetail: "STRING_VALUE",
* // },
* // stopTrigger: { // StopExecutionTrigger
* // reason: "STRING_VALUE",
* // },
* // executionMode: "QUEUED" || "SUPERSEDED" || "PARALLEL",
* // executionType: "STANDARD" || "ROLLBACK",
* // rollbackMetadata: { // PipelineRollbackMetadata
* // rollbackTargetPipelineExecutionId: "STRING_VALUE",
* // },
* // },
* // ],
* // nextToken: "STRING_VALUE",
Expand Down
108 changes: 108 additions & 0 deletions clients/client-codepipeline/src/commands/RollbackStageCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// smithy-typescript generated code
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
import { MetadataBearer as __MetadataBearer } from "@smithy/types";

import { CodePipelineClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../CodePipelineClient";
import { commonParams } from "../endpoint/EndpointParameters";
import { RollbackStageInput, RollbackStageOutput } from "../models/models_0";
import { de_RollbackStageCommand, se_RollbackStageCommand } from "../protocols/Aws_json1_1";

/**
* @public
*/
export { __MetadataBearer, $Command };
/**
* @public
*
* The input for {@link RollbackStageCommand}.
*/
export interface RollbackStageCommandInput extends RollbackStageInput {}
/**
* @public
*
* The output of {@link RollbackStageCommand}.
*/
export interface RollbackStageCommandOutput extends RollbackStageOutput, __MetadataBearer {}

/**
* <p>Rolls back a stage execution.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { CodePipelineClient, RollbackStageCommand } from "@aws-sdk/client-codepipeline"; // ES Modules import
* // const { CodePipelineClient, RollbackStageCommand } = require("@aws-sdk/client-codepipeline"); // CommonJS import
* const client = new CodePipelineClient(config);
* const input = { // RollbackStageInput
* pipelineName: "STRING_VALUE", // required
* stageName: "STRING_VALUE", // required
* targetPipelineExecutionId: "STRING_VALUE", // required
* };
* const command = new RollbackStageCommand(input);
* const response = await client.send(command);
* // { // RollbackStageOutput
* // pipelineExecutionId: "STRING_VALUE", // required
* // };
*
* ```
*
* @param RollbackStageCommandInput - {@link RollbackStageCommandInput}
* @returns {@link RollbackStageCommandOutput}
* @see {@link RollbackStageCommandInput} for command's `input` shape.
* @see {@link RollbackStageCommandOutput} for command's `response` shape.
* @see {@link CodePipelineClientResolvedConfig | config} for CodePipelineClient's `config` shape.
*
* @throws {@link ConflictException} (client fault)
* <p>Your request cannot be handled because the pipeline is busy handling ongoing
* activities. Try again later.</p>
*
* @throws {@link PipelineExecutionNotFoundException} (client fault)
* <p>The pipeline execution was specified in an invalid format or cannot be found, or an
* execution ID does not belong to the specified pipeline. </p>
*
* @throws {@link PipelineExecutionOutdatedException} (client fault)
* <p>The specified pipeline execution is outdated and cannot be used as a target pipeline execution for rollback.</p>
*
* @throws {@link PipelineNotFoundException} (client fault)
* <p>The pipeline was specified in an invalid format or cannot be found.</p>
*
* @throws {@link StageNotFoundException} (client fault)
* <p>The stage was specified in an invalid format or cannot be found.</p>
*
* @throws {@link UnableToRollbackStageException} (client fault)
* <p>Unable to roll back the stage. The cause might be if the pipeline version has changed
* since the target pipeline execution was deployed, the stage is currently running, or an
* incorrect target pipeline execution ID was provided.</p>
*
* @throws {@link ValidationException} (client fault)
* <p>The validation was specified in an invalid format.</p>
*
* @throws {@link CodePipelineServiceException}
* <p>Base exception class for all service exceptions from CodePipeline service.</p>
*
* @public
*/
export class RollbackStageCommand extends $Command
.classBuilder<
RollbackStageCommandInput,
RollbackStageCommandOutput,
CodePipelineClientResolvedConfig,
ServiceInputTypes,
ServiceOutputTypes
>()
.ep({
...commonParams,
})
.m(function (this: any, Command: any, cs: any, config: CodePipelineClientResolvedConfig, o: any) {
return [
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
];
})
.s("CodePipeline_20150709", "RollbackStage", {})
.n("CodePipelineClient", "RollbackStageCommand")
.f(void 0, void 0)
.ser(se_RollbackStageCommand)
.de(de_RollbackStageCommand)
.build() {}
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ export interface UpdatePipelineCommandOutput extends UpdatePipelineOutput, __Met
* timeoutInMinutes: Number("int"),
* },
* ],
* onFailure: { // FailureConditions
* result: "ROLLBACK",
* },
* },
* ],
* version: Number("int"),
Expand Down Expand Up @@ -232,6 +235,9 @@ export interface UpdatePipelineCommandOutput extends UpdatePipelineOutput, __Met
* // timeoutInMinutes: Number("int"),
* // },
* // ],
* // onFailure: { // FailureConditions
* // result: "ROLLBACK",
* // },
* // },
* // ],
* // version: Number("int"),
Expand Down
1 change: 1 addition & 0 deletions clients/client-codepipeline/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export * from "./PutThirdPartyJobSuccessResultCommand";
export * from "./PutWebhookCommand";
export * from "./RegisterWebhookWithThirdPartyCommand";
export * from "./RetryStageExecutionCommand";
export * from "./RollbackStageCommand";
export * from "./StartPipelineExecutionCommand";
export * from "./StopPipelineExecutionCommand";
export * from "./TagResourceCommand";
Expand Down
Loading

0 comments on commit 27a9b33

Please sign in to comment.