文档首页> 对象存储服务 OBS> Python> 服务编排接口(Python SDK)> 恢复失败状态的工作流实例(Python SDK)
更新时间:2024-03-26 GMT+08:00
分享

恢复失败状态的工作流实例(Python SDK)

功能说明

当且仅当一个工作流实例是执行失败状态才能执行恢复操作。恢复后,工作流实例将从上次失败的状态处继续执行,而已经执行过的状态不会再执行。

接口约束

方法定义

WorkflowClient.restoreFailedWorkflowExecution(executionName, graphName)

请求参数

表1 请求参数列表

名称

是否必选

参数类型

描述

executionName

str

参数解释

工作流实例名称。

约束限制:

是已存在的工作流实例名称。

默认取值:

graphName

str

参数解释

工作流名称

约束限制:

是已存在的工作流

默认取值:

返回结果

表2 返回结果

类型

说明

GetResult

参数解释:

SDK公共结果对象。

表3 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时为空。该值根据调用接口的不同而不同,参见“桶相关接口”章节和“对象相关接口”章节的详细描述。

默认取值:

表4 返回结果

GetResult.body类型

说明

表5

参数解释:

响应结果,详见表5

表5 RestoreFailedWorkflowExecutionResponse

参数名称

参数类型

描述

executionUrn

str

参数解释

运行实例的URN

默认取值:

restoredAt

str

参数解释

运行实例的恢复启动时间

默认取值:

executionName

str

参数解释

运行实例的名字

默认取值:

代码样例

 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 = restoreFailedWorkflowExecution('executionName', 'graphName')
      
    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()

相关链接

分享:

    相关文档

    相关产品