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

Importing a Microservice

Function

This API is used to import a microservice.

Calling Method

For details, see Calling APIs.

URI

POST /v2/{project_id}/apigw/instances/{instance_id}/microservice/import

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain it, see Obtaining a Project ID.

instance_id

Yes

String

Gateway ID, which can be obtained from the gateway information on the APIG console.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token. It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is a token.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

group_info

Yes

MicroserviceGroup object

Information about the API group to import a microservice to.

service_type

Yes

String

Microservice center type. Options:

  • CSE: CSE microservice registration center

  • CCE: CCE workload

  • CCE_SERVICE: CCE Service

  • NACOS: Nacos registration center. nacos_info is mandatory.

protocol

No

String

Request protocol used by APIG to access the microservice.

  • HTTP

  • HTTPS

Default: HTTPS

apis

Yes

Array of MicroserviceApiCreate objects

Imported APIs.

Array Length: 1 - 50

backend_timeout

No

Integer

Timeout allowed for APIG to request the backend service. You can set the maximum timeout using the backend_timeout configuration item. The maximum value is 600,000, and the default value is 5000.

Unit: ms.

Minimum: 1

Default: 5000

auth_type

No

String

API authentication mode. By default, authentication is not required.

  • NONE

  • APP

  • IAM

Default: NONE

cors

No

Boolean

Whether CORS is supported. By default, it is not supported.

  • true: Supported.

  • false: Not supported.

Default: false

cse_info

No

MicroServiceInfoCSECreate object

CSE microservice details. This parameter is required if service_type is set to CSE.

cce_info

No

MicroServiceInfoCCECreate object

CCE workload details. This parameter is required if service_type is set to CCE.

cce_service_info

No

MicroServiceInfoCCEServiceCreate object

CCE Service details. This parameter is required if service_type is set to CCE_SERVICE.

nacos_info

No

MicroServiceInfoNacosBase object

Nacos basic information.

Table 4 MicroserviceGroup

Parameter

Mandatory

Type

Description

group_id

No

String

An existing group. If this parameter is left empty, a new group is created.

Minimum: 0

Maximum: 64

group_name

No

String

Name of the API group. This parameter is required when group_id is empty.

Enter 3 to 255 characters, starting with a letter or digit. Only letters, digits, and these special characters are allowed: -_./:()

Minimum: 3

Maximum: 255

app_id

No

String

Integration application to which the new group belongs. This parameter is required when group_id is empty.

Minimum: 0

Maximum: 64

Table 5 MicroserviceApiCreate

Parameter

Mandatory

Type

Description

name

No

String

API name.

Start with a letter or digit, and use only letters, digits, and these special characters: -_./:()

Minimum: 3

Maximum: 255

req_method

No

String

Request method.

Default: ANY

req_uri

Yes

String

Request address, which can contain request parameters enclosed with braces ({}). For example, /getUserInfo/{userId}. Special characters, such as asterisks (*), slashes (/), percent signs (%), hyphens (-), underscores (_), and periods (.), are allowed. It can contain a maximum of 512 characters and must comply with URI specifications.

/apic/health_check is the preset health check path of APIG. If req_method=GET is passed, req_uri=/apic/health_check is not supported.

NOTE:

The address must comply with the URI specifications.

Minimum: 1

Maximum: 512

match_mode

No

String

API matching mode.

  • SWA: Prefix match.

  • NORMAL: Exact match.

Default value: NORMAL

Default: SWA

Table 6 MicroServiceInfoCSECreate

Parameter

Mandatory

Type

Description

engine_id

Yes

String

Microservice engine ID.

Maximum: 64

service_id

Yes

String

Microservice ID.

Maximum: 64

version

Yes

String

Microservice version.

Maximum: 64

Table 7 MicroServiceInfoCCECreate

Parameter

Mandatory

Type

Description

cluster_id

Yes

String

CCE cluster ID.

Maximum: 64

namespace

Yes

String

Namespace.

Maximum: 64

workload_type

Yes

String

Workload type.

  • deployment

  • statefulset

  • daemonset

