Configuring a Bucket Trigger
API Description
You can use this API to bind trigger to a workflow in a bucket.
Method Definition
WorkflowClient.putTriggerPolicy(rules)
Request Parameters
| Parameter | Mandatory or Optional | Type | Description | Constraint |
|---|---|---|---|---|
| rules | Mandatory | Array Rule JSON structure. For details, see Structures. | Number of policy rules | For the same bucket, different policy rules (prefix or suffix rules) associated with the same workflow cannot contain each other or overlap with each other. |
Returned Results
| Type | Description |
|---|---|
| SDK common result object |
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'
)
# Bind a workflow trigger to a bucket.
try:
resp = workflowClient.putTriggerPolicy('bucketName', 'rules')
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: Managing Trigger Policies
Next Article: Querying a Bucket Trigger
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.