
# 根据产品规格查询价格（旧）
#### 功能介绍
自建平台根据产品目录，获取不同规格产品对应的华为云官网价格。
注意事项：
- 新订购产品，或者续订产品，均可以调用该接口询价。
- 该接口可以使用客户AK/SK或者Token调用。
- 
- 该接口不支持查询预留实例产品价格
  ![](https://support.huaweicloud.com/api-oce/public_sys-resources/note_3.0-zh-cn.png)
  该接口即将下线，"根据产品规格查询价格"新接口请参考[查询按需产品价格-ListOnDemandResourceRatings](https://support.huaweicloud.com/api-oce/bcloud_01001.html)和[查询包年/包月产品价格-ListRateOnPeriodDetail](https://support.huaweicloud.com/api-oce/bcloud_01002.html)。
  
 
#### URI
POST /v1.0/{domain_id}/customer/product-mgr/query-rating
参数说明请参见[表1]。
 表1URI参数说明 
| 参数        | 是否必选 | 取值范围    | 描述                                                                                            |
|:---|:---|:---|:---|
| domain_id | 是    | 最大长度：64 | 客户账号ID。获取方法请参见[如何获取客户的customer_id](https://support.huaweicloud.com/api-oce/offl_110002.html)。 |
   
#### 请求消息
**请求参数**
| 参数                         | 是否必选 | 参数类型                | 取值范围            | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
|:---|:---|:---|:---|:---|
| tenantId                   | 是    | String              | 最大长度：128        | 项目ID。 访问"[我的凭证](https://console.huaweicloud.com/iam/#/myCredential)"页面，在"项目列表"页签，可以查看不同所属区域对应的项目ID。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| regionId                   | 是    | String              | 最大长度：128        | 区域ID。 取值为[地区和终端节点](https://developer.huaweicloud.com/endpoint)中查询的对应云服务的"区域"列的值。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| avaliableZoneId            | 否    | String              | 最大长度：128        | AvalibleZoneID，可用区ID。 此参数不携带或携带值为空串或携带值为null时，不作为筛选条件。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| chargingMode               | 是    | Integer             | \[0\|1\|2\]     | 计费模式： - 0：包年/包月；  - 1：按需；  - 2：一次性（指下单完成后，会进行一次性服务，服务完成后即结束。如安全专家服务、硬件安装服务等）；                                                                                                                                                                                                                                                                                                                                                                               |
| periodType                 | 否    | Integer             | \[0-5\]         | 订购周期类型： - 0：天  - 2：月  - 3：年  - 4：小时  - 5：绝对时间   当periodType为"5：绝对时间"的时候，追加产品的周期类型由relativeResourcePeriodType(即关联资源周期类型)的取值决定。 包年/包月计费询价必填。 当计费模式不为包年/包月时，此参数不携带或携带值为空串或携带值为null时，不作为筛选条件。 |
| periodNum                  | 否    | Integer             | \[1-214783647\] | 订购周期数。 包年/包月计费，且订购周期类型非5时必填。 当不满足上述条件时，此参数不携带或携带值为空串或携带值为null时，不作为筛选条件。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| periodEndDate              | 否    | String              | 最大长度：40         | 到期时间。 包年/包月云服务器追加云硬盘或者包年/包月共享带宽新增弹性IP时，填写云服务器或共享带宽的到期时间。 包年/包月计费，且订购周期类型为5时必填。 UTC时间，格式：yyyy-MM-dd'T'HH:mm:ss'Z'，如"2019-05-06T08:05:01Z"。 其中，HH范围是0～23，mm和ss范围是0～59。 为空的时候默认当前时间。 此参数不携带或携带值为空串或携带值为null时，默认当前时间。                                                                                                                                                                                                                                                                                                                             |
| relativeResourceId         | 否    | String              | 最大长度：64         | 关联资源标识。 包年/包月云服务器追加云硬盘或者包年/包月共享带宽新增弹性IP时，填写云服务器或共享带宽的实例标识。 当不满足上述条件时，此参数不携带或携带值为空串或携带值为null时，不作为筛选条件。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| relativeResourcePeriodType | 否    | Integer             | \[0-4\]         | 关联资源周期类型： - 0：天  - 2：月  - 3：年  - 4：小时   传关联资源标识时必填。 当不满足上述条件时，此参数不携带或携带值为空串或携带值为null时，不作为筛选条件。                                                                                                                                                                                                                    |
| subscriptionNum            | 是    | Integer             | \[1-10000\]     | 订购数量。 预留字段，当前默认为1。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| productInfos               | 是    | List\<ProductInfo\> | \[1-100\]       | 产品信息。 具体请参见[表2]。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| inquiryTime                | 否    | String              | 最大长度：40         | 询价时间。 UTC时间，格式：yyyy-MM-dd'T'HH:mm:ss'Z'，如"2019-05-06T08:05:01Z"。 为空的时候默认当前时间。 此参数不携带或携带值为空串或携带值为null时，默认当前时间。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
   
 表2ProductInfo 
| 参数                   | 是否必选 | 参数类型        | 取值范围            | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
|:---|:---|:---|:---|:---|
| id                   | 是    | String      | 最大长度：128        | ID标识。 同一次询价中不能重复，用于标识返回询价结果和请求的映射关系。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| cloudServiceType     | 是    | String      | 最大长度：400        | 云服务类型编码，例如OBS的云服务类型编码为"hws.service.type.obs"。您可以调用[查询云服务类型列表-ListServiceTypes](https://support.huaweicloud.com/api-oce/zh-cn_topic_0000001256679455.html)接口获取。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| resourceType         | 是    | String      | 最大长度：400        | 资源类型编码，例如ECS的VM为"hws.resource.type.vm"。您可以调用[查询资源类型列表-ListResourceTypes](https://support.huaweicloud.com/api-oce/zh-cn_topic_0000001256519451.html)接口获取。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| resourceSpecCode     | 是    | String      | 最大长度：400        | 云服务产品的资源规格。如果是VM的资源规格，则需要在规格后面添加".win"或".linux"，例如"s2.small.1.linux"。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| resourceSize         | 否    | Integer     | \[1-214783647\] | 资源容量大小，与"resouceSizeMeasureId"配合。 例如购买的卷大小或带宽大小。 此参数不携带或携带值为null时，不作为筛选条件；不支持携带值为空串。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| resouceSizeMeasureId | 否    | Integer     | -               | 资源容量度量标识，枚举值如下： - 15：Mbps（购买带宽时使用）  - 17：GB（购买云硬盘时使用）   此参数不携带或携带值为空串或携带值为null时，不作为筛选条件。                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| usageFactor          | 否    | String      | 最大长度：400        | 使用量因子。 按需计费必填。 取值和话单中的使用量因子一致，云服务和使用量因子对应关系如下： - 云服务器：Duration  - 云硬盘：Duration  - 弹性IP：Duration  - 带宽：Duration（按带宽询价）或upflow（按流量询价）  - 市场镜像：Duration   非按需计费时，此参数不携带或携带值为空串或携带值为null，不做筛选条件。 |
| usageValue           | 否    | Double      | 最大值：99999999999 | 使用量值。 按需询价必填。 例如按小时询价，使用量值为1，使用量单位为小时。 非按需计费时，此参数不携带或携带值为空串或携带值为null，不做筛选条件。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| usageMeasureId       | 否    | Integer     | -               | 使用量单位标识。 按需询价必填。 例如按小时询价，使用量值为1，使用量单位为小时。 枚举值如下： - 4：小时  - 10：GB（带宽按流量询价使用）  - 11：MB（带宽按流量询价使用）  - 13：Byte（带宽按流量询价使用）   非按需计费时，此参数不携带或携带值为空串或携带值为null，不做筛选条件。                                                                   |
| extendParams         | 否    | String/JSON | 最大长度：10240      | 扩展参数，可空。 此参数不携带或携带值为空串或携带值为null，不做筛选条件。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
   
**请求示例**
```
POST https://bss.myhuaweicloud.com/v1.0/{domain_id}/customer/product-mgr/query-rating  HTTP/1.1
Content-Type: application/json
X-Auth-Token：MIIPAgYJKoZIhvcNAQcCo...ggg1BBIINPXsidG9rZ
{
    "regionId": "cn-north-1",
    "tenantId": "74******cf27",
    "chargingMode": 0,
    "periodType": 2,
    "periodNum": 1,
    "subscriptionNum": 1,
    "periodEndDate": "",
    "productInfos": [
        {
            "id": "1",
            "cloudServiceType": "hws.service.type.ec2",
            "resourceType": "hws.resource.type.vm",
            "resourceSpecCode": "s2.small.1.linux"
        },
        {
            "id": "2",
            "cloudServiceType": "hws.service.type.ebs",
            "resourceType": "hws.resource.type.volume",
            "resourceSpecCode": "SATA",
            "resourceSize": 1,
            "resouceSizeMeasureId": 17
        },
        {
            "id": "3",
            "cloudServiceType": "hws.service.type.vpc",
            "resourceType": "hws.resource.type.ip",
            "resourceSpecCode": "5_bgp"
        },
        {
            "id": "4",
            "cloudServiceType": "hws.service.type.vpc",
            "resourceType": "hws.resource.type.bandwidth",
            "resourceSpecCode": "19_bgp",
            "resourceSize": 1,
            "resouceSizeMeasureId": 15
        }
    ],
    "inquiryTime": ""
}
```
#### 响应消息
**响应参数**
| 参数           | 参数类型         | 描述                                                                                                         |
|:---|:---|:---|
| error_code   | String       | 状态码。 具体请参见[状态码]。 |
| error_msg    | String       | 错误描述信息。                                                                                                    |
| ratingResult | RatingResult | 询价结果。 具体请参见[表3]       |
   
 表3RatingResult 
| 参数                  | 参数类型                        | 取值范围      | 描述                                                                                                                                                                                                                                                                                                                                                                          |
|:---|:---|:---|:---|
| amount              | Double                      | -         | 订单总额，即最终优惠后的订单金额。                                                                                                                                                                                                                                                                                                                                                           |
| discountAmount      | Double                      | -         | 订单优惠额。                                                                                                                                                                                                                                                                                                                                                                      |
| originalAmount      | Double                      | -         | 订单原总额，即优惠前订单总额。                                                                                                                                                                                                                                                                                                                                                             |
| measureId           | Integer                     | -         | 度量单位标识： - 1：元  - 2：角  - 3：分   |
| currency            | String                      | 最大长度：10   | 货币单位代码（遵循ISO 4217标准）。 CNY：人民币 值为空代表人民币。                                                                                                                                                                                                                                                    |
| productRatingResult | List\<ProductRatingResult\> | -         | 产品询价结果。 具体请参见[表4]。                                                                                                                                                                                                                                                                      |
| extendParams        | String/JSON                 | 最大长度：1024 | 扩展参数。                                                                                                                                                                                                                                                                                                                                                                       |
   
 表4ProductRatingResult 
| 参数             | 参数类型        | 取值范围      | 描述                                                                                                                                                                                                                                                                                                                                                                  |
|:---|:---|:---|:---|
| id             | String      | 最大长度：36   | ID标识，来源于请求中的ID。                                                                                                                                                                                                                                                                                                                                                     |
| productId      | String      | 最大长度：64   | 产品ID。                                                                                                                                                                                                                                                                                                                                                               |
| amount         | Double      | -         | 总额，即最终优惠后的金额。                                                                                                                                                                                                                                                                                                                                                       |
| originalAmount | Double      | -         | 产品原总金额。                                                                                                                                                                                                                                                                                                                                                             |
| discountAmount | Double      | -         | 优惠额。                                                                                                                                                                                                                                                                                                                                                                |
| measureId      | Integer     | -         | 度量单位标识： - 1：元  - 2：角  - 3：分   |
| extendParams   | String/JSON | 最大长度：1024 | 扩展参数。                                                                                                                                                                                                                                                                                                                                                               |
   
**响应示例**
```
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: length
Date: response time  
{
    "ratingResult": {
        "amount": 55.5,
        "discountAmount": 0,
        "originalAmount": 55.5,
        "measureId": 1,
        "currency": null,
        "extendParams": null,
        "productRatingResult": [
            {
                "id": "1",
                "productId": "00301-52002-0--0",
                "amount": 32.2,
                "discountAmount": 0,
                "originalAmount": 32.2,
                "measureId": 1,
                "extendParams": null
            },
            {
                "id": "2",
                "productId": "d5******24",
                "amount": 0.3,
                "discountAmount": 0,
                "originalAmount": 0.3,
                "measureId": 1,
                "extendParams": null
            },
            {
                "id": "3",
                "productId": "da27*****ce08",
                "amount": 0,
                "discountAmount": 0,
                "originalAmount": 0,
                "measureId": 1,
                "extendParams": null
            },
            {
                "id": "4",
                "productId": "605*****d4d8",
                "amount": 23,
                "discountAmount": 0,
                "originalAmount": 23,
                "measureId": 1,
                "extendParams": null
            }
        ]
    },
    "error_code": "CBC.0000",
    "error_msg": "Success"
}
```
 #### 状态码
![](https://support.huaweicloud.com/api-oce/public_sys-resources/note_3.0-zh-cn.png)
- 状态码4xx：由于明显的客户端错误（例如，格式错误的请求语法、参数错误等），华为云会返回4xx错误码，请及时检查请求消息的正确性，重新发起请求。
- 状态码5xx：由于华为云系统原因，导致无法完成明显有效请求的处理，可及时联系华为云客服处理。
 
| HTTP状态码 | 错误码      | 描述                                                                                                                                                    |
|:---|:---|:---|
| 200     | CBC.0000 | 成功。                                                                                                                                                   |
| 400     | CBC.0100 | 参数错误。                                                                                                                                                 |
| 403     | CBC.0151 | 拒绝访问。                                                                                                                                                 |
| 200     | CBC.6006 | 找不到您询价的产品。 如果报此错误，请检查请求参数中的"productInfos"中 "cloudServiceType"、"resourceType"、"resourceSpecCode"及其他参数是否填写正确。 |
| 200     | CBC.6055 | 询价结果超过金额最大限制。                                                                                                                                         |
| 500     | CBC.0999 | 其他错误。                                                                                                                                                 |
   
