更新时间:2024-03-05 GMT+08:00
分享

查询桶触发器(Python SDK)

功能说明

查询桶上绑定工作流触发器。

接口约束

方法定义

WorkflowClient.getTriggerPolicy()

返回结果

表1 返回结果

类型

说明

GetResult

参数解释:

SDK公共结果对象。

表2 GetResult

参数名称

参数类型

描述

status

int

参数解释:

HTTP状态码。

取值范围:

状态码是一组从2xx(成功)到4xx或5xx(错误)的数字代码,状态码表示了请求响应的状态。完整的状态码列表请参见状态码

默认取值:

reason

str

参数解释:

HTTP文本描述。

默认取值:

errorCode

str

参数解释:

OBS服务端错误码,当status参数小于300时为空。

默认取值:

errorMessage

str

参数解释:

OBS服务端错误描述,当status参数小于300时为空。

默认取值:

requestId

str

参数解释:

OBS服务端返回的请求ID。

默认取值:

indicator

str

参数解释:

OBS服务端返回的错误定位码。

默认取值:

hostId

str

参数解释:

请求的服务端ID,当status参数小于300时为空。

默认取值:

resource

str

参数解释:

发生错误时相关的桶或对象,当status参数小于300时为空。

默认取值:

header

list

参数解释:

响应消息头列表,由多个元组构成。每个元组均包含两个元素,代表响应头的键值对。

默认取值:

body

object

参数解释:

操作成功后的结果数据,当status大于300时为空。该值根据调用接口的不同而不同,参见“桶相关接口”章节和“对象相关接口”章节的详细描述。

默认取值:

表3 返回结果

GetResult.body类型

说明

表4

参数解释:

响应结果,详见表4

表4 GetTriggerPolicyResponse

参数名称

参数类型

描述

rules

Array Rule Json结构体 结构体说明

参数解释

策略规则数组

取值范围:

参见结构体说明

默认取值:

代码样例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# 引入模块
from obs import WorkflowClient

# 创建WorkflowClient实例
workflowClient = WorkflowClient(
    access_key_id=os.getenv("AccessKeyID"),
    secret_access_key=os.getenv("SecretAccessKey"),
    server='https://your-endpoint'
)

# 查询桶上绑定工作流触发器
try:
    resp = workflowClient.getTriggerPolicy('bucketName')
      
    if resp.status < 300: 
        print('requestId:', resp.requestId) 
    else: 
        print('errorCode:', resp.errorCode) 
        print('errorMessage:', resp.errorMessage)
except:
    import traceback
    print(traceback.format_exc())

# 关闭workflowClient
workflowClient.close()

相关链接

  • 关于查询桶触发器的API说明,请参见查询桶触发器
  • 查询桶触发器过程中返回的错误码含义、问题原因及处理措施可参考OBS错误码
分享:

    相关文档

    相关产品