查询算力单元详情
更新时间:2025-05-16
功能介绍
用于查询指定算力单元详细信息。
使用说明
本文API支持通过Python SDK、Go SDK、Java SDK 和 Node.js SDK调用,调用流程请参考SDK安装及使用流程。
权限说明
调用本文API,需符合以下权限要求,权限介绍及分配,请查看角色与权限控制列表、账号创建与权限分配。需具有以下任一权限:
- 完全控制千帆大模型平台的权限:QianfanFullControlAccessPolicy
- 运维操作千帆大模型平台预测服务的权限:QianfanServiceOperateAccessPolicy
- 只读访问千帆大模型平台预测服务的权限:QianfanServiceReadAccessPolicy
SDK调用
调用示例
1package main
2
3import (
4 "context"
5 "fmt"
6 "os"
7
8 "github.com/baidubce/bce-qianfan-sdk/go/qianfan"
9)
10
11func main() {
12 // 使用安全认证AK/SK鉴权,通过环境变量初始化;替换下列示例中参数,安全认证Access Key替换your_iam_ak,Secret Key替换your_iam_sk
13 os.Setenv("QIANFAN_ACCESS_KEY", "your_iam_ak")
14 os.Setenv("QIANFAN_SECRET_KEY", "your_iam_sk")
15
16 ca := qianfan.NewConsoleAction()
17
18 res, err := ca.Call(context.TODO(),
19 // 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求结构-请求地址的后缀
20 "/v2/computeunit",
21 // 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求参数-Query参数的Action
22 "DescribeComputeUnit",
23 // 请查看本文请求参数说明,根据实际使用选择参数;对应API调用文档-请求参数-Body参数
24 map[string]interface{}{
25 "instanceId":"unit-xxx",
26 })
27 if err != nil {
28 panic(err)
29 }
30 fmt.Println(string(res.Body))
31
32}
1import com.baidubce.qianfan.Qianfan;
2import com.baidubce.qianfan.model.console.ConsoleResponse;
3import com.baidubce.qianfan.util.CollUtils;
4import com.baidubce.qianfan.util.Json;
5import java.util.Map;
6
7public class Dome {
8 public static void main(String args[]){
9 // 使用安全认证AK/SK鉴权,替换下列示例中参数,安全认证Access Key替换your_iam_ak,Secret Key替换your_iam_sk
10 Qianfan qianfan = new Qianfan("your_iam_ak", "your_iam_sk");
11
12 ConsoleResponse<Map<String, Object>> response = qianfan.console()
13 // 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求结构-请求地址的后缀
14 .route("/v2/computeunit")
15 // 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求参数-Query参数的Action
16 .action("DescribeComputeUnit")
17 // 需要传入参数的场景,可以自行封装请求类,或者使用Map.of()来构建请求Body
18 // Java 8可以使用SDK提供的CollUtils.mapOf()来替代Map.of()
19 // 请查看本文请求参数说明,根据实际使用选择参数;对应API调用文档-请求参数-Body参数
20 .body(CollUtils.mapOf(
21 "instanceId","unit-xxx"
22 ))
23 .execute();
24
25 System.out.println(Json.serialize(response));
26 }
27}
1import {consoleAction, setEnvVariable} from "@baiducloud/qianfan";
2
3// 使用安全认证AK/SK鉴权,通过环境变量初始化;替换下列示例中参数,安全认证Access Key替换your_iam_ak,Secret Key替换your_iam_sk
4setEnvVariable('QIANFAN_ACCESS_KEY','your_iam_ak');
5setEnvVariable('QIANFAN_SECRET_KEY','your_iam_sk');
6
7async function main() {
8 //base_api_route:调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求结构-请求地址的后缀
9 //action:调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求参数-Query参数的Action
10 //data:请查看本文请求参数说明,根据实际使用选择参数;对应API调用文档-请求参数-Body参数
11 const res = await consoleAction({base_api_route: '/v2/computeunit', action: 'DescribeComputeUnit', data: {
12 "instanceId":"unit-xxx"
13 });
14
15 console.log(res);
16}
17
18main();
返回示例
1{
2 "requestId":"1bef3f87-c5b2-4419-936b-50f9884f10d4",
3 "result": {
4 "computeUnitInstance": {
5 "instanceId": "unit-xxx",
6 "region": "bj",
7 "status": "Running",
8 "type": "gpu-1",
9 "totalComputeUnits": 4,
10 "usedComputeUnits": 2,
11 "paymentTiming": "Prepaid",
12 "startTime": "2024-12-03T06:24:03Z",
13 "expiredTime": "2025-01-03T06:24:03Z",
14 "reservationLength": 1,
15 "reservationTimeUnit": "MONTH",
16 "creator": "xxx",
17 "autoRenew": {
18 "renewTime": 4,
19 "renewTimeUnit": "month"
20 }
21 },
22 "serviceInfoList": [
23 {
24 "serviceName": "xxxx",
25 "serviceId": "svco-xxxx",
26 "runStatus": "Serving",
27 "deployedComputingUnits": 1,
28 "creator": "xxxx"
29 }
30 ]
31 }
32}
1{
2 "requestId":"1bef3f87-c5b2-4419-936b-50f9884f10d4",
3 "result": {
4 "computeUnitInstance": {
5 "instanceId": "unit-xxx",
6 "region": "bj",
7 "status": "Running",
8 "type": "gpu-1",
9 "totalComputeUnits": 4,
10 "usedComputeUnits": 2,
11 "paymentTiming": "Prepaid",
12 "startTime": "2024-12-03T06:24:03Z",
13 "expiredTime": "2025-01-03T06:24:03Z",
14 "reservationLength": 1,
15 "reservationTimeUnit": "MONTH",
16 "creator": "xxx",
17 "autoRenew": {
18 "renewTime": 4,
19 "renewTimeUnit": "month"
20 }
21 },
22 "serviceInfoList": [
23 {
24 "serviceName": "xxxx",
25 "serviceId": "svco-xxxx",
26 "runStatus": "Serving",
27 "deployedComputingUnits": 1,
28 "creator": "xxxx"
29 }
30 ]
31 }
32}
1{
2 "requestId":"1bef3f87-c5b2-4419-936b-50f9884f10d4",
3 "result": {
4 "computeUnitInstance": {
5 "instanceId": "unit-xxx",
6 "region": "bj",
7 "status": "Running",
8 "type": "gpu-1",
9 "totalComputeUnits": 4,
10 "usedComputeUnits": 2,
11 "paymentTiming": "Prepaid",
12 "startTime": "2024-12-03T06:24:03Z",
13 "expiredTime": "2025-01-03T06:24:03Z",
14 "reservationLength": 1,
15 "reservationTimeUnit": "MONTH",
16 "creator": "xxx",
17 "autoRenew": {
18 "renewTime": 4,
19 "renewTimeUnit": "month"
20 }
21 },
22 "serviceInfoList": [
23 {
24 "serviceName": "xxxx",
25 "serviceId": "svco-xxxx",
26 "runStatus": "Serving",
27 "deployedComputingUnits": 1,
28 "creator": "xxxx"
29 }
30 ]
31 }
32}
1{
2 requestId:'1bef3f87-c5b2-4419-936b-50f9884f10d4',
3 result: {
4 computeUnitInstance: {
5 instanceId: 'unit-xxx',
6 region: 'bj',
7 status: 'Running',
8 type: 'gpu-1',
9 totalComputeUnits: 4,
10 usedComputeUnits: 2,
11 paymentTiming: 'Prepaid',
12 startTime: '2024-12-03T06:24:03Z',
13 expiredTime: '2025-01-03T06:24:03Z',
14 reservationLength: 1,
15 reservationTimeUnit: 'MONTH',
16 creator: 'xxx',
17 autoRenew: {
18 renewTime: 4,
19 renewTimeUnit: 'month'
20 }
21 },
22 serviceInfoList: [
23 {
24 serviceName: 'xxxx',
25 serviceId: 'svco-xxxx',
26 runStatus: 'Serving',
27 deployedComputingUnits: 1,
28 creator: 'xxxx'
29 }
30 ]
31 }
32}
请求参数
名称 | 类型 | 必填 | 描述 |
---|---|---|---|
instanceId | string | 是 | 实例ID,说明:该字段通过调用购买算力单元接口,返回的instanceId获取 |
返回参数
名称 | 类型 | 描述 |
---|---|---|
requestId | string | 请求ID |
result | object | 请求结果 |
result说明
名称 | 类型 | 描述 |
---|---|---|
computeUnitInstance | object | 资源信息 |
serviceUsageList | List<object> | 服务信息 |
computeUnitInstance说明
名称 | 类型 | 描述 |
---|---|---|
instanceId | string | 实例ID |
region | string | 资源地域,具体值如下: · bj:北京 · bd:保定 · sz:苏州 · gz:广州 · yq:阳泉 · global:全局 |
status | string | 资源状态,具体值如下: · Creating:创建中 · CreateFailed:创建失败 · Running:使用中 · Releasing:释放中 · Released:已释放 · Reconfiguring:变配中 · ReconfigureFailed:变配失败 · BillingChanging:计费变更中 |
type | string | 资源类型,具体值如下: · CPU:cpu · 加速卡I型:gpu-1 · 加速卡Ⅱ型:gpu-2 · 加速卡Ⅲ型:gpu-3 · 加速卡Ⅳ型:gpu-4 · 加速卡Ⅴ型:gpu-5 · 加速卡Ⅵ型:gpu-6 |
totalComputeUnits | int | 算力单元总数 |
usedComputeUnits | int | 已用算力单元数 |
paymentTiming | string | 资源付费类型,具体值如下: · Prepaid:预付费 · Postpaid:后付费 |
startTime | string | 算力单元实例的开始时间 |
expiredTime | string | 算力单元实例的到期时间 |
releaseTime | string | 自动释放时间,说明:当资源付费类型为后付费且有设置自动释放时间时,返回该字段 |
reservationLength | int | 实例时长,说明:当资源付费类型为预付费,即paymentTiming=Prepaid时,返回该字段 |
reservationTimeUnit | string | 实例时长单位,说明:当资源付费类型为预付费,即paymentTiming=Prepaid时,返回该字段 |
creator | string | 资源创建人 |
autoRenew | object | 自动续费设置信息,说明:当资源付费类型为预付费且有设置自动续费规则时,返回该字段 |
autoRenew说明
名称 | 类型 | 描述 |
---|---|---|
renewTime | int | 续费时长 |
renewTimeUnit | string | 续费时长单位,具体值如下: · MONTH:月 · YEAR:年 |
serviceUsageList说明
名称 | 类型 | 描述 |
---|---|---|
serviceName | string | 服务名称 |
serviceId | string | 服务ID |
runStatus | string | 服务状态,具体值如下: · New:待发布 · Deploying:发布中 · Serving:已发布 · Failed:发布失败 · Deactivating:下线中 · DeactivationFailed:下线失败 |
scaleStatus | string | 扩缩容状态,具体值如下: · ScalingIn:缩容中 · ScalingOut:扩容中 · ScalingFailed:扩缩容失败 |
deployedComputingUnits | int | 部署使用算力单元数,等于单副本算力单元数*部署副本数 |
creator | string | 创建人 |