Updated on 2023-08-14 GMT+08:00

Updating a Template

Function

This API is used to update a template.

The update can be performed only when the template has not been used to create a stack.

The upload modes are as follows:

  • For local upload, upload the binary data of the local file directly.
  • For URL upload, enter the URL of the template file.

URI

PUT /v2/templates/{template_id}

Table 1 Parameter description

Parameter

Mandatory

Description

template_id

Yes

ID of the template to be updated.

Request

  • Request parameters
    Table 2 Request parameters

    Parameter

    Mandatory

    Data Type

    Description

    resource

    Yes

    String

    Template content. For details, see Table 2.

    archive_content

    No

    String or Binary

    The file must be in the ZIP, TAR.GZ, TGZ, YAML, or JSON format.

    When content_type is set to yaml or json, the parameter type is String and the value is a YAML or JSON string.

    If the value of content_type is set to file or left blank, the parameter type is Binary and the value is the binary content of the file.

Response message.

  • Response parameters
    Table 3 Response parameter when the request is successful

    Parameter

    Data Type

    Description

    id

    String

    Template ID.

  • Example response
    The following shows the response when the request is successful. For details about the response when the request fails, see Table 5.
    {
        "id": "d078e49c-124c-7706-bcbb-81885661f431"
    }

Status Codes

  • Normal
    Table 4 Status code

    Status Code

    Description

    200

    The template is updated successfully.

  • Abnormal
    Table 5 Status codes

    Status Code

    Description

    400

    The request cannot be parsed by the server due to incorrect parameters. Unless being modified, the request should not be sent again.

    404

    The requested resource does not exist.

    409

    The request cannot be completed due to a conflict with the current resource.

    500

    The server fails to process the request due to an unexpected condition.