查询任务列表
功能介绍
查询任务列表
调用方法
请参见如何调用API。
URI
GET /v3/{project_id}/operation-logs
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
项目ID |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
end_time |
否 |
String |
任务结束时间,格式为%YYYY-%mm-%ddT%HH:%MM:%SSZ,例如2018-02-01T12:00:00Z |
enterprise_project_id |
否 |
String |
企业项目id或all_granted_eps,all_granted_eps表示查询用户有权限的所有企业项目id |
limit |
否 |
Integer |
每页显示的条目数量,正整数 最小值:1 |
offset |
否 |
Integer |
偏移值,正整数 最小值:1 |
operation_type |
否 |
String |
任务类型 |
provider_id |
否 |
String |
备份提供商ID |
resource_id |
否 |
String |
该任务操作的资源ID |
resource_name |
否 |
String |
该任务操作的资源名称 |
start_time |
否 |
String |
任务开始时间,格式为%YYYY-%mm-%ddT%HH:%MM:%SSZ,例如2018-01-01T12:00:00Z |
status |
否 |
String |
任务状态 |
vault_id |
否 |
String |
存储库ID,该任务操作的资源所属绑定的存储库。 |
vault_name |
否 |
String |
存储库名称,该任务操作资源所绑定的存储库名称。 |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
是 |
String |
用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 |
响应参数
状态码: 200
参数 |
参数类型 |
描述 |
---|---|---|
operation_logs |
Array of OperationLog objects |
任务列表 |
count |
Integer |
任务个数 |
limit |
Integer |
每页显示的条目数量 最小值:1 最大值:1000 缺省值:1000 |
offset |
Integer |
偏移量,表示从此偏移量开始查询 最小值:0 缺省值:0 |
参数 |
参数类型 |
描述 |
---|---|---|
checkpoint_id |
String |
备份记录id |
created_at |
String |
创建时间,例如: "2020-02-23T01:00:32Z" |
ended_at |
String |
任务结束时间,例如: "2020-02-23T01:00:32Z" |
error_info |
OpErrorInfo object |
任务错误信息 |
extra_info |
OpExtraInfo object |
任务扩展信息 |
id |
String |
任务id |
operation_type |
String |
任务类型
|
policy_id |
String |
策略ID |
project_id |
String |
项目ID |
provider_id |
String |
备份提供商ID。用于区分备份对象。 |
started_at |
String |
任务开始时间,例如: "2020-02-23T01:00:32Z" |
status |
String |
任务状态
|
updated_at |
String |
修改时间,例如: "2020-02-23T01:00:32Z" |
vault_id |
String |
任务操作资源所属存储库ID |
vault_name |
String |
任务操作资源所属存储库名称 |
参数 |
参数类型 |
描述 |
---|---|---|
backup |
OpExtendInfoBckup object |
备份扩展参数 |
common |
OpExtendInfoCommon object |
公共参数 |
delete |
OpExtendInfoDelete object |
删除扩展参数 |
sync |
OpExtendInfoSync object |
扩展同步信息 |
remove_resources |
OpExtendInfoRemoveResources object |
移除Vault的资源 |
replication |
OpExtendInfoReplication object |
扩展复制信息 |
resource |
Resource object |
资源信息 |
restore |
OpExtendInfoRestore object |
扩展恢复信息 |
vault_delete |
OpExtendInfoVaultDelete object |
删除vault |
参数 |
参数类型 |
描述 |
---|---|---|
app_consistency_error_code |
String |
应用一致性备份失败错误码。请参见错误码。 |
app_consistency_error_message |
String |
应用一致性备份错误信息 |
app_consistency_status |
String |
应用一致性备份状态
|
backup_id |
String |
备份副本ID |
backup_name |
String |
备份名称 |
incremental |
String |
是否增备
|
参数 |
参数类型 |
描述 |
---|---|---|
progress |
Integer |
进度,取值为0-100 最小值:0 最大值:100 |
request_id |
String |
请求id |
task_id |
String |
备份任务id |
参数 |
参数类型 |
描述 |
---|---|---|
sync_backup_num |
Integer |
同步备份副本数 |
delete_backup_num |
Integer |
删除的备份副本数 |
err_sync_backup_num |
Integer |
同步失败备份副本数 |
参数 |
参数类型 |
描述 |
---|---|---|
fail_count |
Integer |
删除失败的资源数量 |
total_count |
Integer |
删除的备份数量 |
resources |
Array of Resource objects |
资源信息 |
参数 |
参数类型 |
描述 |
---|---|---|
extra_info |
ResourceExtraInfo object |
资源附加信息 |
id |
String |
待备份资源id |
name |
String |
待备份资源名称,长度限制:0-255 最小长度:0 最大长度:255 |
type |
String |
待备份资源的类型: OS::Nova::Server, OS::Cinder::Volume, OS::Ironic::BareMetalServer, OS::Native::Server, OS::Sfs::Turbo, OS::Workspace::DesktopV2 |
参数 |
参数类型 |
描述 |
---|---|---|
destination_backup_id |
String |
目标副本ID |
destination_checkpoint_id |
String |
目标还原点ID |
destination_project_id |
String |
目标project_id |
destination_region |
String |
目标区域 |
source_backup_id |
String |
源副本ID |
source_checkpoint_id |
String |
源还原点ID |
source_project_id |
String |
源project_id |
source_region |
String |
源区域 |
source_backup_name |
String |
源备份名称 |
destination_backup_name |
String |
目标备份名称 |
参数 |
参数类型 |
描述 |
---|---|---|
exclude_volumes |
Array of strings |
需要排除备份的卷id。仅在多盘备份特性中有效,排除不需要备份的磁盘。当虚拟机新绑定磁盘时,也能继续排除之前设置不用备份的卷。 |
参数 |
参数类型 |
描述 |
---|---|---|
backup_id |
String |
备份副本ID |
backup_name |
String |
备份名称 |
target_resource_id |
String |
恢复目标资源ID |
target_resource_name |
String |
恢复目标资源名称 |
参数 |
参数类型 |
描述 |
---|---|---|
fail_count |
Integer |
本次任务删除失败的资源数量 |
total_count |
Integer |
本次任务删除的备份总数 |
状态码: 404
参数 |
参数类型 |
描述 |
---|---|---|
operation_logs |
Array of OperationLog objects |
任务列表 |
count |
Integer |
任务个数 |
limit |
Integer |
每页显示的条目数量 最小值:1 最大值:1000 缺省值:1000 |
offset |
Integer |
偏移量,表示从此偏移量开始查询 最小值:0 缺省值:0 |
参数 |
参数类型 |
描述 |
---|---|---|
checkpoint_id |
String |
备份记录id |
created_at |
String |
创建时间,例如: "2020-02-23T01:00:32Z" |
ended_at |
String |
任务结束时间,例如: "2020-02-23T01:00:32Z" |
error_info |
OpErrorInfo object |
任务错误信息 |
extra_info |
OpExtraInfo object |
任务扩展信息 |
id |
String |
任务id |
operation_type |
String |
任务类型
|
policy_id |
String |
策略ID |
project_id |
String |
项目ID |
provider_id |
String |
备份提供商ID。用于区分备份对象。 |
started_at |
String |
任务开始时间,例如: "2020-02-23T01:00:32Z" |
status |
String |
任务状态
|
updated_at |
String |
修改时间,例如: "2020-02-23T01:00:32Z" |
vault_id |
String |
任务操作资源所属存储库ID |
vault_name |
String |
任务操作资源所属存储库名称 |
参数 |
参数类型 |
描述 |
---|---|---|
backup |
OpExtendInfoBckup object |
备份扩展参数 |
common |
OpExtendInfoCommon object |
公共参数 |
delete |
OpExtendInfoDelete object |
删除扩展参数 |
sync |
OpExtendInfoSync object |
扩展同步信息 |
remove_resources |
OpExtendInfoRemoveResources object |
移除Vault的资源 |
replication |
OpExtendInfoReplication object |
扩展复制信息 |
resource |
Resource object |
资源信息 |
restore |
OpExtendInfoRestore object |
扩展恢复信息 |
vault_delete |
OpExtendInfoVaultDelete object |
删除vault |
参数 |
参数类型 |
描述 |
---|---|---|
app_consistency_error_code |
String |
应用一致性备份失败错误码。请参见错误码。 |
app_consistency_error_message |
String |
应用一致性备份错误信息 |
app_consistency_status |
String |
应用一致性备份状态
|
backup_id |
String |
备份副本ID |
backup_name |
String |
备份名称 |
incremental |
String |
是否增备
|
参数 |
参数类型 |
描述 |
---|---|---|
progress |
Integer |
进度,取值为0-100 最小值:0 最大值:100 |
request_id |
String |
请求id |
task_id |
String |
备份任务id |
参数 |
参数类型 |
描述 |
---|---|---|
sync_backup_num |
Integer |
同步备份副本数 |
delete_backup_num |
Integer |
删除的备份副本数 |
err_sync_backup_num |
Integer |
同步失败备份副本数 |
参数 |
参数类型 |
描述 |
---|---|---|
fail_count |
Integer |
删除失败的资源数量 |
total_count |
Integer |
删除的备份数量 |
resources |
Array of Resource objects |
资源信息 |
参数 |
参数类型 |
描述 |
---|---|---|
extra_info |
ResourceExtraInfo object |
资源附加信息 |
id |
String |
待备份资源id |
name |
String |
待备份资源名称,长度限制:0-255 最小长度:0 最大长度:255 |
type |
String |
待备份资源的类型: OS::Nova::Server, OS::Cinder::Volume, OS::Ironic::BareMetalServer, OS::Native::Server, OS::Sfs::Turbo, OS::Workspace::DesktopV2 |
参数 |
参数类型 |
描述 |
---|---|---|
destination_backup_id |
String |
目标副本ID |
destination_checkpoint_id |
String |
目标还原点ID |
destination_project_id |
String |
目标project_id |
destination_region |
String |
目标区域 |
source_backup_id |
String |
源副本ID |
source_checkpoint_id |
String |
源还原点ID |
source_project_id |
String |
源project_id |
source_region |
String |
源区域 |
source_backup_name |
String |
源备份名称 |
destination_backup_name |
String |
目标备份名称 |
参数 |
参数类型 |
描述 |
---|---|---|
exclude_volumes |
Array of strings |
需要排除备份的卷id。仅在多盘备份特性中有效,排除不需要备份的磁盘。当虚拟机新绑定磁盘时,也能继续排除之前设置不用备份的卷。 |
请求示例
GET https://{endpoint}/v3/{project_id}/operation-logs
响应示例
状态码: 200
OK
{ "count" : 1, "operation_logs" : [ { "status" : "success", "provider_id" : "0daac4c5-6707-4851-97ba-169e36266b66", "checkpoint_id" : "b432511f-d889-428f-8b0e-5f47c524c6b6", "updated_at" : "2019-05-23T14:35:23.584+00:00", "error_info" : { "message" : "", "code" : "" }, "started_at" : "2019-05-23T14:31:36.007+00:00", "id" : "4827f2da-b008-4507-ab7d-42d0df5ed912", "extra_info" : { "resource" : { "type" : "OS::Nova::Server", "id" : "1dab32fa-ebf2-415a-ab0b-eabe6353bc86", "name" : "ECS-0001" }, "backup" : { "backup_name" : "manualbk_backup", "backup_id" : "0e5d0ef6-7f0a-4890-b98c-cb12490e31c1" }, "common" : { "progress" : 100, "request_id" : "req-cdb98cc4-e87b-4f40-9b4a-57ec036620bc" } }, "ended_at" : "2019-05-23T14:35:23.511+00:00", "created_at" : "2019-05-23T14:31:36.039+00:00", "operation_type" : "backup", "project_id" : "04f1829c788037ac2fb8c01eb2b04b95" } ] }
SDK代码示例
SDK代码示例如下。
Java
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.cbr.v1.region.CbrRegion; import com.huaweicloud.sdk.cbr.v1.*; import com.huaweicloud.sdk.cbr.v1.model.*; public class ListOpLogsSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); ICredential auth = new BasicCredentials() .withAk(ak) .withSk(sk); CbrClient client = CbrClient.newBuilder() .withCredential(auth) .withRegion(CbrRegion.valueOf("<YOUR REGION>")) .build(); ListOpLogsRequest request = new ListOpLogsRequest(); request.withEndTime("<end_time>"); request.withLimit(<limit>); request.withOffset(<offset>); request.withOperationType(ListOpLogsRequest.OperationTypeEnum.fromValue("<operation_type>")); request.withProviderId("<provider_id>"); request.withResourceId("<resource_id>"); request.withResourceName("<resource_name>"); request.withStartTime("<start_time>"); request.withStatus(ListOpLogsRequest.StatusEnum.fromValue("<status>")); request.withVaultId("<vault_id>"); request.withVaultName("<vault_name>"); request.withEnterpriseProjectId("<enterprise_project_id>"); try { ListOpLogsResponse response = client.listOpLogs(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } } |
Python
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# coding: utf-8 from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkcbr.v1.region.cbr_region import CbrRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkcbr.v1 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = __import__('os').getenv("CLOUD_SDK_AK") sk = __import__('os').getenv("CLOUD_SDK_SK") credentials = BasicCredentials(ak, sk) \ client = CbrClient.new_builder() \ .with_credentials(credentials) \ .with_region(CbrRegion.value_of("<YOUR REGION>")) \ .build() try: request = ListOpLogsRequest() request.end_time = "<end_time>" request.limit = <limit> request.offset = <offset> request.operation_type = "<operation_type>" request.provider_id = "<provider_id>" request.resource_id = "<resource_id>" request.resource_name = "<resource_name>" request.start_time = "<start_time>" request.status = "<status>" request.vault_id = "<vault_id>" request.vault_name = "<vault_name>" request.enterprise_project_id = "<enterprise_project_id>" response = client.list_op_logs(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
Go
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" cbr "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cbr/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cbr/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cbr/v1/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). Build() client := cbr.NewCbrClient( cbr.CbrClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.ListOpLogsRequest{} endTimeRequest:= "<end_time>" request.EndTime = &endTimeRequest limitRequest:= int32(<limit>) request.Limit = &limitRequest offsetRequest:= int32(<offset>) request.Offset = &offsetRequest operationTypeRequest:= model.GetListOpLogsRequestOperationTypeEnum().<OPERATION_TYPE> request.OperationType = &operationTypeRequest providerIdRequest:= "<provider_id>" request.ProviderId = &providerIdRequest resourceIdRequest:= "<resource_id>" request.ResourceId = &resourceIdRequest resourceNameRequest:= "<resource_name>" request.ResourceName = &resourceNameRequest startTimeRequest:= "<start_time>" request.StartTime = &startTimeRequest statusRequest:= model.GetListOpLogsRequestStatusEnum().<STATUS> request.Status = &statusRequest vaultIdRequest:= "<vault_id>" request.VaultId = &vaultIdRequest vaultNameRequest:= "<vault_name>" request.VaultName = &vaultNameRequest enterpriseProjectIdRequest:= "<enterprise_project_id>" request.EnterpriseProjectId = &enterpriseProjectIdRequest response, err := client.ListOpLogs(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
状态码 |
描述 |
---|---|
200 |
OK |
404 |
Not Found |
错误码
请参见错误码。