validateStateMachineDefinition method

Future<ValidateStateMachineDefinitionOutput> validateStateMachineDefinition({
  1. required String definition,
  2. int? maxResults,
  3. ValidateStateMachineDefinitionSeverity? severity,
  4. StateMachineType? type,
})

Validates the syntax of a state machine definition specified in Amazon States Language (ASL), a JSON-based, structured language.

You can validate that a state machine definition is correct without creating a state machine resource.

Suggested uses for ValidateStateMachineDefinition:

  • Integrate automated checks into your code review or Continuous Integration (CI) process to check state machine definitions before starting deployments.
  • Run validation from a Git pre-commit hook to verify the definition before committing to your source repository.
Validation will look for problems in your state machine definition and return a result and a list of diagnostic elements.

The result value will be OK when your workflow definition can be successfully created or updated. Note the result can be OK even when diagnostic warnings are present in the response. The result value will be FAIL when the workflow definition contains errors that would prevent you from creating or updating your state machine.

The list of ValidateStateMachineDefinitionDiagnostic data elements can contain zero or more WARNING and/or ERROR elements.

May throw ValidationException.

Parameter definition : The Amazon States Language definition of the state machine. For more information, see Amazon States Language (ASL).

Parameter maxResults : The maximum number of diagnostics that are returned per call. The default and maximum value is 100. Setting the value to 0 will also use the default of 100.

If the number of diagnostics returned in the response exceeds maxResults, the value of the truncated field in the response will be set to true.

Parameter severity : Minimum level of diagnostics to return. ERROR returns only ERROR diagnostics, whereas WARNING returns both WARNING and ERROR diagnostics. The default is ERROR.

Parameter type : The target type of state machine for this definition. The default is STANDARD.

Implementation

Future<ValidateStateMachineDefinitionOutput> validateStateMachineDefinition({
  required String definition,
  int? maxResults,
  ValidateStateMachineDefinitionSeverity? severity,
  StateMachineType? type,
}) async {
  _s.validateNumRange(
    'maxResults',
    maxResults,
    0,
    100,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'AWSStepFunctions.ValidateStateMachineDefinition'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'definition': definition,
      if (maxResults != null) 'maxResults': maxResults,
      if (severity != null) 'severity': severity.value,
      if (type != null) 'type': type.value,
    },
  );

  return ValidateStateMachineDefinitionOutput.fromJson(jsonResponse.body);
}