文档首页/ 数据仓库服务 DWS/ API参考/ API说明/ 快照管理/ 根据快照ID查询规格信息 - ListSnapshotFlavorInfo
更新时间:2025-10-16 GMT+08:00
分享

根据快照ID查询规格信息 - ListSnapshotFlavorInfo

功能介绍

根据快照ID查询规格信息。支持用来查询某个快照的规格信息,或者快照可恢复到的目标规格信息。

调用方法

请参见如何调用API

授权信息

账号具备所有API的调用权限,如果使用账号下的IAM用户调用当前API,该IAM用户需具备调用API所需的权限,具体权限要求请参见权限和授权项

URI

GET /v2/{project_id}/snapshots/{snapshot_id}/flavors

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

参数解释

项目ID。

约束限制

不涉及。

取值范围

不涉及。

默认取值

不涉及。

snapshot_id

String

参数解释

快照ID。

约束限制

不涉及。

取值范围

不涉及。

默认取值

不涉及。

表2 Query参数

参数

是否必选

参数类型

描述

type

String

参数解释

过滤快照规格类型,用于区分仅查询快照原始规格,还是包含可恢复的规格。

约束限制

不涉及。

取值范围

snapshot:仅查询快照的规格信息

restore:同时查询恢复快照可用的规格信息

默认取值

snapshot

az_code

String

参数解释

恢复时的目标可用区,用以过滤目标可用区下可恢复的规格。

恢复3az集群时需传递3个可用区编码,英文逗号分割(无空格)。

约束限制

不涉及。

取值范围

不涉及。

默认取值

快照原始集群所在可用区。

fine_grained_restore

Boolean

参数解释

是否是细粒度备份恢复,用以过滤恢复时的可用规格。

约束限制

不涉及。

取值范围

true|false

默认取值

false

请求参数

响应参数

状态码:200

表3 响应Body参数

参数

参数类型

描述

flavors

Array of ProductUnitResp objects

参数解释

快照规格信息响应。

取值范围

不涉及。

count

Integer

参数解释

快照规格信息总条数。

取值范围

大于等于0的正整数。

表4 ProductUnitResp

参数

参数类型

描述

id

String

参数解释

规格ID。

取值范围

不涉及。

code

String

参数解释

规格编码。

取值范围

不涉及。

default_capacity

String

参数解释

规格默认容量。

取值范围

不涉及。

classify

String

参数解释

规格类型。

取值范围

不涉及。

scenario

String

参数解释

规格适用场景。

取值范围

不涉及。

version

String

参数解释

规格版本信息。

取值范围

v1.0:一代规格。

v2.0:二代规格。

status

String

参数解释

规格状态。

取值范围

不涉及。

attribute

Array of ProductExtendResp objects

参数解释

扩展信息。

取值范围

不涉及。

duplicate

Integer

参数解释

规格使用副本数量。

取值范围

不涉及。

default_node

Integer

参数解释

默认节点数量。

取值范围

不涉及。

min_node

Integer

参数解释

最小节点数。

取值范围

不涉及。

max_node

Integer

参数解释

最大节点数。

取值范围

不涉及。

product_version_list

Array of ProductVersionResp objects

参数解释

版本信息。

取值范围

不涉及。

flavor_id

String

参数解释

底层规格ID。有别于id字段,一般不会用到。

取值范围

不涉及。

flavor_code

String

参数解释

规格的底层规格编码。

取值范围

不涉及。

volume_num

Integer

参数解释

规格的磁盘数。

取值范围

不涉及。

volume_used

ProductVolumeUsedResp object

参数解释

创建快照时对应集群的磁盘使用信息。

取值范围

不涉及。

表5 ProductExtendResp

参数

参数类型

描述

code

String

参数解释

集群维度规格扩展信息编号。

取值范围

不涉及。

value

String

参数解释

集群维度规格扩展信息值。

取值范围

不涉及。

表6 ProductVersionResp

参数

参数类型

描述

min_cn

Integer

参数解释

产品规格在该版本支持的最小CN数量。

取值范围

不涉及。

max_cn

Integer

参数解释

产品规格在该版本支持的最大CN数量。

取值范围

不涉及。

version_type

String

参数解释

产品规格该版本支持的类型。

取值范围

1:稳定版;

0:最新版本。

datastore_version

String

