Queries the estimated prices of the resources in a template.

Description

  • For more information about the resources that support price inquiry in Resource Orchestration Service (ROS) templates, see the Resource types that support price inquiry section of the Estimate resource prices topic.
  • For more information about the resources that support price inquiry in Terraform templates, see the "ROS resources supported by Terraform" section of the ROS features and resources supported by Terraform topic.

This topic provides an example on how to query the estimated price of an elastic IP address (EIP) that you want to create by using a template. In this example, the template body is {"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}}}}.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes GetTemplateEstimateCost

The operation that you want to perform. Set the value to GetTemplateEstimateCost.

TemplateURL String No oss://ros-template/demo

The URL of the file that contains the template body. The URL must point to a template that is located on an HTTP or HTTPS web server or in an Alibaba Cloud Object Storage Service (OSS) bucket, such as oss://ros/stack-policy/demo or oss://ros/stack-policy/demo?RegionId=cn-hangzhou. The template body can be up to 524,288 bytes in length. If you do not specify the region ID of the OSS bucket, the value of the RegionId parameter is used.

Note You must specify only one of the following parameters: TemplateBody, TemplateURL, TemplateId, and TemplateScratchId.
RegionId String Yes cn-hangzhou

The region ID of the stack. You can call the DescribeRegions operation to query the most recent region list.

TemplateBody String No {"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}}}}

The structure that contains the template body. The template body must be 1 to 524,288 bytes in length. If the length of the template body exceeds the upper limit, we recommend that you add parameters to the HTTP POST request body to prevent request failures caused by excessively long URLs.

Note You must specify only one of the following parameters: TemplateBody, TemplateURL, TemplateId, and TemplateScratchId.
ClientToken String No 123e4567-e89b-12d3-a456-42665544****

The client token that is used to ensure the idempotence of the request. You can use the client to generate the value, but you must make sure that the value is unique among different requests.

The token can be up to 64 characters in length, and can contain letters, digits, hyphens (-), and underscores (_).

For more information, see Ensure idempotence.

TemplateId String No 5ecd1e10-b0e9-4389-a565-e4c15efc****

The ID of the template. This parameter applies to shared and private templates.

Note You must specify only one of the following parameters: TemplateBody, TemplateURL, TemplateId, and TemplateScratchId.
TemplateVersion String No v1

The version of the template. This parameter takes effect only when the TemplateId parameter is specified.

Parameters.N.ParameterKey String Yes Name

The name of parameter N. If you do not specify the name and value of a parameter, ROS uses the default name and value that are specified in the template.

Maximum value of N: 200.

Examples:

  • Parameters.1.ParameterKey: Name
  • Parameters.2.ParameterKey: Netmode
Note The Parameters parameter is optional. If you want to specify Parameters, you must specify both Parameters.N.ParameterKey and Parameters.N.ParameterValue.
Parameters.N.ParameterValue String Yes DemoEip

The value of parameter N.

Maximum value of N: 200.

Examples:

  • Parameters.1.ParameterValue: DemoEip
  • Parameters.2.ParameterValue: public
Note The Parameters parameter is optional. If you want to specify Parameters, you must specify both Parameters.N.ParameterKey and Parameters.N.ParameterValue.
TemplateScratchId String No ts-aa9c62feab844a6b****

The ID of the scenario.

For more information about how to query the IDs of scenarios, see ListTemplateScratches.

Note You must specify only one of the following parameters: TemplateBody, TemplateURL, TemplateId, and TemplateScratchId.
TemplateScratchRegionId String No cn-hangzhou

The region ID of the scenario. The default value is the same as the value of the RegionId parameter.

You can call the DescribeRegions operation to query the most recent region list.

For more information about common request parameters, see Common parameters.

Response parameters

Parameter Type Example Description
RequestId String 6DEA36EF-C97D-5658-A4AC-4F5DB08D1A89

The ID of the request.

Resources Map

Details of the resource.

The following table describes the parameters that are contained in the Resources parameter.

Parameter

Type

Example

Description

Order

The information about the order.

TaxAmount

Long

0

The amount of tax.

OptionalPromotions

Array

[]

The available promotions.

Currency

String

CNY

The unit of the currency. Valid values:

CNY: The value is available only on the China site (aliyun.com).

USD: The value is available only on the International site (alibabacloud.com).

RuleIds

Array

[102204102264****]

The IDs of the promotion rules.

TradeAmount

Long

109.37

The transaction price of the order. The transaction price is equal to the original price minus the discount.

OptionalMixPromotions

Array

[]

The available mixed promotions.

OriginalAmount

Long

125

The original price.

DiscountAmount

Long

15.63

The deducted amount of money.

Rules

Details of the promotion rules.

Name

String

Contract discount_order discount_8.750 discount

The name of the promotion rule.

RuleDescId

Long

102204102264****

The ID of the promotion rule.

OrderSupplement

The supplementary information about the order.

ChargeType

String

PrePaid

The billing method.

Period

Long

1

The subscription duration.

Quantity

Long

1

The quantity.

PriceType

String

Total

The price type.

PeriodUnit

String

Month

The unit of the subscription duration.

OrderDetails

Details of the order.

ModuleCode

String

bandwidth

The code of the module.

ModuleName

String

Bandwidth

The name of the module.

Currency

String

CNY

The type of the currency.

TradeAmount

Long

109.37

The transaction price of the order.

OriginalAmount

Long

125

The original price of the order.

DiscountAmount

Long

15.63

The discount amount of the order.

Examples

Sample requests

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"}]
&<Common request parameters>

Sample success responses

XML format

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>Bandwidth</ModuleName>
                    <Currency>CNY</Currency>
                    <TradeAmount>109.37</TradeAmount>
                    <OriginalAmount>125</OriginalAmount>
                    <DiscountAmount>15.63</DiscountAmount>
                </OrderDetails>
                <Rules>
                    <Rule>
                        <RuleDescId>102204102264****</RuleDescId>
                        <Name>Contract discount_order discount_8.750 discount</Name>
                    </Rule>
                </Rules>
            </Result>
        </NewEip>
    </Resources>
</GetTemplateEstimateCostResponse>

JSON format

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" : "Bandwidth",
          "Currency" : "CNY",
          "TradeAmount" : 109.37,
          "OriginalAmount" : 125,
          "DiscountAmount" : 15.63
        } ],
        "Rules" : {
          "Rule" : [ {
            "RuleDescId" : "102204102264****",
            "Name" : "Contract discount_order discount_8.750 discount"
          } ]
        }
      }
    }
  }
}

