调用GetTemplateParameterConstraints接口查询模板参数的取值。
使用说明
本文将提供一个示例,查询杭州地域模板{"Parameters":{"ZoneInfo":{"Type": "String"},"InstanceType": {"Type": "String"}},"ROSTemplateFormatVersion": "2015-09-01","Resources":{"ECS":{"Properties":{"ZoneId":{"Ref": "ZoneInfo"},"InstanceType": {"Ref": "InstanceType"}},"Type": "ALIYUN::ECS::Instance"}}}中参数ZoneInfo的取值。
关于本接口支持查询的参数和模板内容,请参见参数约束查询。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
请求参数
| 名称 | 类型 | 是否必选 | 示例值 | 描述 |
|---|---|---|---|---|
| Action | String | 是 | GetTemplateParameterConstraints | 要执行的操作,取值:GetTemplateParameterConstraints。 |
| TemplateBody | String | 否 | {"Parameters":{"ZoneInfo":{"Type": "String"},"InstanceType": {"Type": "String"}},"ROSTemplateFormatVersion": "2015-09-01","Resources":{"ECS":{"Properties":{"ZoneId":{"Ref": "ZoneInfo"},"InstanceType": {"Ref": "InstanceType"}},"Type": "ALIYUN::ECS::Instance"}}} | 模板的结构。 长度为1~524,288个字节。如果长度较长,建议通过HTTP POST+Body Param的方式,将参数放在请求体中进行传递,避免URL过长而导致请求失败。 说明 您必须且仅能指定TemplateBody、TemplateURL和TemplateId其中一个参数。 |
| RegionId | String | 是 | cn-hangzhou | 地域ID。 您可以调用DescribeRegions接口查看最新的阿里云地域列表。 |
| TemplateURL | String | 否 | oss://ros-template/demo | 包含模板主体的文件的位置。URL必须指向位于Web服务器(HTTP或HTTPS)或阿里云OSS存储空间(例如:oss://ros/template/demo或oss://ros/template/demo?RegionId=cn-hangzhou)中的模板,模板的最大长度为524,288个字节。如未指定OSS地域,默认与接口参数RegionId相同。 说明 您必须且仅能指定TemplateBody、TemplateURL和TemplateId其中一个参数。 |
| TemplateId | String | 否 | 5ecd1e10-b0e9-4389-a565-e4c15efc**** | 模板ID。支持共享模板和私有模板。 说明 您必须且仅能指定TemplateBody、TemplateURL和TemplateId其中一个参数。 |
| TemplateVersion | String | 否 | v1 | 模板版本。如果不指定,默认取最新版本。 说明 TemplateVersion仅在指定TemplateId时生效。 |
| Parameters.N.ParameterKey | String | 是 | ZoneInfo | 模板中已定义的参数的名称。 说明 Parameters为可选参数。若指定了Parameters,则ParameterKey为必选参数。 |
| Parameters.N.ParameterValue | String | 是 | cn-hangzhou-h | 模板中已定义的参数的取值。 说明 Parameters为可选参数。若指定了Parameters,则ParameterValue为必选参数。 |
| ParametersKeyFilter | Array of String | 否 | ZoneInfo | 需要查询的参数。 |
| ClientToken | String | 否 | 123e4567-e89b-12d3-a456-42665544**** | 保证请求的幂等性。 该值由客户端生成,并且必须是全局唯一的。长度不超过64个字符,可包含英文字母、数字、短划线(-)和下划线(_)。 更多信息,请参见如何保证幂等性。 |
| ParametersOrder | Array of String | 否 | ["ZoneId", "InstanceType"] | 参数依赖关系的顺序。 说明 默认按照模板中 Metadata参数的依赖关系。 |
| StackId | String | 否 | c754d2a4-28f1-46df-b557-9586173a**** | 资源栈ID。 当填写此参数时,表示查询变配场景的参数约束。 |
返回数据
| 名称 | 类型 | 示例值 | 描述 |
|---|---|---|---|
| RequestId | String | 9816785B-BCF8-514D-8B76-C1EC2BC954FC | 请求ID。 |
| ParameterConstraints | Array of ParameterConstraint | 参数约束信息。 |
|
| ParameterKey | String | ZoneInfo | 参数的名称。 |
| Type | String | String | 参数的类型。 |
| AllowedValues | Array of String | cn-hangzhou-h | 参数的取值。 |
| Behavior | String | NoLimit | 参数的行为。取值:
说明 当查询结果没有返回AllowedValues时,会额外返回Behavior和BehaviorReason,说明参数的行为和原因。 |
| BehaviorReason | String | No resource property refer to the parameter | 参数行为出现的原因。 |
| AssociationParameterNames | Array of String | InstanceType | 关联参数名称的列表。 |
| IllegalValueByParameterConstraints | Array of Any | cn-hangzhou-h | 不符合参数约束的值。 说明 当查询结果返回 AllowedValues时,会同时返回被参数约束和模板规则过滤掉的不合法的值IllegalValueByParameterConstraints和IllegalValueByRules。 |
| IllegalValueByRules | Array of Any | cn-hangzhou-h | 不符合模板规则的值。 说明 当查询结果返回 AllowedValues时,会同时返回被参数约束和模板规则过滤掉的不合法的值IllegalValueByParameterConstraints和IllegalValueByRules。 |
| NotSupportResources | Array of NotSupportResource | 不支持的资源详情。 |
|
| ResourceType | String | ALIYUN::ECS::InstanceGroup | 资源类型。 |
| PropertyName | String | InstanceName | 资源属性名称。 |
| QueryErrors | Array of QueryError | 查询失败的详情。 |
|
| ErrorMessage | String | ALIYUN::ECS::InstanceGroup | 错误详情。 |
| ResourceName | String | MyECS | 资源名称。 |
| ResourceType | String | InstanceType is needed while query DataDisk | 资源类型。 |
示例
请求示例
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"]
&公共请求参数
正常返回示例
XML格式
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格式
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" ]
} ]
}
错误码
访问错误中心查看更多错误码。