Creating Static Information for a Microservice
Function
This API is used to create static information for a microservice before registering a microservice instance. The registered instance is associated with the static information based on the service_id field. One service corresponds to multiple instances. The service_id field can be customized. If service_id is not customized, the system generates a random service ID.
Constraints
None
URI
POST /v4/{project_id}/registry/microservices
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String | Unique ID of a tenant sub-project. Length: 1–64 characters. |
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| x-domain-name | Yes | String | Tenant account name. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| service | No | MicroService object | Microservice information. |
| rules | No | Array of Rule objects | Blacklist and whitelist. |
| instances | No | Array of MicroServiceInstance objects | Instance information. |
| tags | No | Object | Extended attribute. You can customize a key and value. The value contains at least 1 byte. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| serviceId | No | String | Microservice ID, which must be unique. Length: 1–64 characters. Regular expression: ^.*$ |
| environment | No | String | Service stage. Value: development, testing, acceptance, or production. Only when the value is development, testing, or acceptance, you can add new schemas or modify existing schemas in batches. Default value: development. |
| appId | Yes | String | Application ID, which must be unique. Length: 1–160 characters. Regular expression: ^[a-zA-Z0-9]$|^[a-zA-Z0-9][a-zA-Z0-9_-.][a-zA-Z0-9]$ |
| serviceName | Yes | String | Microservice name, which must be unique in an application. Length: 1–128 characters. Regular expression: ^[a-zA-Z0-9]$|^[a-zA-Z0-9][a-zA-Z0-9_-.][a-zA-Z0-9]$ |
| version | Yes | String | Microservice version. Length: 1–64 characters. Regular expression: ^[0-9]$|^[0-9]+(.[0-9]+)$ |
| description | No | String | Microservice description. Length: 0–256 characters. |
| level | No | String | Microservice level. Value: FRONT, MIDDLE, or BACK. |
| registerBy | No | String | Microservice registration mode. Value: SDK, PLATFORM, SIDECAR, or UNKNOWN. |
| schemas | No | Array of Schema objects | Microservice schema content. The value must be 1 to 160 bytes long. Only digits, letters, underscores (_), hyphens (-), and periods (.) are allowed. An array contains a maximum of 100 schemas. |
| status | No | String | Microservice status. Value: UP (default) or DOWN. Enumeration values:
|
| timestamp | No | String | Microservice registration time. |
| modTimestamp | No | String | Latest modification time (UTC). |
| framework | No | Framework object | Development framework information. |
| paths | No | Array of ServicePath objects | Service route information. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| schemaId | No | String | Microservice schema ID. The value must be 1 to 160 bytes long. Only digits, letters, underscores (_), hyphens (-), and periods (.) are allowed. |
| schema | No | String | Microservice schema content. The value must be 1 to 2048 bytes long. Any characters are allowed. |
| summary | No | String | Microservice schema summary. The value contains a maximum of 128 bytes. Only digits and letters are allowed. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| name | No | String | Microservice development framework. Default value: UNKNOWN. |
| version | No | String | Microservice development framework version. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| Path | No | String | Route address. |
| Property | No | Object | Extended attribute. You can customize a key and value. The value contains at least 1 byte. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| ruleId | No | String | User-defined rule ID. |
| ruleType | No | String | Rule type. Value: WHITE or BLACK. |
| attribute | No | String | If the value starts with tag_xxx, the attributes are filtered by Tag. Otherwise, the attributes are filtered by serviceId, AppId, ServiceName, Version, Description, Level, or Status. |
| pattern | No | String | Matching rule. The value must be 1 to 64 characters long. A regular expression is supported. |
| description | No | String | Rule description. |
| timestamp | No | String | Time when a rule is created. This parameter is used only when you query rules. |
| modTimestamp | No | String | Update time. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| instanceId | No | String | Instance ID, which must be unique. During instance creation, instanceId is generated by the service center. |
| serviceId | No | String | Microservice ID, which must be unique. During instance creation, the service ID in the URL instead of the service ID here is used. |
| version | No | String | Microservice version. |
| hostName | Yes | String | Host information. |
| endpoints | Yes | Array of strings | Access address. |
| status | No | String | Instance status. Value: UP (default), DOWN, STARTING, or OUTOFSERVICE. |
| properties | No | Object | Extended attribute. You can customize a key and value. The value contains at least 1 byte. |
| healthCheck | No | HealthCheck object | Health check information. |
| dataCenterInfo | No | DataCenterInfo object | Data center information. |
| timestamp | No | String | Instance creation timestamp, which is automatically generated. |
| modTimestamp | No | String | Update time. |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| serviceId | String | Microservice ID, which must be unique. |
Status code: 400
| Parameter | Type | Description |
|---|---|---|
| errorCode | String | Error code. |
| errorMessage | String | Error information. |
| detail | String | Location details. |
Status code: 500
| Parameter | Type | Description |
|---|---|---|
| errorCode | String | Error code. |
| errorMessage | String | Error information. |
| detail | String | Location details. |
Example Requests
POST https://{endpoint}/v4/{project_id}/registry/microservices
{
"service" : {
"serviceName" : "helloworld",
"alias" : "HelloWorld",
"appId" : "TestApp",
"version" : "1.0.1",
"description" : "some descrition message!",
"level" : "FRONT",
"schemas" : [ "com.test.HelloWorld" ],
"status" : "UP",
"properties" : {
"attr1" : "a"
},
"paths" : [ {
"path" : "/rest/url",
"property" : {
"match" : "accurate",
"local" : "force",
"checksession" : "true"
}
}, {
"path" : "/rest/url2",
"property" : {
"match" : "accurate",
"local" : "force"
}
} ]
}
} Example Responses
Status code: 200
The request is successful. service_id (string) indicates the ID generated for the microservice. Subsequent operations are operated based on the microservice ID.
"{\n \"serviceId\": \"string\"\n}" Status Codes
| Status Code | Description |
|---|---|
| 200 | The request is successful. service_id (string) indicates the ID generated for the microservice. Subsequent operations are operated based on the microservice ID. |
| 400 | Bad Request |
| 500 | Internal Server Error |
Error Codes
See Error Codes.
Last Article: Querying Information About Microservices
Next Article: Deleting Definitions and Related Information About Microservices in Batches
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.