通过QueryInstancePrice4Modify发起异步查询返回TaskId,通过GetResult4QueryInstancePrice4Modify接口根据TaskId获取变配价格。
注意事项
支持部署完成的应用
示例代码
查询kvstore变配价格
CommonRequest request = new CommonRequest();
request.setSysMethod(MethodType.POST);
request.setSysDomain("bpstudio.cn-hangzhou.aliyuncs.com");
request.setSysVersion("2021-09-31");
request.setSysAction("QueryInstancePrice4Modify");
Map<String, Object> params = Maps.newHashMap();
//升级配置UPGRADE,降级配置DOWNGRADE
params.put("orderType", "UPGRADE");
//分片数
params.put("number", "");
//实例规格
params.put("instance_class", "");
request.putQueryParameter("Configuration", JSON.toJSONString(params));
//应用id
request.putQueryParameter("ApplicationId", "");
//应用中实例id
request.putQueryParameter("InstanceId", "");
try {
CommonResponse response = getClient().getCommonResponse(request);
Map<String, Object> data = JSON.parseObject(response.getData(), Map.class);
String taskId = data.get("Data").toString();
} catch (ClientException e) {
e.printStackTrace();
throw e;
}
查询kvstore_prepaid_public_cn 或 tair变配价格
CommonRequest request = new CommonRequest();
request.setSysMethod(MethodType.POST);
request.setSysDomain("bpstudio.cn-hangzhou.aliyuncs.com");
request.setSysVersion("2021-09-31");
request.setSysAction("QueryInstancePrice4Modify");
Map<String, Object> params = Maps.newHashMap();
//升级配置UPGRADE,降级配置DOWNGRADE
params.put("orderType", "UPGRADE");
//分片数
params.put("shard_quantity", "");
//分片规格
params.put("shard_class", "");
request.putQueryParameter("Configuration", JSON.toJSONString(params));
//应用id
request.putQueryParameter("ApplicationId", "");
//应用中实例id
request.putQueryParameter("InstanceId", "");
try {
CommonResponse response = getClient().getCommonResponse(request);
Map<String, Object> data = JSON.parseObject(response.getData(), Map.class);
String taskId = data.get("Data").toString();
} catch (ClientException e) {
e.printStackTrace();
throw e;
}
查询ecs变配价格
CommonRequest request = new CommonRequest();
request.setSysMethod(MethodType.POST);
request.setSysDomain("bpstudio.cn-hangzhou.aliyuncs.com");
request.setSysVersion("2021-09-31");
request.setSysAction("QueryInstancePrice4Modify");
Map<String, Object> params = Maps.newHashMap();
//1.预付费 升级配置Upgrade,降级配置Downgrade,2.后付费只支持Upgrade
params.put("orderType", "Upgrade");
//实例规格
params.put("instance_type", "");
request.putQueryParameter("Configuration", JSON.toJSONString(params));
//应用id
request.putQueryParameter("ApplicationId", "");
//方案中实例id
request.putQueryParameter("InstanceId", "");
try {
CommonResponse response = getClient().getCommonResponse(request);
Map<String, Object> data = JSON.parseObject(response.getData(), Map.class);
String taskId = data.get("Data").toString();
} catch (ClientException e) {
e.printStackTrace();
throw e;
}
查询rds变配价格
CommonRequest request = new CommonRequest();
request.setSysMethod(MethodType.POST);
request.setSysDomain("bpstudio.cn-hangzhou.aliyuncs.com");
request.setSysVersion("2021-09-31");
request.setSysAction("QueryInstancePrice4Modify");
Map<String, Object> params = Maps.newHashMap();
//升级配置UPGRADE,降级配置DOWNGRADE
params.put("orderType", "UPGRADE");
//实例规格
params.put("instance_type", "");
//容量
params.put("instance_storage", "");
request.putQueryParameter("Configuration", JSON.toJSONString(params));
//应用id
request.putQueryParameter("ApplicationId", "");
//应用中实例id
request.putQueryParameter("InstanceId", "");
try {
CommonResponse response = getClient().getCommonResponse(request);
Map<String, Object> data = JSON.parseObject(response.getData(), Map.class);
String taskId = data.get("Data").toString();
} catch (ClientException e) {
e.printStackTrace();
throw e;
}
通过taskId获取变配价格
CommonRequest request = new CommonRequest();
request.setSysMethod(MethodType.POST);
request.setSysDomain("bpstudio.cn-hangzhou.aliyuncs.com");
request.setSysVersion("2021-09-31");
request.setSysProtocol(ProtocolType.HTTPS);
request.setSysAction("GetResult4QueryInstancePrice4Modify");
//通过QueryInstancePrice4Modify接口获取taskId
request.putQueryParameter("TaskId", taskId);
//应用id
request.putQueryParameter("ApplicationId", appId);
try {
CommonResponse response = getClient().getCommonResponse(request);
Map<String, Object> data = JSON.parseObject(response.getData(), Map.class);
Map<String, Object> result = (Map<String, Object>) data.get("Data");
List<Map<String, Object>> priceList = (List<Map<String, Object>>) result.get("PriceList");
} catch (ClientException e) {
e.printStackTrace();
throw e;
}
GetResult4QueryInstancePrice4Modify返回结果
params中传递params.put("period_unit", "Month");params.put("period", "1");将会返回三个价格
如果不传递period_unit,period将只返回变配后应该支付金额
[
//变配后应该支付金额
{
"PriceUnit": "元",
"NodeType": "rds",
"TradeAmount": 212.74,
"OriginalAmount": 212.74,
"DiscountAmount": 0.0
},
//原规格价格
{
"PromotionName": "",
"PriceUnit": "元/月",
"NodeType": "RDS",
"TradeAmount": 765.0,
"OriginalAmount": 765.0,
"DiscountAmount": 0.0
},
//新规格价格
{
"PromotionName": "",
"PriceUnit": "元/月",
"NodeType": "RDS",
"TradeAmount": 974.0,
"OriginalAmount": 974.0,
"DiscountAmount": 0.0
}
]
文档内容是否对您有帮助?