Calling an API to Trigger a Workflow
API Description
You can call this API to configure the triggering of a workflow by an API.
Method Definition
WorkflowClient.asyncAPIStartWorkflow(graphName, bucket, object, inputs=None)
Request Parameters
|
Parameter |
Mandatory or Optional |
Type |
Description |
Constraint |
|---|---|---|---|---|
|
graphName |
Mandatory |
str |
Workflow name |
The name should start with a letter or digit, and contain a maximum of 64 characters. Only letters, digits, underscores (_), and hyphens (-) are allowed. |
|
bucket |
Mandatory |
str |
Bucket name |
- |
|
object |
Mandatory |
str |
Object name |
- |
|
inputs |
Optional |
map |
Parameters that can be modified in a workflow |
The key in the map must be the name of a parameter in the workflow. |
Returned Results
|
Type |
Description |
|---|---|
|
SDK common result object |
|
GetResult.body Type |
Description |
|---|---|
|
Response Result of the Request for Triggering a Workflow by an API |
Response result |
Sample Code
# Import the module.
from obs import WorkflowClient
# Create a WorkflowClient instance.
workflowClient = WorkflowClient(
access_key_id='*** Provide your Access Key ***',
secret_access_key='*** Provide your Secret Key ***',
server='https://your-endpoint'
)
# Trigger a Workflow by an API.
try:
resp = workflowClient.asyncAPIStartWorkflow('graphName', 'bucket', 'object', inputs='inputs')
if resp.status < 300:
print('requestId:', resp.requestId)
else:
print('errorCode:', resp.errorCode)
print('errorMessage:', resp.errorMessage)
except:
import traceback
print(traceback.format_exc())
# Close workflowClient.
workflowClient.close()
Last Article: Querying the Workflow List
Next Article: Managing Workflow Instances
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.