文档首页/ 云备份 CBR/ API参考/ API/ 存储库/ 查询存储库列表
更新时间:2024-06-21 GMT+08:00

查询存储库列表

功能介绍

查询存储库列表

调用方法

请参见如何调用API

URI

GET /v3/{project_id}/vaults

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

项目ID

表2 Query参数

参数

是否必选

参数类型

描述

cloud_type

String

公有云:public ;混合云:hybrid

enterprise_project_id

String

企业项目id或all_granted_eps,all_granted_eps表示查询用户有权限的所有企业项目id

id

String

存储库ID

limit

Integer

每页显示条目数,正整数

最小值:1

最大值:1000

name

String

存储库名称

object_type

String

对象类型:云服务器(server),云硬盘(disk),文件系统(turbo),云桌面(workspace),VMware(vmware),关系型数据库(rds),文件(file)。

offset

Integer

偏移值,正整数

policy_id

String

策略ID

protect_type

String

保护类型:备份(backup)、复制(replication)。

resource_ids

String

资源id,支持多资源,以英文逗号分割

status

String

状态

请求参数

表3 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。

响应参数

状态码: 200

表4 响应Body参数

参数

参数类型

描述

vaults

Array of Vault objects

存储库实例列表

count

Integer

存储库个数

limit

Integer

每页显示的条目数量

最小值:1

最大值:1000

缺省值:1000

offset

Integer

偏移量,表示从此偏移量开始查询

最小值:0

缺省值:0

表5 Vault

参数

参数类型

描述

billing

Billing object

运营信息

description

String

存储库自定义描述信息。

最小长度:0

最大长度:255

id

String

存储库ID

name

String

存储库名称

最小长度:1

最大长度:64

project_id

String

项目ID

provider_id

String

存储库资源类型id

resources

Array of ResourceResp objects

存储库资源

tags

Array of Tag objects

存储库标签

enterprise_project_id

String

企业项目id,默认为‘0’。

auto_bind

Boolean

是否自动绑定,默认为false,不支持。

bind_rules

VaultBindRules object

绑定规则

user_id

String

用户id

created_at

String

创建时间,例如:"2020-02-05T10:38:34.209782"

auto_expand

Boolean

是否开启存储库自动扩容能力(只支持按需存储库)。

smn_notify

Boolean

存储库smn消息通知开关

缺省值:true

threshold

Integer

存储库容量阈值,已用容量占总容量达到此百分比即发送相关通知

最小值:1

最大值:100

缺省值:80

sys_lock_source_service

String

用于标识SMB服务,您可以设置为SMB或者空

最小长度:0

最大长度:32

表6 Billing

参数

参数类型

描述

allocated

Integer

已分配容量,单位GB

charging_mode

String

创建模式,按需:post_paid,包周期:pre_paid,默认为post_paid

cloud_type

String

公有云:public ;混合云:hybrid

consistent_level

String

规格,崩溃一致性(crash_consistent)或应用一致性(app_consistent)

object_type

String

对象类型:云服务器(server),云硬盘(disk),文件系统(turbo),云桌面(workspace),VMware(vmware),关系型数据库(rds),文件(file)。

order_id

String

订单ID

product_id

String

产品ID

protect_type

String

保护类型:备份(backup)、复制(replication)。

size

Integer

容量,单位GB

最小值:1

最大值:10485760

spec_code

String

规格编码。 云服务备份存储库:vault.backup.server.normal;云硬盘备份存储库:vault.backup.volume.normal;文件备份存储库:vault.backup.turbo.normal

status

String

存储库状态

  • available: 可用

  • lock: 锁定

  • frozen: 冻结

  • deleting: 删除中

  • error: 异常

storage_unit

String

存储库桶名

used

Integer

已使用容量,单位MB

frozen_scene

String

冻结场景

is_multi_az

Boolean

存储库多az属性

缺省值:false

表7 ResourceResp

参数

参数类型

描述

extra_info

ResourceExtraInfo object

资源附加信息

id

String

待备份资源id

name

String

待备份资源名称

最小长度:0

最大长度:255

protect_status

String

保护状态

  • available: 可用

  • error: 异常

  • protecting: 保护中

  • restoring: 恢复中

  • removing: 删除中

size

Integer

资源已分配容量,单位为GB

type

String

待备份资源的类型: OS::Nova::Server, OS::Cinder::Volume, OS::Ironic::BareMetalServer, OS::Native::Server, OS::Sfs::Turbo, OS::Workspace::DesktopV2

backup_size

Integer

副本大小

backup_count

Integer

副本数量

表8 ResourceExtraInfo

参数

参数类型

描述

exclude_volumes

Array of strings

需要排除备份的卷id。仅在多盘备份特性中有效,排除不需要备份的磁盘。当虚拟机新绑定磁盘时,也能继续排除之前设置不用备份的卷。

表9 Tag

参数

参数类型

描述

key

String

键。

key最大长度为36个字符。

