调用GetTemplateEstimateCost接口查询模板中创建资源的预估价格。
使用说明
- ROS模板支持询价的资源,请参见预估资源价格的支持询价的资源类型章节。
- Terraform模板支持询价的资源,请参见Terraform支持的功能和资源 的ROS资源支持情况章节。
本文将提供一个示例,查询模板{"ROSTemplateFormatVersion": "2015-09-01", "Parameters": {"Isp": {"Type": "String"},
"Name": {"Type": "String"},"Netmode": {"Type": "String"}, "Bandwidth": {"Type": "Number",
"Default": 5}}, "Resources": {"NewEip": {"Type": "ALIYUN::VPC::EIP","Properties":
{"InstanceChargeType": "Prepaid", "PricingCycle": "Month", "Isp": {"Ref": "Isp"},
"Period": 1, "DeletionProtection": false, "AutoPay": false, "Name": {"Ref": "Name"},
"InternetChargeType": "PayByTraffic", "Netmode": { "Ref": "Netmode"},"Bandwidth":
5}}}}中创建的EIP资源的预估价格。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
请求参数
| 名称 | 类型 | 是否必选 | 示例值 | 描述 |
|---|---|---|---|---|
| Action | String | 是 | GetTemplateEstimateCost |
要执行的操作,取值:GetTemplateEstimateCost。 |
| TemplateURL | String | 否 | oss://ros-template/demo |
包含模板主体的文件的位置。URL必须指向位于Web服务器(HTTP或HTTPS)或阿里云OSS存储空间(例如:oss://ros/stack-policy/demo、oss://ros/stack-policy/demo?RegionId=cn-hangzhou)中的模板,模板的最大长度为524,288个字节。如未指定OSS地域,默认与RegionId取值相同。 说明 您必须且仅能指定TemplateBody、TemplateURL、TemplateId和TemplateScratchId其中一个参数。
|
| RegionId | String | 是 | cn-hangzhou |
资源栈所属的地域ID。您可以调用DescribeRegions查看最新的阿里云地域列表。 |
| TemplateBody | String | 否 | {"ROSTemplateFormatVersion": "2015-09-01", "Parameters": {"Isp": {"Type": "String"}, "Name": {"Type": "String"},"Netmode": {"Type": "String"}, "Bandwidth": {"Type": "Number", "Default": 5}}, "Resources": {"NewEip": {"Type": "ALIYUN::VPC::EIP","Properties": {"InstanceChargeType": "Prepaid", "PricingCycle": "Month", "Isp": {"Ref": "Isp"}, "Period": 1, "DeletionProtection": false, "AutoPay": false, "Name": {"Ref": "Name"}, "InternetChargeType": "PayByTraffic", "Netmode": { "Ref": "Netmode"},"Bandwidth": 5}}}} |
模板主体的结构。长度为1~524,288个字节。如果长度较长,则建议通过HTTP POST+Body Param的方式,将参数放在请求体中进行传递,避免因URL过长而导致请求失败。 说明 您必须且仅能指定TemplateBody、TemplateURL、TemplateId和TemplateScratchId其中一个参数。
|
| ClientToken | String | 否 | 123e4567-e89b-12d3-a456-42665544**** |
保证请求的幂等性。 该值由客户端生成,并且必须全局唯一。 长度不超过64个字符。可包含英文字母、数字、短划线(-)和下划线(_)。 更多信息,请参见如何保证幂等性。 |
| TemplateId | String | 否 | 5ecd1e10-b0e9-4389-a565-e4c15efc**** |
模板ID。支持共享模板和私有模板。 说明 您必须且仅能指定TemplateBody、TemplateURL、TemplateId和TemplateScratchId其中一个参数。
|
| TemplateVersion | String | 否 | v1 |
模板版本。仅在指定TemplateId时生效。 |
| Parameters.N.ParameterKey | String | 是 | Name |
参数的名称。如果未指定模板中定义的参数名称和参数值,ROS将使用模板中指定的默认值。 N的最大值为:200。 取值示例:
说明 Parameters为可选参数。如果需要指定Parameters,则Parameters.N.ParameterKey和Parameters.N.ParameterValue必须同时指定。
|
| Parameters.N.ParameterValue | String | 是 | DemoEip |
参数值。 N的最大值为:200。 取值示例:
说明 Parameters为可选参数。如果需要指定Parameters,则Parameters.N.ParameterKey和Parameters.N.ParameterValue必须同时指定。
|
| TemplateScratchId | String | 否 | ts-aa9c62feab844a6b**** |
资源场景ID。 关于如何获取资源场景ID,请参见ListTemplateScratches。 说明 您必须且仅能指定TemplateBody、TemplateURL、TemplateId和TemplateScratchId其中一个参数。
|
| TemplateScratchRegionId | String | 否 | cn-hangzhou |
资源场景所属的地域ID,默认与RegionId取值相同。 您可以调用DescribeRegions查看最新的阿里云地域列表。 |
关于公共请求参数的详情,请参见公共参数。
返回数据
| 名称 | 类型 | 示例值 | 描述 |
|---|---|---|---|
| RequestId | String | 6DEA36EF-C97D-5658-A4AC-4F5DB08D1A89 |
请求ID。 |
| Resources | Map |
资源详情。 |
Resources各参数含义如下所示。
|
名称 |
类型 |
示例值 |
描述 |
|---|---|---|---|
|
Order |
订单信息。 |
||
|
TaxAmount |
Long |
0 |
税额。 |
|
OptionalPromotions |
Array |
[] |
可选促销。 |
|
Currency |
String |
CNY |
货币单位。取值: CNY:该值仅适用于中国站。 USD:该值仅适用于国际站。 |
|
RuleIds |
Array |
[102204102264****] |
活动规则列表。 |
|
TradeAmount |
Long |
109.37 |
最终价,为原价减去折扣。 |
|
OptionalMixPromotions |
Array |
[] |
可选的混合促销。 |
|
OriginalAmount |
Long |
125 |
原价。 |
|
DiscountAmount |
Long |
15.63 |
抵扣金额。 |
|
Rules |
活动规则。 |
||
|
Name |
String |
合同优惠_整单_8.750折 |
活动规则名称。 |
|
RuleDescId |
Long |
102204102264**** |
活动ID。 |
|
OrderSupplement |
订单补充信息。 |
||
|
ChargeType |
String |
PrePaid |
付费方式。 |
|
Period |
Long |
1 |
计费时长。 |
|
Quantity |
Long |
1 |
数量。 |
|
PriceType |
String |
Total |
价格类型。 |
|
PeriodUnit |
String |
Month |
包年包月计费方式的时长单位。 |
|
OrderDetails |
订单详情信息。 |
||
|
ModuleCode |
String |
bandwidth |
模块标识。 |
|
ModuleName |
String |
带宽 |
模块名称。 |
|
Currency |
String |
CNY |
货币类型。 |
|
TradeAmount |
Long |
109.37 |
订单实际交易价。 |
|
OriginalAmount |
Long |
125 |
订单原价。 |
|
DiscountAmount |
Long |
15.63 |
订单优惠金额。 |
示例
请求示例
http(s)://ros.aliyuncs.com/?Action=GetTemplateEstimateCost
&RegionId=cn-hangzhou
&TemplateBody={"ROSTemplateFormatVersion": "2015-09-01", "Parameters": {"Isp": {"Type": "String"}, "Name": {"Type": "String"},"Netmode": {"Type": "String"}, "Bandwidth": {"Type": "Number", "Default": 5}}, "Resources": {"NewEip": {"Type": "ALIYUN::VPC::EIP","Properties": {"InstanceChargeType": "Prepaid", "PricingCycle": "Month", "Isp": {"Ref": "Isp"}, "Period": 1, "DeletionProtection": false, "AutoPay": false, "Name": {"Ref": "Name"}, "InternetChargeType": "PayByTraffic", "Netmode": { "Ref": "Netmode"},"Bandwidth": 5}}}}
&Parameters=[{"ParameterKey":"Name","ParameterValue":"DemoEip"}]
&公共请求参数
正常返回示例
XML格式
HTTP/1.1 200 OK
Content-Type:application/xml
<GetTemplateEstimateCostResponse>
<RequestId>6DEA36EF-C97D-5658-A4AC-4F5DB08D1A89</RequestId>
<Resources>
<NewEip>
<Type>ALIYUN::VPC::EIP</Type>
<Success>true</Success>
<Result>
<Order>
<TaxAmount>0</TaxAmount>
<TradeCycleAmount>0</TradeCycleAmount>
<RiCycleAmount>0</RiCycleAmount>
<Currency>CNY</Currency>
<TotalCostAmount>109.37</TotalCostAmount>
<RuleIds>102204102264****</RuleIds>
<TradeAmount>109.37</TradeAmount>
<DiscountCycleAmount>0</DiscountCycleAmount>
<OriginalAmount>125</OriginalAmount>
<DiscountAmount>15.63</DiscountAmount>
</Order>
<OrderSupplement>
<ChargeType>PrePaid</ChargeType>
<Period>1</Period>
<Quantity>1</Quantity>
<PriceType>Total</PriceType>
<PeriodUnit>Month</PeriodUnit>
</OrderSupplement>
<OrderDetails>
<ModuleCode>bandwidth</ModuleCode>
<ModuleName>带宽</ModuleName>
<Currency>CNY</Currency>
<TradeAmount>109.37</TradeAmount>
<OriginalAmount>125</OriginalAmount>
<DiscountAmount>15.63</DiscountAmount>
</OrderDetails>
<Rules>
<Rule>
<RuleDescId>102204102264****</RuleDescId>
<Name>合同优惠_整单_8.750折</Name>
</Rule>
</Rules>
</Result>
</NewEip>
</Resources>
</GetTemplateEstimateCostResponse>
JSON格式
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "6DEA36EF-C97D-5658-A4AC-4F5DB08D1A89",
"Resources" : {
"NewEip" : {
"Type" : "ALIYUN::VPC::EIP",
"Success" : true,
"Result" : {
"Order" : {
"TaxAmount" : 0,
"OptionalPromotions" : [ ],
"TradeCycleAmount" : 0,
"RiCycleAmount" : 0,
"Currency" : "CNY",
"TotalCostAmount" : 109.37,
"RuleIds" : [ "102204102264****" ],
"TradeAmount" : 109.37,
"DiscountCycleAmount" : 0,
"OriginalAmount" : 125,
"OptionalMixPromotions" : [ ],
"DiscountAmount" : 15.63
},
"OrderSupplement" : {
"ChargeType" : "PrePaid",
"Period" : 1,
"Quantity" : 1,
"PriceType" : "Total",
"PeriodUnit" : "Month"
},
"OrderDetails" : [ {
"ModuleCode" : "bandwidth",
"ModuleName" : "带宽",
"Currency" : "CNY",
"TradeAmount" : 109.37,
"OriginalAmount" : 125,
"DiscountAmount" : 15.63
} ],
"Rules" : {
"Rule" : [ {
"RuleDescId" : "102204102264****",
"Name" : "合同优惠_整单_8.750折"
} ]
}
}
}
}
}
错误码
访问错误中心查看更多错误码。
|
HttpCode |
错误码 |
错误信息 |
描述 |
|---|---|---|---|
|
400 |
CircularDependency |
Circular Dependency Found: {reason}. |
模板包含循环引用。reason为具体原因。 |
|
400 |
InvalidSchema |
{reason}. |
模板格式不正确。reason为具体原因。 |
|
400 |
InvalidTemplateAttribute |
The Referenced Attribute ({resource} {name}) is incorrect. |
模板包含不正确的资源属性(输出)引用。resource为资源名,name为属性名。 |
|
400 |
InvalidTemplatePropertyType |
The specified value type of ({resource} {section}) is incorrect. |
模板资源定义中的字段类型不正确。resource为资源名,section为字段名。 |
|
400 |
InvalidTemplateReference |
The specified reference "{name}" (in {referencer}) is incorrect. |
模板包含不正确的引用。name为引用名,referencer为引用者。 |
|
400 |
InvalidTemplateSection |
The template section is invalid: {section}. |
模板包含无效的字段。section为字段名。 |
|
400 |
InvalidTemplateVersion |
The template version is invalid: {reason}. |
模板版本不正确。reason为具体原因。 |
|
400 |
StackValidationFailed |
{reason}. |
资源栈校验失败。reason为具体原因。 |
|
400 |
UnknownUserParameter |
The Parameter ({name}) was not defined in template. |
传递的参数在模板中未定义。name为参数名。 |
|
400 |
UserParameterMissing |
The Parameter {name} was not provided. |
参数在模板中已定义,但未传递值。name为参数名。 |
|
404 |
TemplateNotFound |
The Template ({ ID }) could not be found. |
模板不存在。ID为模板ID。 |
|
404 |
TemplateNotFound |
The Template { ID } with version { version } could not be found. |
模板或指定版本不存在。ID为模板ID,version为模板版本。 |