Registering a Microservice Instance
Function
This API is used to register a microservice instance after a microservice is created. To register a microservice instance, you need to provide its information as required. The instance ID can be customized. If it is customized, all contents are overwritten upon re-registration. If it is not customized, the system automatically generates an instance ID. If the endpoint content is duplicate, the original ID is used.
URI
POST /v4/{project_id}/registry/microservices/{service_id}/instances
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String | Unique ID of a tenant sub-project. Length: 1–64 characters. |
| service_id | Yes | String | Microservice ID, which must be unique. Length: 1–64 characters. Regular expression: ^.*$ |
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| x-domain-name | Yes | String | Tenant account name. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| instance | No | MicroServiceInstance object | Microservice instance information. |
| 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 |
|---|---|---|
| instanceId | String | Instance ID. |
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/existence
{
"instance" : {
"endpoints" : [ "grpc://127.0.1.312:9980", "rest://127.0.0.111:8081" ],
"hostName" : "localhost",
"status" : "UP",
"stage" : "dev",
"properties" : {
"_TAGS" : "A, B",
"attr1" : "a",
"nodeIP" : "127.0.0.1"
},
"dataCenterInfo" : {
"name" : "dc",
"region" : "r1",
"availableZone" : "az1"
},
"healthCheck" : {
"mode" : "push",
"interval" : 30,
"times" : 3
}
}
} Example Responses
Status code: 200
OK
"{\n \"instanceId\": \"string\"\n}" Status Codes
| Status Code | Description |
|---|---|
| 200 | OK |
| 400 | Bad Request |
| 500 | Internal Server Error |
Error Codes
See Error Codes.
Last Article: Microservice Instance
Next Article: Querying Instances of a Microservice Based on the Service ID
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.