|
| 1 | +// smithy-typescript generated code |
| 2 | +import { EndpointParameterInstructions, getEndpointPlugin } from "@smithy/middleware-endpoint"; |
| 3 | +import { getSerdePlugin } from "@smithy/middleware-serde"; |
| 4 | +import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@smithy/protocol-http"; |
| 5 | +import { Command as $Command } from "@smithy/smithy-client"; |
| 6 | +import { |
| 7 | + FinalizeHandlerArguments, |
| 8 | + Handler, |
| 9 | + HandlerExecutionContext, |
| 10 | + HttpHandlerOptions as __HttpHandlerOptions, |
| 11 | + MetadataBearer as __MetadataBearer, |
| 12 | + MiddlewareStack, |
| 13 | + SerdeContext as __SerdeContext, |
| 14 | + SMITHY_CONTEXT_KEY, |
| 15 | +} from "@smithy/types"; |
| 16 | + |
| 17 | +import { |
| 18 | + TestStateInput, |
| 19 | + TestStateInputFilterSensitiveLog, |
| 20 | + TestStateOutput, |
| 21 | + TestStateOutputFilterSensitiveLog, |
| 22 | +} from "../models/models_0"; |
| 23 | +import { de_TestStateCommand, se_TestStateCommand } from "../protocols/Aws_json1_0"; |
| 24 | +import { ServiceInputTypes, ServiceOutputTypes, SFNClientResolvedConfig } from "../SFNClient"; |
| 25 | + |
| 26 | +/** |
| 27 | + * @public |
| 28 | + */ |
| 29 | +export { __MetadataBearer, $Command }; |
| 30 | +/** |
| 31 | + * @public |
| 32 | + * |
| 33 | + * The input for {@link TestStateCommand}. |
| 34 | + */ |
| 35 | +export interface TestStateCommandInput extends TestStateInput {} |
| 36 | +/** |
| 37 | + * @public |
| 38 | + * |
| 39 | + * The output of {@link TestStateCommand}. |
| 40 | + */ |
| 41 | +export interface TestStateCommandOutput extends TestStateOutput, __MetadataBearer {} |
| 42 | + |
| 43 | +/** |
| 44 | + * @public |
| 45 | + * <p>Accepts the definition of a single state and executes it. You can test a state without creating a state machine or updating an existing state machine. Using this API, you can test the following:</p> |
| 46 | + * <ul> |
| 47 | + * <li> |
| 48 | + * <p>A state's <a href="https://docs.aws.amazon.com/step-functions/latest/dg/test-state-isolation.html#test-state-input-output-dataflow">input and output processing</a> data flow</p> |
| 49 | + * </li> |
| 50 | + * <li> |
| 51 | + * <p>An <a href="https://docs.aws.amazon.com/step-functions/latest/dg/connect-to-services.html">Amazon Web Services service integration</a> request and response</p> |
| 52 | + * </li> |
| 53 | + * <li> |
| 54 | + * <p>An <a href="https://docs.aws.amazon.com/step-functions/latest/dg/connect-third-party-apis.html">HTTP Task</a> request and response</p> |
| 55 | + * </li> |
| 56 | + * </ul> |
| 57 | + * <p>You can call this API on only one state at a time. The states that you can test include the following:</p> |
| 58 | + * <ul> |
| 59 | + * <li> |
| 60 | + * <p> |
| 61 | + * <a href="https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-task-state.html#task-types">All Task types</a> except <a href="https://docs.aws.amazon.com/step-functions/latest/dg/concepts-activities.html">Activity</a> |
| 62 | + * </p> |
| 63 | + * </li> |
| 64 | + * <li> |
| 65 | + * <p> |
| 66 | + * <a href="https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-pass-state.html">Pass</a> |
| 67 | + * </p> |
| 68 | + * </li> |
| 69 | + * <li> |
| 70 | + * <p> |
| 71 | + * <a href="https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-wait-state.html">Wait</a> |
| 72 | + * </p> |
| 73 | + * </li> |
| 74 | + * <li> |
| 75 | + * <p> |
| 76 | + * <a href="https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-choice-state.html">Choice</a> |
| 77 | + * </p> |
| 78 | + * </li> |
| 79 | + * <li> |
| 80 | + * <p> |
| 81 | + * <a href="https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-succeed-state.html">Succeed</a> |
| 82 | + * </p> |
| 83 | + * </li> |
| 84 | + * <li> |
| 85 | + * <p> |
| 86 | + * <a href="https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-fail-state.html">Fail</a> |
| 87 | + * </p> |
| 88 | + * </li> |
| 89 | + * </ul> |
| 90 | + * <p>The <code>TestState</code> API assumes an IAM role which must contain the required IAM permissions for the resources your state is accessing. For information about the permissions a state might need, see <a href="https://docs.aws.amazon.com/step-functions/latest/dg/test-state-isolation.html#test-state-permissions">IAM permissions to test a state</a>.</p> |
| 91 | + * <p>The <code>TestState</code> API can run for up to five minutes. If the execution of a state exceeds this duration, it fails with the <code>States.Timeout</code> error.</p> |
| 92 | + * <p> |
| 93 | + * <code>TestState</code> doesn't support <a href="https://docs.aws.amazon.com/step-functions/latest/dg/concepts-activities.html">Activity tasks</a>, <code>.sync</code> or <code>.waitForTaskToken</code> |
| 94 | + * <a href="https://docs.aws.amazon.com/step-functions/latest/dg/connect-to-resource.html">service integration patterns</a>, <a href="https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-parallel-state.html">Parallel</a>, or <a href="https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-map-state.html">Map</a> states.</p> |
| 95 | + * @example |
| 96 | + * Use a bare-bones client and the command you need to make an API call. |
| 97 | + * ```javascript |
| 98 | + * import { SFNClient, TestStateCommand } from "@aws-sdk/client-sfn"; // ES Modules import |
| 99 | + * // const { SFNClient, TestStateCommand } = require("@aws-sdk/client-sfn"); // CommonJS import |
| 100 | + * const client = new SFNClient(config); |
| 101 | + * const input = { // TestStateInput |
| 102 | + * definition: "STRING_VALUE", // required |
| 103 | + * roleArn: "STRING_VALUE", // required |
| 104 | + * input: "STRING_VALUE", |
| 105 | + * inspectionLevel: "INFO" || "DEBUG" || "TRACE", |
| 106 | + * revealSecrets: true || false, |
| 107 | + * }; |
| 108 | + * const command = new TestStateCommand(input); |
| 109 | + * const response = await client.send(command); |
| 110 | + * // { // TestStateOutput |
| 111 | + * // output: "STRING_VALUE", |
| 112 | + * // error: "STRING_VALUE", |
| 113 | + * // cause: "STRING_VALUE", |
| 114 | + * // inspectionData: { // InspectionData |
| 115 | + * // input: "STRING_VALUE", |
| 116 | + * // afterInputPath: "STRING_VALUE", |
| 117 | + * // afterParameters: "STRING_VALUE", |
| 118 | + * // result: "STRING_VALUE", |
| 119 | + * // afterResultSelector: "STRING_VALUE", |
| 120 | + * // afterResultPath: "STRING_VALUE", |
| 121 | + * // request: { // InspectionDataRequest |
| 122 | + * // protocol: "STRING_VALUE", |
| 123 | + * // method: "STRING_VALUE", |
| 124 | + * // url: "STRING_VALUE", |
| 125 | + * // headers: "STRING_VALUE", |
| 126 | + * // body: "STRING_VALUE", |
| 127 | + * // }, |
| 128 | + * // response: { // InspectionDataResponse |
| 129 | + * // protocol: "STRING_VALUE", |
| 130 | + * // statusCode: "STRING_VALUE", |
| 131 | + * // statusMessage: "STRING_VALUE", |
| 132 | + * // headers: "STRING_VALUE", |
| 133 | + * // body: "STRING_VALUE", |
| 134 | + * // }, |
| 135 | + * // }, |
| 136 | + * // nextState: "STRING_VALUE", |
| 137 | + * // status: "SUCCEEDED" || "FAILED" || "RETRIABLE" || "CAUGHT_ERROR", |
| 138 | + * // }; |
| 139 | + * |
| 140 | + * ``` |
| 141 | + * |
| 142 | + * @param TestStateCommandInput - {@link TestStateCommandInput} |
| 143 | + * @returns {@link TestStateCommandOutput} |
| 144 | + * @see {@link TestStateCommandInput} for command's `input` shape. |
| 145 | + * @see {@link TestStateCommandOutput} for command's `response` shape. |
| 146 | + * @see {@link SFNClientResolvedConfig | config} for SFNClient's `config` shape. |
| 147 | + * |
| 148 | + * @throws {@link InvalidArn} (client fault) |
| 149 | + * <p>The provided Amazon Resource Name (ARN) is not valid.</p> |
| 150 | + * |
| 151 | + * @throws {@link InvalidDefinition} (client fault) |
| 152 | + * <p>The provided Amazon States Language definition is not valid.</p> |
| 153 | + * |
| 154 | + * @throws {@link InvalidExecutionInput} (client fault) |
| 155 | + * <p>The provided JSON input data is not valid.</p> |
| 156 | + * |
| 157 | + * @throws {@link ValidationException} (client fault) |
| 158 | + * <p>The input does not satisfy the constraints specified by an Amazon Web Services service.</p> |
| 159 | + * |
| 160 | + * @throws {@link SFNServiceException} |
| 161 | + * <p>Base exception class for all service exceptions from SFN service.</p> |
| 162 | + * |
| 163 | + */ |
| 164 | +export class TestStateCommand extends $Command<TestStateCommandInput, TestStateCommandOutput, SFNClientResolvedConfig> { |
| 165 | + public static getEndpointParameterInstructions(): EndpointParameterInstructions { |
| 166 | + return { |
| 167 | + UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, |
| 168 | + Endpoint: { type: "builtInParams", name: "endpoint" }, |
| 169 | + Region: { type: "builtInParams", name: "region" }, |
| 170 | + UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }, |
| 171 | + }; |
| 172 | + } |
| 173 | + |
| 174 | + /** |
| 175 | + * @public |
| 176 | + */ |
| 177 | + constructor(readonly input: TestStateCommandInput) { |
| 178 | + super(); |
| 179 | + } |
| 180 | + |
| 181 | + /** |
| 182 | + * @internal |
| 183 | + */ |
| 184 | + resolveMiddleware( |
| 185 | + clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>, |
| 186 | + configuration: SFNClientResolvedConfig, |
| 187 | + options?: __HttpHandlerOptions |
| 188 | + ): Handler<TestStateCommandInput, TestStateCommandOutput> { |
| 189 | + this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize)); |
| 190 | + this.middlewareStack.use(getEndpointPlugin(configuration, TestStateCommand.getEndpointParameterInstructions())); |
| 191 | + |
| 192 | + const stack = clientStack.concat(this.middlewareStack); |
| 193 | + |
| 194 | + const { logger } = configuration; |
| 195 | + const clientName = "SFNClient"; |
| 196 | + const commandName = "TestStateCommand"; |
| 197 | + const handlerExecutionContext: HandlerExecutionContext = { |
| 198 | + logger, |
| 199 | + clientName, |
| 200 | + commandName, |
| 201 | + inputFilterSensitiveLog: TestStateInputFilterSensitiveLog, |
| 202 | + outputFilterSensitiveLog: TestStateOutputFilterSensitiveLog, |
| 203 | + [SMITHY_CONTEXT_KEY]: { |
| 204 | + service: "AWSStepFunctions", |
| 205 | + operation: "TestState", |
| 206 | + }, |
| 207 | + }; |
| 208 | + const { requestHandler } = configuration; |
| 209 | + return stack.resolve( |
| 210 | + (request: FinalizeHandlerArguments<any>) => |
| 211 | + requestHandler.handle(request.request as __HttpRequest, options || {}), |
| 212 | + handlerExecutionContext |
| 213 | + ); |
| 214 | + } |
| 215 | + |
| 216 | + /** |
| 217 | + * @internal |
| 218 | + */ |
| 219 | + private serialize(input: TestStateCommandInput, context: __SerdeContext): Promise<__HttpRequest> { |
| 220 | + return se_TestStateCommand(input, context); |
| 221 | + } |
| 222 | + |
| 223 | + /** |
| 224 | + * @internal |
| 225 | + */ |
| 226 | + private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<TestStateCommandOutput> { |
| 227 | + return de_TestStateCommand(output, context); |
| 228 | + } |
| 229 | +} |
0 commit comments