Skip to Content
GPU 接口文档磁盘与云存储查询云盘扩容价格
GPU API 接口

查询云盘扩容价格

接口说明

查询已挂载云盘扩容到目标大小的价格。返回结果中包含云盘和快照服务的价格明细。

POSThttps://api.compshare.cnActionGetCompShareAttachedDiskUpgradePrice

请求参数

名称类型必填描述示例值
ActionString接口名称GetCompShareAttachedDiskUpgradePrice
RegionString地域cn-wlcb
ZoneString可用区cn-wlcb-01
UHostIdString实例 IDuhost-xxxx
DiskIdString云盘 IDudisk-xxxx
DiskSpaceInteger目标磁盘大小,单位 GB200
BackupModeString备份模式。枚举值:NONEDATAARKSNAPSHOT。默认保持当前磁盘已启用的备份模式NONE

响应参数

名称类型描述示例值
ActionString响应名称GetCompShareAttachedDiskUpgradePriceResponse
RetCodeInteger返回码,0 为成功0
PriceFloat扩容差价(元)50.00
OriginalPriceFloat折前原价差额(元)50.00
ListPriceFloat目录价差额(元,无任何折扣)50.00
PriceDetailObject折后价格明细
OriginalPriceDetailObject折前原价明细(结构同 PriceDetail)
ListPriceDetailObject目录价明细(结构同 PriceDetail)

PriceDetail 结构

名称类型描述
UDiskFloat云盘扩容费用(元)
SnapshotFloat快照服务费用(元)

请求示例

Python(使用 UCloud SDK)

安装 SDK:

pip install --upgrade ucloud-sdk-python3

示例代码:

from ucloud.core import exc from ucloud.client import Client def main(): client = Client({ "region": "cn-wlcb", "public_key": "my_public_key", # 替换为你的公钥(控制台 账户中心 → API 密钥:https://console.compshare.cn/uaccount/api_manage) "private_key": "my_private_key", # 替换为你的私钥 "base_url": "https://api.compshare.cn", }) try: resp = client.ucompshare().invoke("GetCompShareAttachedDiskUpgradePrice", { "Region": "cn-wlcb", "Zone": "cn-wlcb-01", "UHostId": "uhost-xxxx", # 实例 ID,通过 DescribeCompShareInstance 获取 "DiskId": "udisk-xxxx", # 云盘 ID "DiskSpace": 200, }) print(f"扩容差价: {resp.get('Price')} 元") except exc.UCloudException as e: print(e) if __name__ == "__main__": main()

Go(使用 UCloud SDK)

安装依赖:

go get github.com/ucloud/ucloud-sdk-go

示例代码:

package main import ( "fmt" "github.com/ucloud/ucloud-sdk-go/ucloud" "github.com/ucloud/ucloud-sdk-go/ucloud/auth" "github.com/ucloud/ucloud-sdk-go/ucloud/request" "github.com/ucloud/ucloud-sdk-go/ucloud/response" ) type GetCompShareAttachedDiskUpgradePriceRequest struct { request.CommonBase UHostId *string DiskId *string DiskSpace *int // 目标大小 (GB) } type GetCompShareAttachedDiskUpgradePriceResponse struct { response.CommonBase Price float64 `json:"Price"` // 扩容差价 (元) OriginalPrice float64 `json:"OriginalPrice"` // 折前原价差额 (元) } func main() { cfg := ucloud.NewConfig() cfg.Region = "cn-wlcb" cfg.BaseUrl = "https://api.compshare.cn" credential := auth.NewCredential() credential.PublicKey = "my_public_key" // 替换为你的公钥(控制台 账户中心 → API 密钥:https://console.compshare.cn/uaccount/api_manage) credential.PrivateKey = "my_private_key" // 替换为你的私钥 client := ucloud.NewClient(&cfg, &credential) req := &GetCompShareAttachedDiskUpgradePriceRequest{ UHostId: ucloud.String("uhost-xxxx"), // 实例 ID,通过 DescribeCompShareInstance 获取 DiskId: ucloud.String("udisk-xxxx"), // 云盘 ID DiskSpace: ucloud.Int(200), } req.SetRegion("cn-wlcb") req.SetZone("cn-wlcb-01") resp := &GetCompShareAttachedDiskUpgradePriceResponse{} if err := client.InvokeAction("GetCompShareAttachedDiskUpgradePrice", req, resp); err != nil { fmt.Printf("调用失败: RetCode=%d Msg=%s err=%v\n", resp.RetCode, resp.Message, err) return } fmt.Printf("扩容差价: %.2f\n", resp.Price) }

响应示例

{ "Action": "GetCompShareAttachedDiskUpgradePriceResponse", "RetCode": 0, "Price": 50.00, "OriginalPrice": 50.00, "PriceDetail": { "UDisk": 50.00, "Snapshot": 0.00 }, "OriginalPriceDetail": { "UDisk": 50.00, "Snapshot": 0.00 } }
Last updated on