app_name

No

String

App name. Start with a letter, and include only letters, digits, periods (.), hyphens (-), and underscores (_). (1 to 64 characters)

Minimum: 1

Maximum: 64

label_key

No

String

Service label key. Start with a letter or digit, and use only letters, digits, and these special characters: -_./:(). (1 to 64 characters)

Minimum: 1

Maximum: 64

label_value

No

String

Service label value. Start with a letter, and include only letters, digits, periods (.), hyphens (-), and underscores (_). (1 to 64 characters)

Minimum: 1

Maximum: 64

version

No

String

Workload version.

Maximum: 64

port

Yes

Integer

Listening port No. of the workload.

Minimum: 1

Maximum: 65535

labels

No

Array of MicroserviceLabel objects

Workload label list.

Table 8 MicroserviceLabel

Parameter

Mandatory

Type

Description

label_name

Yes

String

Tag name.

Start and end with a letter or digit. Use only letters, digits, hyphens (-), underscores (_), and periods (.). (Max. 63 characters.)

Minimum: 1

Maximum: 63

label_value

Yes

String

Tag value.

Start and end with a letter or digit. Use only letters, digits, hyphens (-), underscores (_), and periods (.). (Max. 63 characters.)

Minimum: 1

Maximum: 63

Table 9 MicroServiceInfoCCEServiceCreate

Parameter

Mandatory

Type

Description

cluster_id

Yes

String

CCE cluster ID.

Maximum: 64

namespace

Yes

String

Namespace. 1 to 63 characters. Use lowercase letters, digits, and hyphens (-). Start with a letter and end with a letter or digit.

Minimum: 1

Maximum: 63

service_name

Yes

String

Service name. Start with a letter, and use only letters, digits, periods (.), hyphens (-), and underscores (_). (1 to 64 characters)

Minimum: 1

Maximum: 64

port

No

Integer

Service listening port. For a multi-port service, you only need to enter one port number.

Minimum: 1

Maximum: 65535

Table 10 MicroServiceInfoNacosBase

Parameter

Mandatory

Type

Description

namespace

No

String

Namespace ID. If the default namespace public is used, leave this parameter empty. Only letters, numbers, hyphens (-), underscores (_) are allowed. Max.: 64 characters

Minimum: 0

Maximum: 64

cluster_name

No

String

Cluster name. The default value is DEFAULT. Only letters, numbers, hyphens (-), underscores (_) are allowed. Max.: 64 characters

Minimum: 0

Maximum: 64

group_name

No

String

Group name. The default value is DEFAULT_GROUP. Only letters, numbers, hyphens (-), underscores (_), periods (.), and colons (:) are allowed. Max.: 128 characters

Minimum: 0

Maximum: 128

service_name

Yes

String

Microservice name. The value cannot start with @ or contain @@. Max.: 512 characters

Minimum: 1

Maximum: 512

server_config

Yes

Array of NacosServerConfig objects

Nacos server configurations.

Array Length: 1 - 9

user_info

Yes

NacosUserInfo object

Nacos user information.

Table 11 NacosServerConfig

Parameter

Mandatory

Type

Description

ip_address

Yes

String

IP address of the Nacos server. Do not enter Chinese characters.

Minimum: 7

Maximum: 128

port

Yes

Integer

Port number of the Nacos server. Range: 1–65535.

Minimum: 1

Maximum: 65535

grpc_port

No

Integer

gRPC port number of the Nacos server. Default: port number + 1000 Range: 1–65535.

Minimum: 1

Maximum: 65535

Table 12 NacosUserInfo

Parameter

Mandatory

Type

Description

user_name

Yes

String

Nacos username.

Minimum: 1

Maximum: 64

password

Yes

String

Nacos password.

Minimum: 1

Maximum: 64

Response Parameters

Status code: 201

Table 13 Response body parameters

Parameter

Type

Description

vpc_channel_id

String

VPC channel ID.

api_group_id

String

API group ID.

apis

Array of MicroserviceImportApiResp objects

