Querying Microservice Instances in Batches
Function
This API is used to query microservice instances in batches based on microservice version rules or field filter criteria after the instances are registered.
URI
POST /v4/{project_id}/registry/instances/action
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
project_id |
String |
Yes |
Fixed value: default. |
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
type |
String |
Yes |
Operation type. Fixed value: query. |
Request
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
X-ConsumerId |
String |
No |
Unique ID of a service consumer. |
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
services |
Array of objects |
No |
Microservice request struct. For details, see Table 5. |
instances |
Array of objects |
No |
Microservice instance request struct. For details, see Table 6. |
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
service |
Object |
Yes |
Microservice request struct. For details, see DependencyMicroService. |
rev |
String |
No |
Version number cached by the client. |
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
instance |
Object |
Yes |
Microservice instance request struct. For details, see HeartbeatSetElement. |
rev |
String |
No |
Version number cached by the client. |
Response
Response parameters
Table 7 describes the parameters.
Parameter |
Type |
Description |
---|---|---|
services |
BatchFindResult |
Response structs of microservices that are discovered. |
instances |
BatchFindResult |
Response structs of microservice instances that are discovered. |
Parameter |
Type |
Description |
---|---|---|
failed |
Array of objects |
Response structs of microservices that cannot be discovered. For details, see Table 9. |
notModified |
Array of integers |
Index array of instances that remain unchanged. The value of each item in the array corresponds to an index of a microservice in the request struct. |
updated |
Array of objects |
Response structs of instances that are modified. For details, see Table 10. |
Parameter |
Type |
Description |
---|---|---|
indexes |
Array of integers |
Index array of microservices that cannot be discovered. The value of each item in the array corresponds to an index of a microservice in the request struct. |
error |
Object |
Error information struct. For details, see Error. |
Parameter |
Type |
Description |
---|---|---|
index |
Integer |
Index array of instances that remain unchanged. The value of each item in the array corresponds to an index of a microservice in the request struct. |
rev |
String |
Version number cached by the client. |
instances |
Array of objects |
Set of microservice instances. For details, see MicroServiceInstance. |
Example
Example request
curl -X POST "/v4/default/registry/instances/action?type=query" -H "accept: application/json" -H "Content-Type: application/json" -d ' { "services": [ { "service": { "environment": "string", "appId": "string", "serviceName": "string", "version": "string" }, "rev": "string" } ], "instances": [ { "instance": { "serviceId": "string", "instanceId": "string" }, "rev": "string" } ] }
Example response
HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 Server: SERVICECENTER/0.0.1 Vary: Accept-Encoding Vary: Origin X-Response-Status: 200 Date: Fri, 21 Dec 2018 02:36:48 GMT Content-Length: 1952 { "services": { "failed": [ { "indexes": [ 0 ], "error": { "errorCode": "string", "errorMessage": "string", "detail": "string" } } ], "notModified": [ 0 ], "updated": [ { "index": 0, "rev": "string", "instances": [ { "instanceId": "string", "serviceId": "string", "version": "string", "hostName": "string", "endpoints": [ "string" ], "status": "string", "healthCheck": { "mode": "string", "port": 0, "interval": 0, "times": 0 }, "dataCenterInfo": { "name": "string", "region": "string", "availableZone": "string" }, "timestamp": "string", "modTimestamp": "string" } ] } ] }, "instances": { "failed": [ { "indexes": [ 0 ], "error": { "errorCode": "string", "errorMessage": "string", "detail": "string" } } ], "notModified": [ 0 ], "updated": [ { "index": 0, "rev": "string", "instances": [ { "instanceId": "string", "serviceId": "string", "version": "string", "hostName": "string", "endpoints": [ "string" ], "status": "string", "healthCheck": { "mode": "string", "port": 0, "interval": 0, "times": 0 }, "dataCenterInfo": { "name": "string", "region": "string", "availableZone": "string" }, "timestamp": "string", "modTimestamp": "string" } ] } ] } }
Status Code
See Status Codes.
Error Code
See CSE 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