key不能为空字符串。

key前后空格会被丢弃。

key不能包含非打印字符ASCII(0-31),“=”,“*”,“<”,“>”,“\”,“,”,“|”,“/”。

key只能由中文,字母,数字,“-”,“_”组成。

value

String

值。

添加标签时value值必选,删除标签时value值可选。

value最大长度为43个字符。

value可以为空字符串。

value前后的空格会被丢弃。

value不能包含非打印字符ASCII(0-31),“=”,“*”,“<”,“>”,“\”,“,”,“|”,“/”。

value只能由中文,字母,数字,“-”,“_”,“.”组成。

表10 VaultBindRules

参数

参数类型

描述

tags

Array of BindRulesTags objects

按tags过滤自动绑定的资源

最小长度:0

最大长度:5

数组长度:0 - 5

表11 BindRulesTags

参数

参数类型

描述

key

String

key不能包含非打印字符ASCII(0-31),“=”,“*”,“<”,“>”,“\”,“,”,“|”,“/”。

key只能由中文,字母,数字,“-”,“_”组成。

value

String

value不能包含非打印字符ASCII(0-31),“=”,“*”,“<”,“>”,“\”,“,”,“|”,“/”。

value只能由中文,字母,数字,“-”,“_”,“.”组成。

请求示例

查询存储库列表。

GET https://{endpoint}/v3/{project_id}/vaults

响应示例

状态码: 200

OK

{
  "vaults" : [ {
    "id" : "a335f9e1-1628-4c64-a7be-38656e5ec19c",
    "name" : "vault-8538",
    "resources" : [ ],
    "provider_id" : "0daac4c5-6707-4851-97ba-169e36266b66",
    "created_at" : "2020-09-04T06:57:37.344+00:00",
    "project_id" : "0605767b5780d5762fc5c0118072a564",
    "enterprise_project_id" : 0,
    "auto_bind" : false,
    "bind_rules" : { },
    "auto_expand" : false,
    "user_id" : "aa2999fa5ae640f28926f8fd79188934",
    "billing" : {
      "allocated" : 0,
      "cloud_type" : "public",
      "consistent_level" : "crash_consistent",
      "charging_mode" : "post_paid",
      "protect_type" : "backup",
      "object_type" : "server",
      "spec_code" : "vault.backup.server.normal",
      "used" : 0,
      "status" : "available",
      "size" : 100
    },
    "tags" : [ ]
  } ],
  "count" : 50
}

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
58
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.*;

import java.util.List;
import java.util.ArrayList;

public class ListVaultSolution {

    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();
        ListVaultRequest request = new ListVaultRequest();
        request.withLimit(<limit>);
        request.withName("<name>");
        request.withOffset(<offset>);
        request.withCloudType(ListVaultRequest.CloudTypeEnum.fromValue("<cloud_type>"));
        request.withProtectType(ListVaultRequest.ProtectTypeEnum.fromValue("<protect_type>"));
        request.withObjectType("<object_type>");
        request.withEnterpriseProjectId("<enterprise_project_id>");
        request.withId();
        request.withPolicyId("<policy_id>");
        request.withStatus("<status>");
        request.withResourceIds("<resource_ids>");
        try {
            ListVaultResponse response = client.listVault(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
# 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 = ListVaultRequest()
        request.limit = <limit>
        request.name = "<name>"
        request.offset = <offset>
        request.cloud_type = "<cloud_type>"
        request.protect_type = "<protect_type>"
        request.object_type = "<object_type>"
        request.enterprise_project_id = "<enterprise_project_id>"
        request.id = 
        request.policy_id = "<policy_id>"
        request.status = "<status>"
        request.resource_ids = "<resource_ids>"
        response = client.list_vault(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
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.ListVaultRequest{}
	limitRequest:= int32(<limit>)
	request.Limit = &limitRequest
	nameRequest:= "<name>"
	request.Name = &nameRequest
	offsetRequest:= int32(<offset>)
	request.Offset = &offsetRequest
	cloudTypeRequest:= model.GetListVaultRequestCloudTypeEnum().<CLOUD_TYPE>
	request.CloudType = &cloudTypeRequest
	protectTypeRequest:= model.GetListVaultRequestProtectTypeEnum().<PROTECT_TYPE>
	request.ProtectType = &protectTypeRequest
	objectTypeRequest:= "<object_type>"
	request.ObjectType = &objectTypeRequest
	enterpriseProjectIdRequest:= "<enterprise_project_id>"
	request.EnterpriseProjectId = &enterpriseProjectIdRequest
	policyIdRequest:= "<policy_id>"
	request.PolicyId = &policyIdRequest
	statusRequest:= "<status>"
	request.Status = &statusRequest
	resourceIdsRequest:= "<resource_ids>"
	request.ResourceIds = &resourceIdsRequest
	response, err := client.ListVault(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

更多

更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。

状态码

状态码

描述

200

OK

错误码

请参见错误码