Imported APIs.

Table 14 MicroserviceImportApiResp

Parameter

Type

Description

name

String

API name.

req_uri

String

Request path.

req_method

String

Request method.

id

String

API ID.

match_mode

String

API matching mode.

  • SWA: Prefix match.

  • NORMAL: Exact match.

    Default value: SWA

Status code: 400

Table 15 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 401

Table 16 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 403

Table 17 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 404

Table 18 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 500

Table 19 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Example Requests

  • Importing a CSE microservice

    {
      "group_info" : {
        "group_id" : "6329eaa17736412b988536179cd8d662",
        "group_name" : "",
        "app_id" : ""
      },
      "service_type" : "CSE",
      "protocol" : "HTTPS",
      "apis" : [ {
        "name" : "api1",
        "req_method" : "ANY",
        "req_uri" : "/test",
        "match_mode" : "SWA"
      } ],
      "backend_timeout" : 5000,
      "auth_type" : "NONE",
      "cors" : false,
      "cse_info" : {
        "engine_id" : "fde2c21c-5bd9-40f0-ad6a-81e4b6782805a",
        "service_id" : "92919f98fba80c2df13cc285c983946c90e635ff",
        "version" : "1.0.0"
      }
    }
  • Importing a CCE Deployment

    {
      "group_info" : {
        "group_id" : "6329eaa17736412b988536179cd8d662",
        "group_name" : "",
        "app_id" : ""
      },
      "service_type" : "CCE",
      "protocol" : "HTTPS",
      "apis" : [ {
        "name" : "dp",
        "req_method" : "ANY",
        "req_uri" : "/test",
        "match_mode" : "SWA"
      } ],
      "backend_timeout" : 5000,
      "auth_type" : "NONE",
      "cors" : false,
      "cce_info" : {
        "cluster_id" : "11069278-f9f8-11ec-b1b2-0255ac100b06",
        "namespace" : "test",
        "workload_type" : "deployment",
        "app_name" : "dp",
        "port" : 80,
        "labels" : [ {
          "label_name" : "cluster_id",
          "label_value" : "c429700c-5dc4-482a-9c0e-99f6c0635113"
        } ]
      }
    }

Example Responses

Status code: 201

success

  • Example 1

    {
      "vpc_channel_id" : "9d075537ff314a5e8e5c98bf29549b89",
      "api_group_id" : "6329eaa17736412b988536179cd8d662",
      "apis" : [ {
        "id" : "72e667087fe140529f81995b213dadbe",
        "name" : "api1",
        "req_uri" : "/test",
        "req_method" : "ANY",
        "match_mode" : "SWA"
      } ]
    }
  • Example 2

    {
      "vpc_channel_id" : "3f56e9d4a747486caa4cfb59a47b6854",
      "api_group_id" : "6329eaa17736412b988536179cd8d662",
      "apis" : [ {
        "id" : "3b52e2c05710470b88e283deb0a805e6",
        "name" : "dp_b09d",
        "req_uri" : "/test",
        "req_method" : "ANY",
        "match_mode" : "SWA"
      } ]
    }

Status code: 400

Bad Request

{
  "error_code" : "APIG.2011",
  "error_msg" : "Invalid parameter value,parameterName:name. Please refer to the support documentation"
}

Status code: 401

Unauthorized

{
  "error_code" : "APIG.1002",
  "error_msg" : "Incorrect token or token resolution failed"
}

Status code: 403

Forbidden

{
  "error_code" : "APIG.1005",
  "error_msg" : "No permissions to request this method"
}

Status code: 404

Not Found

{
  "error_code" : "APIG.3030",
  "error_msg" : "The instance does not exist;id:f0fa1789-3b76-433b-a787-9892951c620ec"
}

Status code: 500

Internal Server Error

{
  "error_code" : "APIG.9999",
  "error_msg" : "System error"
}

Status Codes

Status Code

Description

201

success

400

Bad Request

401

Unauthorized

403

Forbidden

404

Not Found

500

Internal Server Error

Error Codes

See Error Codes.

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