全部产品
Search
文档中心

资源编排:GetTemplateParameterConstraints - 获取模版参数约束

更新时间:May 11, 2023

调用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代码示例。

调试

授权信息

当前API暂无授权信息透出。

请求参数

名称类型必填描述示例值
TemplateBodystring

模板的结构。
长度为1~524,288个字节。如果长度较长,建议通过HTTP POST+Body Param的方式,将参数放在请求体中进行传递,避免URL过长而导致请求失败。

说明您必须且仅能指定TemplateBody、TemplateURL和TemplateId其中一个参数。
{"Parameters":{"ZoneInfo":{"Type": "String"},"InstanceType": {"Type": "String"}},"ROSTemplateFormatVersion": "2015-09-01","Resources":{"ECS":{"Properties":{"ZoneId":{"Ref": "ZoneInfo"},"InstanceType": {"Ref": "InstanceType"}},"Type": "ALIYUN::ECS::Instance"}}}
RegionIdstring

地域ID。
您可以调用DescribeRegions接口查看最新的阿里云地域列表。

cn-hangzhou
TemplateURLstring

包含模板主体的文件的位置。URL必须指向位于Web服务器(HTTP或HTTPS)或阿里云OSS存储空间(例如:oss://ros/template/demo或oss://ros/template/demo?RegionId=cn-hangzhou)中的模板,模板的最大长度为524,288个字节。如未指定OSS地域,默认与接口参数RegionId相同。

说明您必须且仅能指定TemplateBody、TemplateURL和TemplateId其中一个参数。
oss://ros-template/demo
TemplateIdstring

模板ID。支持共享模板和私有模板。

说明您必须且仅能指定TemplateBody、TemplateURL和TemplateId其中一个参数。
5ecd1e10-b0e9-4389-a565-e4c15efc****
TemplateVersionstring

模板版本。如果不指定,默认取最新版本。

说明TemplateVersion仅在指定TemplateId时生效。
v1
Parametersarray

模板中已定义的参数。

object
ParameterKeystring

模板中已定义的参数的名称。

说明Parameters为可选参数。若指定了Parameters,则ParameterKey为必选参数。
ZoneInfo
ParameterValuestring

模板中已定义的参数的取值。

说明Parameters为可选参数。若指定了Parameters,则ParameterValue为必选参数。
cn-hangzhou-h
ParametersKeyFilterarray

需要查询的参数列表。

string

需要查询的参数。

ZoneInfo
ClientTokenstring

保证请求的幂等性。 该值由客户端生成,并且必须是全局唯一的。长度不超过64个字符,可包含英文字母、数字、短划线(-)和下划线(_)。 更多信息,请参见如何保证幂等性

123e4567-e89b-12d3-a456-42665544****
ParametersOrderarray

参数依赖关系。

string

参数依赖关系的顺序。

说明默认按照模板中Metadata参数的依赖关系。
["ZoneId", "InstanceType"]
StackIdstring

资源栈ID。

当填写此参数时,表示查询变配场景的参数约束。

c754d2a4-28f1-46df-b557-9586173a****

返回参数

名称类型描述示例值
object
RequestIdstring

请求ID。

9816785B-BCF8-514D-8B76-C1EC2BC954FC
ParameterConstraintsarray

参数约束信息。

object
ParameterKeystring

参数的名称。

ZoneInfo
Typestring

参数的类型。

String
AllowedValuesarray

参数的取值列表。

string

参数的取值。

cn-hangzhou-h
Behaviorstring

参数的行为。取值:

  • NoLimit:无限制,此参数没有取值限制。

  • NotSupport:不支持,此参数不支持查询取值。

  • QueryError:查询失败。

说明当查询结果没有返回AllowedValues时,会额外返回Behavior和BehaviorReason,说明参数的行为和原因。
NoLimit
BehaviorReasonstring

参数行为出现的原因。

No resource property refer to the parameter
AssociationParameterNamesarray

关联参数列表。

string

关联参数名称的列表。

InstanceType
IllegalValueByParameterConstraintsarray

不符合参数约束的值列表。

说明当查询结果有返回AllowedValues时,会额外返回IllegalValueByParameterConstraints和IllegalValueByRules,说明被参数约束和模板规则过滤掉的不合法的值。
any

不符合参数约束的值。

说明当查询结果返回AllowedValues时,会同时返回被参数约束和模板规则过滤掉的不合法的值IllegalValueByParameterConstraintsIllegalValueByRules
cn-hangzhou-h
IllegalValueByRulesarray

不符合模板规则的值列表。

说明当查询结果有返回AllowedValues时,会额外返回IllegalValueByParameterConstraints和IllegalValueByRules,说明被参数约束和模板规则过滤掉的不合法的值。
any

不符合模板规则的值。

说明当查询结果返回AllowedValues时,会同时返回被参数约束和模板规则过滤掉的不合法的值IllegalValueByParameterConstraintsIllegalValueByRules
cn-hangzhou-h
NotSupportResourcesarray

不支持的资源详情。

object

不支持的资源详情。

Behavior取值为NotSupport时,返回该信息。

ResourceTypestring

资源类型。

ALIYUN::ECS::InstanceGroup
PropertyNamestring

资源属性名称。

InstanceName
QueryErrorsarray

查询失败的详情。

object

查询失败的详情。

Behavior取值为QueryError时,返回该信息。

ErrorMessagestring

错误详情。

ALIYUN::ECS::InstanceGroup
ResourceNamestring

资源名称。

MyECS
ResourceTypestring

资源类型。

InstanceType is needed while query DataDisk

示例

正常返回示例

JSON格式

{
  "RequestId": "9816785B-BCF8-514D-8B76-C1EC2BC954FC",
  "ParameterConstraints": [
    {
      "ParameterKey": "ZoneInfo",
      "Type": "String",
      "AllowedValues": [
        "cn-hangzhou-h"
      ],
      "Behavior": "NoLimit",
      "BehaviorReason": "No resource property refer to the parameter",
      "AssociationParameterNames": [
        "InstanceType"
      ],
      "IllegalValueByParameterConstraints": [
        "cn-hangzhou-h"
      ],
      "IllegalValueByRules": [
        "cn-hangzhou-h"
      ],
      "NotSupportResources": [
        {
          "ResourceType": "ALIYUN::ECS::InstanceGroup",
          "PropertyName": "InstanceName"
        }
      ],
      "QueryErrors": [
        {
          "ErrorMessage": "ALIYUN::ECS::InstanceGroup",
          "ResourceName": "MyECS",
          "ResourceType": "InstanceType is needed while query DataDisk"
        }
      ]
    }
  ]
}

错误码

访问错误中心查看更多错误码。