Updated on 2022-02-22 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

    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.

  • Example request
    {
       "name": "helloworld",
       "description": "helloworld blueprint new",
       "version": "1.0"
    }
    curl -k -X PUT -H "X-Auth-Token: $token" -H "Content-Type:multipart/form-data" -F "archive_content=@test-agent-1-1.0.tar.gz" https://aos.ae-ad-1.myhuaweicloud.com/v2/templates/d078e49c-124c-7706-bcbb-81885661f431

Response

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

    Parameter

    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 Code

  • Normal
    Table 4 Status code

    Status Code

    Description

    200

    The template is updated successfully.

  • Abnormal
    Table 5 Status code

    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.