Queries the values of one or more parameters in a template.

Description

This topic provides an example on how to query the values of a parameter. In this example, the values of the ZoneInfo parameter in a template that is created in the China (Hangzhou) region are queried. The template body is {"Parameters":{"ZoneInfo":{"Type": "String"},"InstanceType": {"Type": "String"}},"ROSTemplateFormatVersion": "2015-09-01","Resources":{"ECS":{"Properties":{"ZoneId":{"Ref": "ZoneInfo"},"InstanceType": {"Ref": "InstanceType"}},"Type": "ALIYUN::ECS::Instance"}}}.

For more information about the template parameters whose values you can query by calling this operation and the sample code of the template, see Query the constraints of parameters.

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 GetTemplateParameterConstraints

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

TemplateBody String No {"Parameters":{"ZoneInfo":{"Type": "String"},"InstanceType": {"Type": "String"}},"ROSTemplateFormatVersion": "2015-09-01","Resources":{"ECS":{"Properties":{"ZoneId":{"Ref": "ZoneInfo"},"InstanceType": {"Ref": "InstanceType"}},"Type": "ALIYUN::ECS::Instance"}}}

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 exactly one of the following parameters: TemplateBody, TemplateURL, and TemplateId.
RegionId String Yes cn-hangzhou

The ID of the region.

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

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 Object Storage Service (OSS) bucket, such as oss://ros/template/demo or oss://ros/template/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 exactly one of the following parameters: TemplateBody, TemplateURL, and TemplateId.
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 exactly one of the following parameters: TemplateBody, TemplateURL, and TemplateId.
TemplateVersion String No v1

The version of the template. If you do not specify this parameter, the latest version is used.

Note This parameter takes effect only when the TemplateId parameter is specified.
Parameters.N.ParameterKey String Yes ZoneInfo

The name of parameter N that is defined in the template.

Note The Parameters parameter is optional. If you specify Parameters, you must specify Parameters.N.ParameterKey.
Parameters.N.ParameterValue String Yes cn-hangzhou-h

The value of parameter N that is defined in the template.

Note The Parameters parameter is optional. If you specify Parameters, you must specify Parameters.N.ParameterValue.
ParametersKeyFilter Array of String No ZoneInfo

The parameters whose values you want to query.

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 token, but you must make sure that the token 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.

ParametersOrder Array of String No ["ZoneId", "InstanceType"]

The order in which associated parameters are arranged.

Note By default, the order of the associated parameters specified in the Metadata section of the template is used.
StackId String No c754d2a4-28f1-46df-b557-9586173a****

The ID of the stack.

If you specify this parameter in a request, the request is used to query the values of parameters whose configurations are changed.

Response parameters

Parameter Type Example Description
RequestId String 9816785B-BCF8-514D-8B76-C1EC2BC954FC

The ID of the request.

ParameterConstraints Array of ParameterConstraint

The constraints of the parameters.

ParameterKey String ZoneInfo

The name of the parameter.

Type String String

The data type of the parameter.

AllowedValues Array of String cn-hangzhou-h

The values of the parameter.

Behavior String NoLimit

The behavior of the parameter. Valid values:

  • NoLimit: No limit is imposed on the value of this parameter.
  • NotSupport: The value of this parameter cannot be queried.
  • QueryError: This parameter failed to be queried.
Note If the AllowedValues parameter is not returned, the Behavior and BehaviorReason parameters are returned.
BehaviorReason String No resource property refer to the parameter

The reason why the behavior of the parameter is returned.

AssociationParameterNames Array of String InstanceType

The names of the associated parameters.

IllegalValueByParameterConstraints Array of Any cn-hangzhou-h

The values that do not conform to the parameter constraints.

Note If the AllowedValues parameter is returned, the IllegalValueByParameterConstraints and IllegalValueByRules parameters are returned at the same time.
IllegalValueByRules Array of Any cn-hangzhou-h

The values that do not match the rules in the template.

Note If the AllowedValues parameter is returned, the IllegalValueByParameterConstraints and IllegalValueByRules parameters are returned at the same time.
NotSupportResources Array of NotSupportResource

The unsupported resources in the template.

ResourceType String ALIYUN::ECS::InstanceGroup

The type of the resource.

PropertyName String InstanceName

The name of the resource property.

QueryErrors Array of QueryError

The error details that are returned if the request fails.

ResourceType String ALIYUN::ECS::InstanceGroup

The type of the resource.

ResourceName String MyECS

The name of the resource.

ResourceType String InstanceType is needed while query DataDisk

The error message.

Examples

Sample requests

http(s)://ros.aliyuncs.com/?Action=GetTemplateParameterConstraints
&TemplateBody={"Parameters":{"ZoneInfo":{"Type": "String"},"InstanceType": {"Type": "String"}},"ROSTemplateFormatVersion": "2015-09-01","Resources":{"ECS":{"Properties":{"ZoneId":{"Ref": "ZoneInfo"},"InstanceType": {"Ref": "InstanceType"}},"Type": "ALIYUN::ECS::Instance"}}}
&RegionId=cn-hangzhou
&ParametersKeyFilter=["ZoneInfo"]
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<GetTemplateParameterConstraintsResponse>
    <RequestId>9816785B-BCF8-514D-8B76-C1EC2BC954FC</RequestId>
    <ParameterConstraints>
        <ParameterKey>ZoneInfo</ParameterKey>
        <Type>String</Type>
        <AllowedValues>cn-hangzhou-i</AllowedValues>
        <AllowedValues>cn-hangzhou-k</AllowedValues>
        <AllowedValues>cn-hangzhou-d</AllowedValues>
        <AssociationParameterNames>InstanceType</AssociationParameterNames>
        <IllegalValueByParameterConstraints>cn-hangzhou-h</IllegalValueByParameterConstraints>
        <IllegalValueByRules>cn-hangzhou-h</IllegalValueByRules>
    </ParameterConstraints>
</GetTemplateParameterConstraintsResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "9816785B-BCF8-514D-8B76-C1EC2BC954FC",
  "ParameterConstraints" : [ {
    "ParameterKey" : "ZoneInfo",
    "Type" : "String",
    "AllowedValues" : [ "cn-hangzhou-i", "cn-hangzhou-k", "cn-hangzhou-d" ],
    "AssociationParameterNames" : [ "InstanceType" ],
    "IllegalValueByParameterConstraints" : [ "cn-hangzhou-h" ],
    "IllegalValueByRules" : [ "cn-hangzhou-h" ]
  } ]
}

Error codes

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