Error codes

For a list of error codes, see Service error codes.

HTTP status code

Error code

Error message

Description

400

CircularDependency

Circular Dependency Found: {reason}.

The error message returned because the template contains a circular dependency. reason indicates the cause of the error.

400

InvalidSchema

{reason}.

The error message returned because the template format is invalid. reason indicates the cause of the error.

400

InvalidTemplateAttribute

The Referenced Attribute ({resource} {name}) is incorrect.

The error message returned because the template contains an invalid reference of the resource property in the Outputs section. resource indicates the resource name. name indicates the property name.

400

InvalidTemplatePropertyType

The specified value type of ({resource} {section}) is incorrect.

The error message returned because the type of the resource property that is defined in a section of the template is invalid. resource indicates the resource name. section indicates the section name.

400

InvalidTemplateReference

The specified reference "{name}" (in {referencer}) is incorrect.

The error message returned because the template contains an invalid reference. name indicates the reference name. referencer indicates the referencer name.

400

InvalidTemplateSection

The template section is invalid: {section}.

The error message returned because the template contains an invalid section. section indicates the section name.

400

InvalidTemplateVersion

The template version is invalid: {reason}.

The error message returned because the template version is invalid. reason indicates the cause of the error.

400

StackValidationFailed

{reason}.

The error message returned because the stack failed to be validated. reason indicates the cause of the error.

400

UnknownUserParameter

The Parameter ({name}) was not defined in template.

The error message returned because the specified parameter is not defined in the template. name indicates the parameter name.

400

UserParameterMissing

The Parameter {name} was not provided.

The error message returned because no value is specified for the parameter defined in the template. name indicates the parameter name.

404

TemplateNotFound

The Template ({ ID }) could not be found.

The error message returned because the template does not exist. ID indicates the ID of the template.

404

TemplateNotFound

The Template { ID } with version { version } could not be found.

The error message returned because the specified template or template version does not exist. ID indicates the ID of the template. version indicates the version of the template.