Registering a Microservice Instance
Function
This API is used to register a microservice instance after a microservice is created.
Information about the instance must be provided during registration.
instanceid can be customized. If it is customized, the new instance ID will overwrite the original one. If it is not customized, the system automatically generates an ID. If the endpoints are duplicate, the original ID is used.
URI
POST /v4/{project_id}/registry/microservices/{service_id}/instances
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
|
service_id |
Yes |
String |
Microservice ID, which must be unique. The value contains 1 to 64 characters. Regular expression: ^.*$. See Querying Information About All Microservices. |
Request
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
Authorization |
No |
String |
This parameter is mandatory if security authentication is enabled for an exclusive microservice engine. Otherwise, this parameter is not required. The token of an exclusive microservice engine with security authentication enabled is in the following format: Authorization:Bearer {Token} For details about how to obtain the token, see Obtaining the User Token of an Exclusive Microservice Engine. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
instance |
Yes |
MicroServiceInstance object |
Microservice instance information. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
instanceId |
No |
String |
Instance ID, which must be unique. The instance ID is generated by the service center. |
serviceId |
No |
String |
Microservice ID, which must be unique. During instance creation, use the microservice ID in the URL instead of the microservice ID specified here. |
version |
No |
String |
Microservice version. |
hostName |
Yes |
String |
Host information. |
endpoints |
No |
Array of strings |
Access address information. |
status |
No |
String |
Instance status. Value: UP, DOWN, STARTING, or OUTOFSERVICE. Default value: UP. |
properties |
No |
Object |
Extended attribute. You can customize a key and value. The value must be at least 1 byte long. |
healthCheck |
No |
HealthCheck object |
Health check information. |
dataCenterInfo |
No |
DataCenterInfo object |
Data center information. |
timestamp |
No |
String |
Time when an instance is created, which is automatically generated. |
modTimestamp |
No |
String |
Update time. |
Response
Status code: 200
Parameter |
Type |
Description |
---|---|---|
instanceId |
String |
Instance ID. |
Status code: 400
Parameter |
Type |
Description |
---|---|---|
errorCode |
String |
Error code. |
errorMessage |
String |
Error message. |
detail |
String |
Location details. |
Status code: 500
Parameter |
Type |
Description |
---|---|---|
errorCode |
String |
Error code. |
errorMessage |
String |
Error message. |
detail |
String |
Location details. |
Example Request
Register a microservice instance: host information is localhost, heartbeat mode is push, heartbeat interval is 30s, region is r1, name is dc, and AZ is az1.
POST https://{endpoint}/v4/{project_id}/registry/microservices/{service_id}/instances { "instance" : { "endpoints" : [ "grpc://127.0.1.312:9980", "rest://127.0.0.111:8081" ], "hostName" : "localhost", "status" : "UP", "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 Response
Status code: 200
Successfully registered.
{ "instanceId" : "8540bb8b693c4ad1a7fb6a756c415244" }
Status Code
Status Code |
Description |
---|---|
200 |
OK |
400 |
Bad Request |
500 |
Internal Server Error |
Error Code
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