GetTemplate

Updated at:

Queries the details of a template by specifying a stack, a stack group, a change set, or a custom template.

Operation description

This topic provides an example on how to query the details of a template whose ID is 5ecd1e10-b0e9-4389-a565-e4c15efc**** in the cn-hangzhou region.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

ros:GetTemplate

get

stack

acs:ros:{#regionId}:{#accountId}:stack/{#stackId}

template

acs:ros:*:{#accountId}:template/{#templateId}

None None

Request parameters

Parameter

Type

Required

Description

Example

StackId

string

No

The ID of the stack.

Note

You must specify only one of the following parameters: StackId, ChangeSetId, StackGroupName, and TemplateId.

4a6c9851-3b0f-4f5f-b4ca-a14bf691****

RegionId

string

No

The region ID of the stack or stack group to which the template belongs. You can call the DescribeRegions operation to query the most recent region list.

cn-hangzhou

ChangeSetId

string

No

The ID of the change set.

Note

You must specify only one of the following parameters: StackId, ChangeSetId, StackGroupName, and TemplateId.

1f6521a4-05af-4975-afe9-bc4b45ad****

TemplateId

string

No

The ID of the template.

Both shared and private templates are supported. For a shared template, the TemplateId is the same as the TemplateARN. Use this value for the query.

Note

You must specify only one of the following parameters: StackId, ChangeSetId, StackGroupName, and TemplateId.

5ecd1e10-b0e9-4389-a565-e4c15efc****

TemplateVersion

string

No

The version of the template. This parameter takes effect only when TemplateId is specified.
For a shared template, this parameter is supported only when VersionOption is set to AllVersions. For more information, see SetTemplatePermission.

Valid values: v1 to v65000, and Draft. Valid values for shared templates: v1 to v65000.

v1

TemplateStage

string

No

The stage of the template. This parameter takes effect only when StackId, ChangeSetId, or StackGroupName is specified.

Valid values:

  • Processed: the parsed and transformed template. This is the default value.

  • Original: the original template specified by the user.

Processed

IncludePermission

string

No

Specifies whether to query the sharing information of the template. Valid values:

  • Enabled: queries the sharing information.

  • Disabled: does not query the sharing information. This is the default value.

Note

Only the template owner can query the sharing information.

Enabled

StackGroupName

string

No

The name of the stack group.

Note

You must specify only one of the following parameters: StackId, ChangeSetId, StackGroupName, and TemplateId.

MyStackGroup

IncludeTags

string

No

Specifies whether to query the tag information. Valid values:

  • Enabled: queries the tag information.

  • Disabled: does not query the tag information. This is the default value.

Note

This parameter takes effect only when TemplateId is specified.

Enabled

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

Response elements

Element

Type

Description

Example

object

TemplateARN

string

The ARN of the template. This parameter is returned only when TemplateId is specified.

acs:ros:*:151266687691****:template/a52f81be-496f-4e1c-a286-8852ab54****

Description

string

The description of the template. This parameter is returned only when TemplateId is specified.

ROS template for create ECS instance.

RequestId

string

The ID of the request.

B288A0BE-D927-4888-B0F7-B35EF84****

CreateTime

string

The time when the template was created. The time is displayed in the YYYY-MM-DDThh:mm:ss format. This parameter is returned only when TemplateId is specified.

Note
  • If TemplateVersion is specified, the creation time of the template of the specified version is returned.

  • If TemplateVersion is not specified, the creation time of the template of the default version is returned.

2020-11-18T08:49:26

StackGroupName

string

The name of the stack group. This parameter is returned only when StackGroupName is specified.

MyStackGroup

TemplateVersion

string

The version of the template. This parameter is returned only when TemplateId is specified.
If TemplateVersion is not specified or does not take effect, this parameter indicates the current version of the template.

For a shared template, this parameter is returned only when VersionOption is set to AllVersions.

v1

TemplateBody

string

The content of the template.

{"ROSTemplateFormatVersion": "2015-09-01"}

ChangeSetId

string

The ID of the change set. This parameter is returned only when ChangeSetId is specified.

e85abe0c-6528-43fb-ae93-fdf8de22****

OwnerId

string

The Alibaba Cloud account ID to which the template belongs. This parameter is returned only when TemplateId is specified.

151266687691****

UpdateTime

string

The time when the template was last updated. The time is displayed in the YYYY-MM-DDThh:mm:ss format. This parameter is returned only when TemplateId is specified.

Note
  • If TemplateVersion is specified, the last update time of the template of the specified version is returned.

  • If TemplateVersion is not specified, the last update time of the template is returned.

2020-12-07T06:11:48

Permissions

array<object>

The sharing status of the template. This parameter is returned only when TemplateId is specified and IncludePermission is set to Enabled.

Note
  • If TemplateVersion is not specified or does not take effect, the sharing status of the template is returned.

  • If TemplateVersion is specified and takes effect, the sharing status of the template associated with the version is returned.

object

VersionOption

string

The shared version option. This parameter is returned only when ShareOption is set to ShareToAccounts.

Valid values:

  • AllVersions: shares all versions of shared template.

  • Latest: shares only the latest version of shared template. When a new version is added to shared template, the shared version changes accordingly to always remain the latest.

  • Current: shares only the current latest version of shared template. When a new version is added to shared template, the shared version remains unchanged.

  • Specified: shares only a specified version of shared template.

AllVersions

AccountId

string

The Alibaba Cloud account with which the template is shared.

142437958638****

ShareOption

string

The sharing option.

Valid value: ShareToAccounts, which indicates that the template is shared with other Alibaba Cloud accounts.

ShareToAccounts

TemplateVersion

string

The shared template version. This parameter is returned when ShareOption is set to ShareToAccounts and VersionOption is set to Specified or Current.

When the TemplateVersion parameter is set to Draft, if the Draft version exists, Draft is returned. If the Draft version does not exist or has been deleted, the current latest version is returned.

Valid values: v1 to v65000, and Draft.

v1

ShareSource

string

The source of the sharing relationship. Valid values:

  • ROS: the sharing relationship is established by using the ROS console or API.

  • ResourceDirectory: the sharing relationship is established for accounts in a resource directory by using the resource sharing feature in Resource Management.

Note
  • Sharing from ROS and sharing from Resource Directory have independent quotas.

  • Sharing from Resource Directory cannot be canceled or overwritten by using the ROS console or API.

  • Sharing from Resource Directory can overwrite sharing from ROS.

ROS

TemplateName

string

The name of the template. This parameter is returned only when TemplateId is specified.

Note
  • If TemplateVersion is specified, the name of the template associated with the version is returned.

  • If TemplateVersion is not specified, the name of the template is returned.

MyTemplate

RegionId

string

The region ID of the stack or stack group to which the template belongs. This parameter is returned only when StackId, ChangeSetId, or StackGroupName is specified.

cn-hangzhou

TemplateId

string

The ID of the template. This parameter is returned only when TemplateId is specified.

For a shared template, the returned value is the same as the TemplateARN.

a52f81be-496f-4e1c-a286-8852ab54****

StackId

string

The ID of the stack. This parameter is returned only when StackId is specified.

4a6c9851-3b0f-4f5f-b4ca-a14bf691****

ShareType

string

The sharing type of the template. This parameter is returned only when TemplateId is specified.

Valid values:

  • Private: the template is owned by the user.

  • Shared: the template is shared by another user.

Private

ResourceGroupId

string

The ID of the resource group.

rg-acfmxazb4ph6aiy****

Interface

string

The interface description.

{}

Tags

array<object>

The tags of the template.

object

The tags of the template.

Key

string

The tag key of the template.

usage

Value

string

The tag value of the template.

test

AdditionalInfo

object

The supplementary information of the public template.

{"DeploymentDuration":null,"Title":"Self-Built_ElasticSearch_Snapshot_Saved_To_OSS","Labels":{"ResourceTypes":["ALIYUN::ECS::Instance","ALIYUN::ECS::SecurityGroup","ALIYUN::ECS::VPC","ALIYUN::ECS::VSwitch","ALIYUN::OSS::Bucket","ALIYUN::ROS::WaitCondition","ALIYUN::ROS::WaitConditionHandle"],"DeployTypes":["ROS"],"ApplicationScenes":["Other"]},"Provider":"ROS","Categories":["Solution"]}

Examples

Success response

JSON format

{
  "TemplateARN": "acs:ros:*:151266687691****:template/a52f81be-496f-4e1c-a286-8852ab54****",
  "Description": "ROS template for create ECS instance.",
  "RequestId": "B288A0BE-D927-4888-B0F7-B35EF84****",
  "CreateTime": "2020-11-18T08:49:26",
  "StackGroupName": "MyStackGroup",
  "TemplateVersion": "v1",
  "TemplateBody": "{\"ROSTemplateFormatVersion\": \"2015-09-01\"}",
  "ChangeSetId": "e85abe0c-6528-43fb-ae93-fdf8de22****",
  "OwnerId": "151266687691****",
  "UpdateTime": "2020-12-07T06:11:48",
  "Permissions": [
    {
      "VersionOption": "AllVersions",
      "AccountId": "142437958638****",
      "ShareOption": "ShareToAccounts",
      "TemplateVersion": "v1",
      "ShareSource": "ROS"
    }
  ],
  "TemplateName": "MyTemplate",
  "RegionId": "cn-hangzhou",
  "TemplateId": "a52f81be-496f-4e1c-a286-8852ab54****",
  "StackId": "4a6c9851-3b0f-4f5f-b4ca-a14bf691****\t",
  "ShareType": "Private",
  "ResourceGroupId": "rg-acfmxazb4ph6aiy****",
  "Interface": "{}",
  "Tags": [
    {
      "Key": "usage",
      "Value": "test"
    }
  ],
  "AdditionalInfo": {
    "DeploymentDuration": null,
    "Title": "Self-Built_ElasticSearch_Snapshot_Saved_To_OSS",
    "Labels": {
      "ResourceTypes": [
        "ALIYUN::ECS::Instance",
        "ALIYUN::ECS::SecurityGroup",
        "ALIYUN::ECS::VPC",
        "ALIYUN::ECS::VSwitch",
        "ALIYUN::OSS::Bucket",
        "ALIYUN::ROS::WaitCondition",
        "ALIYUN::ROS::WaitConditionHandle"
      ],
      "DeployTypes": [
        "ROS"
      ],
      "ApplicationScenes": [
        "其他"
      ]
    },
    "Provider": "ROS",
    "Categories": [
      "Solution"
    ]
  }
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.