查询算力单元实例信息
更新时间:2024-07-18
功能介绍
本接口用于查询当前服务已使用的全部或特定算力单元实例信息,且只能获取配置相关信息。
SDK调用
使用说明
调用本文API,需使用安全认证AK/SK鉴权,调用流程及鉴权介绍详见SDK安装及使用流程。
调用示例
import os
from qianfan import resources
# 使用安全认证AK/SK鉴权,通过环境变量方式初始化;替换下列示例中参数,安全认证Access Key替换your_iam_ak,Secret Key替换your_iam_sk
os.environ["QIANFAN_ACCESS_KEY"] = "your_iam_ak"
os.environ["QIANFAN_SECRET_KEY"] = "your_iam_sk"
resp = resources.Charge.get_service_resource_instance_info(
service_id="svco-48exxxa594",
instance_id="a0085162f7e8xxxx49d19e58e",
)
print(resp.body)
返回示例
{
"requestId":"1bef3f87-xxxx-936b-50f9884f10d4",
"result":{
"instance":{
"instanceId":"a0085162fxxxx0a49d19e58e",
"paymentTiming":"Prepaid",
"replicasCount":5,
"status":"Running",
"startTime":"2024-04-01T10:00:00Z",
"expiredTime":"2024-05-01T10:00:00Z"
}
}
}
请求参数
名称 | 类型 | 必填 | 描述 |
---|---|---|---|
service_id | string | 是 | 服务ID |
instance_id | string | 是 | 已购算力单元实例ID,说明: 该字段值通过调用购买算力单元实例接口,返回的instanceId获取 |
返回参数
名称 | 类型 | 描述 |
---|---|---|
requestId | string | 请求ID |
result | dict | 请求结果 |
result说明
名称 | 类型 | 描述 |
---|---|---|
instance | dict | 实例信息 |
instance说明
名称 | 类型 | 描述 |
---|---|---|
instanceId | string | 实例ID |
paymentTiming | string | 付费类型,说明: · Prepaid:预付费 · Postpaid:表示后付费 |
replicasCount | int | 算力单元实例包含的副本数量 |
status | string | 资源状态,说明: · Creating:创建中 · Running:使用中 · Deleted: 已过期 |
startTime | string | 开始时间,说明: · 当status为Creating,该字段为购买算力单元实例的订单的创建时间 · 当status为Running或Deleted,该字段返回算力单元实例的开始时间 |
expiredTime | string | 算力单元实例的到期时间,说明: · 当status为Creating,该字段返回空 · 当status为Running或Deleted,该字段返回算力单元实例的到期时间 |
HTTP调用
鉴权说明
调用本文API,使用“基于安全认证AK/SK”进行签名计算鉴权,即使用安全认证中的Access Key ID 和 Secret Access Key进行鉴权,具体鉴权认证机制参考HTTP调用鉴权说明。
请求说明
- 基本信息
请求地址: https://qianfan.baidubce.com/v2/charge
请求方式: POST
- Header参数
名称 | 类型 | 必填 | 描述 |
---|---|---|---|
Content-Type | string | 是 | 固定值application/json |
x-bce-date | string | 否 | 当前时间,遵循ISO8601规范,格式如2016-04-06T08:23:49Z |
Authorization | string | 是 | 用于验证请求合法性的认证信息,更多内容请参考鉴权认证机制,签名工具可参考IAM签名工具 |
- Query参数
名称 | 类型 | 必填 | 描述 |
---|---|---|---|
Action | string | 是 | 方法名称,固定值DescribeServiceResource |
- Body参数
名称 | 类型 | 必填 | 描述 |
---|---|---|---|
serviceId | string | 是 | 服务ID |
instanceId | string | 是 | 已购算力单元实例ID,说明:该字段值通过调用购买算力单元实例接口,返回的instanceId获取 |
响应说明
名称 | 类型 | 描述 |
---|---|---|
requestId | string | 请求ID |
result | object | 请求结果 |
result说明
名称 | 类型 | 描述 |
---|---|---|
instance | object | 实例信息 |
instances说明
名称 | 类型 | 描述 |
---|---|---|
instanceId | string | 实例ID |
paymentTiming | string | 付费类型,说明: · Prepaid:预付费 · Postpaid:表示后付费 |
replicasCount | int | 算力单元实例包含的副本数量 |
status | string | 资源状态,说明: · Creating:创建中 · Running:使用中 · Deleted: 已过期 |
startTime | string | 开始时间,说明: · 当status为Creating,该字段为购买算力单元实例的订单的创建时间 · 当status为Running或Deleted,该字段返回算力单元实例的开始时间 |
expiredTime | string | 算力单元实例的到期时间,说明: · 当status为Creating,该字段返回空 · 当status为Running或Deleted,该字段返回算力单元实例的到期时间 |
请求示例
curl --location 'https://qianfan.baidubce.com/v2/charge?Action=DescribeServiceResource' \
--header 'Authorization: bce-auth-v1/f0ee7a166b934f7xxxx79702c13/2023-09-19T13:42:13Z/180000/host;x-bce-date/9a8cfb8ee58a8f4xxxx0016e374525543' \
--header 'x-bce-date: 2023-09-19T13:37:10Z' \
--header 'Content-Type: application/json' \
--data '{
"serviceId":"svco-48esssdpa594",
"instanceId":"a0085162f7e8xxxx49d19e58e"
}'
响应示例
{
"requestId":"1bef3f87-xxxx-936b-50f9884f10d4",
"result":{
"instance":{
"instanceId":"a0085162fxxxx0a49d19e58e",
"paymentTiming":"Prepaid",
"replicasCount":5,
"status":"Running",
"startTime":"2024-04-01T10:00:00Z",
"expiredTime":"2024-05-01T10:00:00Z"
}
}
}
错误码
若请求错误,服务器将返回的JSON文本包含以下参数:
名称 | 描述 |
---|---|
error_code | 错误码 |
error_msg | 错误描述信息,帮助理解和解决发生的错误 |
例如失败返回:
{
"requestId":"1bef3f87-cxxxb-50f9884f10d4",
"code":"AccessDenied",
"message":"Access denied."
}
更多千帆大模型平台其他错误码,也可以查看错误码说明。