参数解释

产品规格版本号名称。

取值范围

不涉及。

表7 ProductVolumeUsedResp

参数

参数类型

描述

volume_type

String

参数解释

节点使用存储类型。

取值范围

HIGH:SAS盘;

ULTRAHIGH:SSD云盘;

COMMON:SATA盘;

LOCAL_DISK:本地盘;

volume_num

Integer

参数解释

节点使用的磁盘数量信息。

取值范围

不涉及。

capacity

Integer

参数解释

集群单节点的可用存储容量。

取值范围

不涉及。

volume_size

Integer

参数解释

集群节点上单数据磁盘的物理存储容量。

取值范围

不涉及。

请求示例

根据快照ID查询规格信息。

GET https://{Endpoint}/v2/05f2cff45100d5112f4bc00b794ea08e/snapshots/46921d1d-3d15-4a6f-8834-520c108c03da/flavors?type=snapshot

响应示例

状态码:200

查询成功。

{
  "flavors" : [ {
    "id" : "908c1620-4cd8-3803-9082-2b29fc966917",
    "code" : "dws2.km1.xlarge",
    "classify" : "dws",
    "scenario" : "non-production",
    "version" : "v1.0",
    "status" : "enable",
    "attribute" : [ {
      "code" : "maxQueue",
      "value" : ""
    }, {
      "code" : "cpuNum",
      "value" : "4"
    }, {
      "code" : "memSize",
      "value" : "32"
    }, {
      "code" : "ioGbSec",
      "value" : ""
    }, {
      "code" : "diskType",
      "value" : "SSD"
    }, {
      "code" : "localDisk",
      "value" : "N"
    } ],
    "duplicate" : 2,
    "default_node" : 3,
    "min_node" : 3,
    "max_node" : 32,
    "default_capacity" : "200",
    "product_version_list" : [ {
      "min_cn" : 2,
      "max_cn" : 20,
      "version_type" : "1",
      "datastore_version" : "9.1.0.215"
    } ],
    "flavor_id" : "e7fe0f10-5ec7-45f5-8558-c8b50ad88b34",
    "flavor_code" : "rc6.xlarge.4",
    "volume_num" : 2,
    "volume_used" : {
      "volume_type" : "SATA",
      "volume_num" : 2,
      "capacity" : 200,
      "volume_size" : 200
    }
  } ],
  "count" : 1
}

SDK代码示例

SDK代码示例如下。

 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
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.dws.v2.region.DwsRegion;
import com.huaweicloud.sdk.dws.v2.*;
import com.huaweicloud.sdk.dws.v2.model.*;


public class ListSnapshotFlavorInfoSolution {

    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");
        String projectId = "{project_id}";

        ICredential auth = new BasicCredentials()
                .withProjectId(projectId)
                .withAk(ak)
                .withSk(sk);

        DwsClient client = DwsClient.newBuilder()
                .withCredential(auth)
                .withRegion(DwsRegion.valueOf("<YOUR REGION>"))
                .build();
        ListSnapshotFlavorInfoRequest request = new ListSnapshotFlavorInfoRequest();
        request.withSnapshotId("{snapshot_id}");
        try {
            ListSnapshotFlavorInfoResponse response = client.listSnapshotFlavorInfo(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());
        }
    }
}
 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
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdws.v2.region.dws_region import DwsRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkdws.v2 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 = os.environ["CLOUD_SDK_AK"]
    sk = os.environ["CLOUD_SDK_SK"]
    projectId = "{project_id}"

    credentials = BasicCredentials(ak, sk, projectId)

    client = DwsClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(DwsRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = ListSnapshotFlavorInfoRequest()
        request.snapshot_id = "{snapshot_id}"
        response = client.list_snapshot_flavor_info(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)
 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
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    dws "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dws/v2"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dws/v2/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dws/v2/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")
    projectId := "{project_id}"

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        WithProjectId(projectId).
        Build()

    client := dws.NewDwsClient(
        dws.DwsClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.ListSnapshotFlavorInfoRequest{}
	request.SnapshotId = "{snapshot_id}"
	response, err := client.ListSnapshotFlavorInfo(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

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

状态码

状态码

描述

200

查询成功。

400

请求错误。

401

鉴权失败。

403

没有操作权限。

500

服务内部错误。

503

服务不可用。

相关文档