All Products
Search
Document Center

CreateTemplate

Last Updated: Sep 02, 2019

You can call this operation to create a template.

Request parameters

Parameter Type Required Example Description
Action String Yes CreateTemplate The operation that you want to perform. Set this parameter to CreateTemplate.
TemplateName String Yes MyTemplate The name of the template. The template name can be up to 200 characters in length. The name can contain letters, digits, hyphens (-), and underscores (_). It cannot start with ALIYUN, ACS, ALIBABA, or ALICLOUD.
Content String Yes {“FormatVersion”: “OOS-2019-06-01”, “Description”: “Descirbe instances of given status”, “Parameters”: {“Status”: {“Type”: “String”, “Description”: “(Required) The status of the Ecs instance.”}}, “Tasks”: [{“Properties”: {“Parameters”: {“Status”: “{{ Status }}”}, “API”: “DescribeInstances”, “Service”: “Ecs”}, “Name”: “foo”, “Action”: “ACS::ExecuteApi”}]} The content of the template. The template must be in the JSON or YAML format. Maximum size: 64 KB.

Response parameters

Parameter Type Example Description
RequestId String 14A07460-EBE7-47CA-9757-12CC4761D47A The ID of the request.
Template The metadata of the template.
└ CreatedBy String root(13090000) The user who created the template.
└ CreatedDate String 2019-05-16T10:26:14Z The time when the template was created.
└ UpdatedBy String root(130900000) The user who updated the template.
└ UpdatedDate String 2019-05-16T10:26:14Z The time when the template was updated.
└ Description String Describe instances of given status The description of the template.
└ Hash String 4bc7d7a21b3e003434b9c223f6e6d2578b5ebfeb5be28c1fcf8a8a1b11907bb4 The encrypted SHA-256 hash code of the template content.
└ ShareType String Private The sharing mode of the template. The sharing mode of templates created by users is set to Private.
└ TemplateFormat String JSON The format of the template. The format can be JSON or YAML. The system automatically identifies the format.
└ TemplateName String MyTemplate The name of the template.
└ TemplateId String t-94753d38 The ID of the template.
└ TemplateVersion String v1 The version of the template. The version name consists of the letter v and a digit. The digit starts from 1.

Examples

Sample request

  1. https://oos.cn-hangzhou.aliyuncs.com/?Action=CreateTemplate
  2. &TemplateName=MyTemplate
  3. &Content=%7B%22FormatVersion%22%3A+%22OOS-2019-06-01%22%2C+%22Description%22%3A+%22Descirbe+instances+of+given+status%22%2C+%22Parameters%22%3A+%7B%22Status%22%3A+%7B%22Type%22%3A+%22String%22%2C+%22Description%22%3A+%22%28Required%29+The+status+of+the+Ecs+instance.%22%7D%7D%2C+%22Tasks%22%3A+%5B%7B%22Properties%22%3A+%7B%22Parameters%22%3A+%7B%22Status%22%3A+%22%7B%7B+Status+%7D%7D%22%7D%2C+%22API%22%3A+%22DescribeInstances%22%2C+%22Service%22%3A+%22ECS%22%7D%2C+%22Name%22%3A+%22describeInstances%22%2C+%22Action%22%3A+%22ACS%3A%3AExecuteAPI%22%7D%5D%7D
  4. &<Common request parameters>

Sample success response
JSON format

  1. {
  2. "RequestId": "20758A-585D-4A41-A9B2-28DA8F4F534F",
  3. "Template": {
  4. "CreatedBy": "root(130900000)",
  5. "CreatedDate": "2019-05-27T08:46:33Z",
  6. "UpdatedBy": "root(1309000000)",
  7. "UpdatedDate": "2019-05-27T08:46:33Z",
  8. "Description": "Descirbe instances of given status",
  9. "Hash": "4bc7d7a21b3e003434b9c223f6e6d2578b5ebfeb5be28c1fcf8a8a1b11907bb4",
  10. "ShareType": "Private",
  11. "TemplateFormat": "JSON",
  12. "TemplateName": "MyTemplate",
  13. "TemplateId": "t-94753eeaef8",
  14. "TemplateVersion": "v1"
  15. }
  16. }

Error codes

Error code HTTP status code Error message Description
InvalidVersion 400 The specified Version is invalid. The error message returned because the specified version is invalid. Specify a valid version in the URL and try again.
InvalidAction.NotFound 400 Specified api is not found, please check your url and method. The error message returned because the specified operation does not exist. Specify a valid value for the Action parameter.
Throttling.User 400 Request was denied due to user flow control. The error message returned because too many requests have been sent over a short period of time. Try again later.
User.NoPermission 401 User has no permission to do the action: ({api_name}) The error message returned because the user is not authorized to call this operation. Check whether the current user is authorized to call the OOS API operation in the RAM console.
InvalidStsToken 400 Invalid STS token to do the action: ({api_name}) The error message returned because the specified STS token is invalid.
ExpiredStsToken 400 Expired STS token to do the action: ({api_name}) The error message returned because the specified STS token has expired.
QuotaExceed 403 The Quota ({key}) exceeded ({value}). The error message returned because an upper limit is reached, such as the maximum numbers of templates and running executions.
InvalidAccountType 400 The account type ({account_type}) was not supported. The error message returned because the specified account type is not supported.
TemplateValidationError 400 {reason} The error message returned because the template failed the validation due to violations of data types, value ranges, or other constraints.
EntityAlreadyExist.Template 403 The template {name} already exist. The error message returned because the template already exists.