Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Creating a Template

Updated on 2022-02-22 GMT+08:00

Function

This API is used to create a template by uploading a local template to the server.

URI

POST /v2/templates

Request

  • Request parameters
    Table 1 Request parameters

    Parameter

    Mandatory

    Type

    Description

    resource

    Yes

    String

    Template content. For details, see UploadResource parameters.

    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.

    Table 2 UploadResource parameters

    Parameter

    Mandatory

    Type

    Description

    name

    Yes

    String

    Template name. The value must be 1 to 64 characters long and start with a letter, but cannot end with a hyphen (-). Only lowercase letters, digits, and hyphens are allowed.

    description

    No

    String

    Template description. The value supports a maximum of 255 characters. A Chinese character is regarded as multiple characters. The following characters are not allowed: <>()#%&/

    origin_template_url

    No

    String

    URL of the source template. This parameter is required when the template is uploaded by URL. The package must be in the .zip, .tar.gz, or .tgz format. The package name must comply with the regular expression ^[A-Za-z0-9][A-Za-z0-9_-]{0,254}$.

    scope

    No

    String

    Template application scope. Only the default value domain is supported.

    vendor

    No

    String

    Template provider. The value supports a maximum of 64 characters. A Chinese character is regarded as one character. The following characters are not allowed: <>()#%&/

    version

    Yes

    String

    Template version. The value supports a maximum of 24 characters and must meet the regular expression ^[a-zA-Z0-9_]+([-.][a-zA-Z0-9]+)*$.

    main_file_name

    No

    String

    Name of the main file of a template. If this parameter is left blank, the default value blueprint.yaml is used. The value supports a maximum of 255 characters. If this parameter is not left blank, the file name extension must be .yaml and the file name must comply with the regular expression ^[a-zA-Z0-9_]+([-.][a-zA-Z0-9]+)*$.

    project_id

    No

    String

    Project ID contained in the template to be uploaded.

    filename

    No

    String

    Name of the compressed package file. This parameter must be specified when the Internet Explorer is used. The value must be a string that supports a maximum of 64 characters.

    dsl_version

    No

    String

    If this parameter is not left blank, the DSL version of the uploaded template must be the same as the specified version. Otherwise, the template cannot be uploaded. DSL version of the template. Only cloud_tosca_version_1_0 is supported. By default, this parameter is left blank.

    content_type

    No

    String

    Template file type. The value can be yaml, json, or file.

    NOTE:

    Parameters in the preceding two template upload scenarios cannot be mixed up. Otherwise, an error will be reported.

    Table 3 Request headers

    Parameter

    Mandatory

    Type

    Description

    Content-Type

    Yes

    String

    multipart/form-data.

    X-Auth-Token

    Yes

    String

    Valid token (a user token with the op_cred permission and a short validity period). This parameter is mandatory on the account side.

    NOTE:

    For AOS API HTTP headers, if only parameters (in JSON format) are transmitted, Content-Type must be set to Application/json. Unless otherwise specified, other fields are the same as those listed in the preceding table.

  • Example request
    curl -k -X POST -H "X-Auth-Token: $token" -H "Content-Type:multipart/form-data" -F 'resource={"name": "test-agent-11","description":"aos","version": "1.0.1"}' -F "archive_content=@test-agent-1-1.0.tar.gz" https://aos.ae-ad-1.myhuaweicloud.com/v2/templates

Response

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

      Parameter

      Type

      Description

      id

      String

      Template ID

    • Example response
      {
          "id": "d078e49c-124c-7706-bcbb-81885661f431"
      }
  • Response when the request fails
    • Response parameters
      Table 5 Response parameters when the request fails

      Parameter

      Type

      Description

      message

      String

      Detailed reason why the request fails.

      code

      String

      Code for the reason why the request fails.

      extend

      String

      Extended reason why the request fails. This field is reserved for future use.

      NOTE:

      Unless otherwise specified, subsequent AOS API errors are returned in the following form:

    • Example response
      {
          "message": "Parameters validate err, The name should not be empty.",
          "code": "02000005",
          "extend": ""
      }

Status Code

  • Normal
    Table 6 Status code

    Status Code

    Description

    201

    The template is created successfully.

  • Abnormal
    Table 7 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.

    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.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback