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
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
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. |
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:
|
protocol |
No |
String |
Request protocol used by APIG to access the microservice.
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.
Default: NONE |
cors |
No |
Boolean |
Whether CORS is supported. By default, it is 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 |
CCE Service details. This parameter is required if service_type is set to CCE_SERVICE. |
|
nacos_info |
No |
MicroServiceInfoNacosBase object |
Nacos basic information. |
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 |
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.
Default value: NORMAL Default: SWA |
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 |
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.
|
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. |
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 |
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 |
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. |
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 |
Response Parameters
Status code: 201
Parameter |
Type |
Description |
---|---|---|
vpc_channel_id |
String |
VPC channel ID. |
api_group_id |
String |
API group ID. |
apis |
Array of MicroserviceImportApiResp objects |
Imported APIs. |
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.
|
Status code: 400
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code. |
error_msg |
String |
Error message. |
Status code: 401
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code. |
error_msg |
String |
Error message. |
Status code: 403
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code. |
error_msg |
String |
Error message. |
Status code: 404
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code. |
error_msg |
String |
Error message. |
Status code: 500
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.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot