Skip to content

Commit b73ebff

Browse files
author
awstools
committed
feat(client-sfn): Add new ValidateStateMachineDefinition operation, which performs syntax checking on the definition of a Amazon States Language (ASL) state machine.
1 parent 75febc1 commit b73ebff

File tree

9 files changed

+465
-2
lines changed

9 files changed

+465
-2
lines changed

clients/client-sfn/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,3 +510,11 @@ UpdateStateMachineAlias
510510
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/sfn/command/UpdateStateMachineAliasCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-sfn/Interface/UpdateStateMachineAliasCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-sfn/Interface/UpdateStateMachineAliasCommandOutput/)
511511

512512
</details>
513+
<details>
514+
<summary>
515+
ValidateStateMachineDefinition
516+
</summary>
517+
518+
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/sfn/command/ValidateStateMachineDefinitionCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-sfn/Interface/ValidateStateMachineDefinitionCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-sfn/Interface/ValidateStateMachineDefinitionCommandOutput/)
519+
520+
</details>

clients/client-sfn/src/SFN.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,11 @@ import {
170170
UpdateStateMachineCommandInput,
171171
UpdateStateMachineCommandOutput,
172172
} from "./commands/UpdateStateMachineCommand";
173+
import {
174+
ValidateStateMachineDefinitionCommand,
175+
ValidateStateMachineDefinitionCommandInput,
176+
ValidateStateMachineDefinitionCommandOutput,
177+
} from "./commands/ValidateStateMachineDefinitionCommand";
173178
import { SFNClient, SFNClientConfig } from "./SFNClient";
174179

175180
const commands = {
@@ -209,6 +214,7 @@ const commands = {
209214
UpdateMapRunCommand,
210215
UpdateStateMachineCommand,
211216
UpdateStateMachineAliasCommand,
217+
ValidateStateMachineDefinitionCommand,
212218
};
213219

214220
export interface SFN {
@@ -763,6 +769,23 @@ export interface SFN {
763769
options: __HttpHandlerOptions,
764770
cb: (err: any, data?: UpdateStateMachineAliasCommandOutput) => void
765771
): void;
772+
773+
/**
774+
* @see {@link ValidateStateMachineDefinitionCommand}
775+
*/
776+
validateStateMachineDefinition(
777+
args: ValidateStateMachineDefinitionCommandInput,
778+
options?: __HttpHandlerOptions
779+
): Promise<ValidateStateMachineDefinitionCommandOutput>;
780+
validateStateMachineDefinition(
781+
args: ValidateStateMachineDefinitionCommandInput,
782+
cb: (err: any, data?: ValidateStateMachineDefinitionCommandOutput) => void
783+
): void;
784+
validateStateMachineDefinition(
785+
args: ValidateStateMachineDefinitionCommandInput,
786+
options: __HttpHandlerOptions,
787+
cb: (err: any, data?: ValidateStateMachineDefinitionCommandOutput) => void
788+
): void;
766789
}
767790

768791
/**

clients/client-sfn/src/SFNClient.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ import {
125125
UpdateStateMachineAliasCommandOutput,
126126
} from "./commands/UpdateStateMachineAliasCommand";
127127
import { UpdateStateMachineCommandInput, UpdateStateMachineCommandOutput } from "./commands/UpdateStateMachineCommand";
128+
import {
129+
ValidateStateMachineDefinitionCommandInput,
130+
ValidateStateMachineDefinitionCommandOutput,
131+
} from "./commands/ValidateStateMachineDefinitionCommand";
128132
import {
129133
ClientInputEndpointParameters,
130134
ClientResolvedEndpointParameters,
@@ -175,7 +179,8 @@ export type ServiceInputTypes =
175179
| UntagResourceCommandInput
176180
| UpdateMapRunCommandInput
177181
| UpdateStateMachineAliasCommandInput
178-
| UpdateStateMachineCommandInput;
182+
| UpdateStateMachineCommandInput
183+
| ValidateStateMachineDefinitionCommandInput;
179184

180185
/**
181186
* @public
@@ -216,7 +221,8 @@ export type ServiceOutputTypes =
216221
| UntagResourceCommandOutput
217222
| UpdateMapRunCommandOutput
218223
| UpdateStateMachineAliasCommandOutput
219-
| UpdateStateMachineCommandOutput;
224+
| UpdateStateMachineCommandOutput
225+
| ValidateStateMachineDefinitionCommandOutput;
220226

221227
/**
222228
* @public

clients/client-sfn/src/commands/RedriveExecutionCommand.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ export interface RedriveExecutionCommandOutput extends RedriveExecutionOutput, _
8686
* @throws {@link InvalidArn} (client fault)
8787
* <p>The provided Amazon Resource Name (ARN) is not valid.</p>
8888
*
89+
* @throws {@link ValidationException} (client fault)
90+
* <p>The input does not satisfy the constraints specified by an Amazon Web Services service.</p>
91+
*
8992
* @throws {@link SFNServiceException}
9093
* <p>Base exception class for all service exceptions from SFN service.</p>
9194
*
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
// smithy-typescript generated code
2+
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
3+
import { getSerdePlugin } from "@smithy/middleware-serde";
4+
import { Command as $Command } from "@smithy/smithy-client";
5+
import { MetadataBearer as __MetadataBearer } from "@smithy/types";
6+
7+
import { commonParams } from "../endpoint/EndpointParameters";
8+
import {
9+
ValidateStateMachineDefinitionInput,
10+
ValidateStateMachineDefinitionInputFilterSensitiveLog,
11+
ValidateStateMachineDefinitionOutput,
12+
} from "../models/models_0";
13+
import {
14+
de_ValidateStateMachineDefinitionCommand,
15+
se_ValidateStateMachineDefinitionCommand,
16+
} from "../protocols/Aws_json1_0";
17+
import { ServiceInputTypes, ServiceOutputTypes, SFNClientResolvedConfig } from "../SFNClient";
18+
19+
/**
20+
* @public
21+
*/
22+
export { __MetadataBearer, $Command };
23+
/**
24+
* @public
25+
*
26+
* The input for {@link ValidateStateMachineDefinitionCommand}.
27+
*/
28+
export interface ValidateStateMachineDefinitionCommandInput extends ValidateStateMachineDefinitionInput {}
29+
/**
30+
* @public
31+
*
32+
* The output of {@link ValidateStateMachineDefinitionCommand}.
33+
*/
34+
export interface ValidateStateMachineDefinitionCommandOutput
35+
extends ValidateStateMachineDefinitionOutput,
36+
__MetadataBearer {}
37+
38+
/**
39+
* <p>Validates the syntax of a state machine definition.</p>
40+
* <p>You can validate that a state machine definition is correct without
41+
* creating a state machine resource. Step Functions will implicitly perform the same
42+
* syntax check when you invoke <code>CreateStateMachine</code> and
43+
* <code>UpdateStateMachine</code>. State machine definitions are specified using a
44+
* JSON-based, structured language. For more information on Amazon States Language see <a href="https://docs.aws.amazon.com/step-functions/latest/dg/concepts-amazon-states-language.html">Amazon States Language</a> (ASL). </p>
45+
* <p>Suggested uses for <code>ValidateStateMachineDefinition</code>:</p>
46+
* <ul>
47+
* <li>
48+
* <p>Integrate automated checks into your code review or Continuous Integration
49+
* (CI) process to validate state machine definitions before starting
50+
* deployments.</p>
51+
* </li>
52+
* <li>
53+
* <p>Run the validation from a Git pre-commit hook to check your state machine
54+
* definitions before committing them to your source repository.</p>
55+
* </li>
56+
* </ul>
57+
* <note>
58+
* <p>Errors found in the state machine definition will be returned in the response as a list of <b>diagnostic elements</b>, rather than raise an exception.</p>
59+
* </note>
60+
* @example
61+
* Use a bare-bones client and the command you need to make an API call.
62+
* ```javascript
63+
* import { SFNClient, ValidateStateMachineDefinitionCommand } from "@aws-sdk/client-sfn"; // ES Modules import
64+
* // const { SFNClient, ValidateStateMachineDefinitionCommand } = require("@aws-sdk/client-sfn"); // CommonJS import
65+
* const client = new SFNClient(config);
66+
* const input = { // ValidateStateMachineDefinitionInput
67+
* definition: "STRING_VALUE", // required
68+
* type: "STANDARD" || "EXPRESS",
69+
* };
70+
* const command = new ValidateStateMachineDefinitionCommand(input);
71+
* const response = await client.send(command);
72+
* // { // ValidateStateMachineDefinitionOutput
73+
* // result: "OK" || "FAIL", // required
74+
* // diagnostics: [ // ValidateStateMachineDefinitionDiagnosticList // required
75+
* // { // ValidateStateMachineDefinitionDiagnostic
76+
* // severity: "ERROR", // required
77+
* // code: "STRING_VALUE", // required
78+
* // message: "STRING_VALUE", // required
79+
* // location: "STRING_VALUE",
80+
* // },
81+
* // ],
82+
* // };
83+
*
84+
* ```
85+
*
86+
* @param ValidateStateMachineDefinitionCommandInput - {@link ValidateStateMachineDefinitionCommandInput}
87+
* @returns {@link ValidateStateMachineDefinitionCommandOutput}
88+
* @see {@link ValidateStateMachineDefinitionCommandInput} for command's `input` shape.
89+
* @see {@link ValidateStateMachineDefinitionCommandOutput} for command's `response` shape.
90+
* @see {@link SFNClientResolvedConfig | config} for SFNClient's `config` shape.
91+
*
92+
* @throws {@link ValidationException} (client fault)
93+
* <p>The input does not satisfy the constraints specified by an Amazon Web Services service.</p>
94+
*
95+
* @throws {@link SFNServiceException}
96+
* <p>Base exception class for all service exceptions from SFN service.</p>
97+
*
98+
* @public
99+
*/
100+
export class ValidateStateMachineDefinitionCommand extends $Command
101+
.classBuilder<
102+
ValidateStateMachineDefinitionCommandInput,
103+
ValidateStateMachineDefinitionCommandOutput,
104+
SFNClientResolvedConfig,
105+
ServiceInputTypes,
106+
ServiceOutputTypes
107+
>()
108+
.ep({
109+
...commonParams,
110+
})
111+
.m(function (this: any, Command: any, cs: any, config: SFNClientResolvedConfig, o: any) {
112+
return [
113+
getSerdePlugin(config, this.serialize, this.deserialize),
114+
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
115+
];
116+
})
117+
.s("AWSStepFunctions", "ValidateStateMachineDefinition", {})
118+
.n("SFNClient", "ValidateStateMachineDefinitionCommand")
119+
.f(ValidateStateMachineDefinitionInputFilterSensitiveLog, void 0)
120+
.ser(se_ValidateStateMachineDefinitionCommand)
121+
.de(de_ValidateStateMachineDefinitionCommand)
122+
.build() {}

clients/client-sfn/src/commands/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ export * from "./UntagResourceCommand";
3535
export * from "./UpdateMapRunCommand";
3636
export * from "./UpdateStateMachineAliasCommand";
3737
export * from "./UpdateStateMachineCommand";
38+
export * from "./ValidateStateMachineDefinitionCommand";

clients/client-sfn/src/models/models_0.ts

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4548,6 +4548,106 @@ export interface UpdateStateMachineAliasOutput {
45484548
updateDate: Date | undefined;
45494549
}
45504550

4551+
/**
4552+
* @public
4553+
*/
4554+
export interface ValidateStateMachineDefinitionInput {
4555+
/**
4556+
* <p>The Amazon States Language definition of the state machine. For more information, see
4557+
* <a href="https://docs.aws.amazon.com/step-functions/latest/dg/concepts-amazon-states-language.html">Amazon States Language</a> (ASL).</p>
4558+
* @public
4559+
*/
4560+
definition: string | undefined;
4561+
4562+
/**
4563+
* <p>The target type of state machine for this definition. The default is <code>STANDARD</code>.</p>
4564+
* @public
4565+
*/
4566+
type?: StateMachineType;
4567+
}
4568+
4569+
/**
4570+
* @public
4571+
* @enum
4572+
*/
4573+
export const ValidateStateMachineDefinitionSeverity = {
4574+
ERROR: "ERROR",
4575+
} as const;
4576+
4577+
/**
4578+
* @public
4579+
*/
4580+
export type ValidateStateMachineDefinitionSeverity =
4581+
(typeof ValidateStateMachineDefinitionSeverity)[keyof typeof ValidateStateMachineDefinitionSeverity];
4582+
4583+
/**
4584+
* <p>Describes an error found during validation. Validation errors found in the definition
4585+
* return in the response as <b>diagnostic elements</b>, rather
4586+
* than raise an exception.</p>
4587+
* @public
4588+
*/
4589+
export interface ValidateStateMachineDefinitionDiagnostic {
4590+
/**
4591+
* <p>A value of <code>ERROR</code> means that you cannot create or update a state machine with this definition.</p>
4592+
* @public
4593+
*/
4594+
severity: ValidateStateMachineDefinitionSeverity | undefined;
4595+
4596+
/**
4597+
* <p>Identifying code for the diagnostic.</p>
4598+
* @public
4599+
*/
4600+
code: string | undefined;
4601+
4602+
/**
4603+
* <p>Message describing the diagnostic condition.</p>
4604+
* @public
4605+
*/
4606+
message: string | undefined;
4607+
4608+
/**
4609+
* <p>Location of the issue in the state machine, if available.</p>
4610+
* <p>For errors specific to a field, the location could be in the format: <code>/States/<StateName>/<FieldName></code>, for example: <code>/States/FailState/ErrorPath</code>.</p>
4611+
* @public
4612+
*/
4613+
location?: string;
4614+
}
4615+
4616+
/**
4617+
* @public
4618+
* @enum
4619+
*/
4620+
export const ValidateStateMachineDefinitionResultCode = {
4621+
FAIL: "FAIL",
4622+
OK: "OK",
4623+
} as const;
4624+
4625+
/**
4626+
* @public
4627+
*/
4628+
export type ValidateStateMachineDefinitionResultCode =
4629+
(typeof ValidateStateMachineDefinitionResultCode)[keyof typeof ValidateStateMachineDefinitionResultCode];
4630+
4631+
/**
4632+
* @public
4633+
*/
4634+
export interface ValidateStateMachineDefinitionOutput {
4635+
/**
4636+
* <p>The result value will be <code>OK</code> when no syntax errors are found, or
4637+
* <code>FAIL</code> if the workflow definition does not pass verification.</p>
4638+
* @public
4639+
*/
4640+
result: ValidateStateMachineDefinitionResultCode | undefined;
4641+
4642+
/**
4643+
* <p>If the result is <code>OK</code>, this field will be empty. When there are errors,
4644+
* this field will contain an array of <b>Diagnostic</b> objects
4645+
* to help you troubleshoot.</p>
4646+
* @public
4647+
*/
4648+
diagnostics: ValidateStateMachineDefinitionDiagnostic[] | undefined;
4649+
}
4650+
45514651
/**
45524652
* @internal
45534653
*/
@@ -5062,3 +5162,13 @@ export const UpdateStateMachineAliasInputFilterSensitiveLog = (obj: UpdateStateM
50625162
...obj,
50635163
...(obj.description && { description: SENSITIVE_STRING }),
50645164
});
5165+
5166+
/**
5167+
* @internal
5168+
*/
5169+
export const ValidateStateMachineDefinitionInputFilterSensitiveLog = (
5170+
obj: ValidateStateMachineDefinitionInput
5171+
): any => ({
5172+
...obj,
5173+
...(obj.definition && { definition: SENSITIVE_STRING }),
5174+
});

0 commit comments

Comments
 (0)