Help Center/ ServiceStage/ API Reference (ME-Abu Dhabi Region)/ CSE API/ Querying Microservice Instances in Batches
Updated on 2023-06-25 GMT+08:00

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

Table 1 Path parameters

Parameter

Type

Mandatory

Description

project_id

String

Yes

Fixed value: default.

Table 2 Query parameters

Parameter

Type

Mandatory

Description

type

String

Yes

Operation type.

Fixed value: query.

Request

Table 3 Request header parameter

Parameter

Type

Mandatory

Description

X-ConsumerId

String

No

Unique ID of a service consumer.

Table 4 Parameters

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.

Table 5 FindService parameters

Parameter

Type

Mandatory

Description

service

Object

Yes

Microservice request struct. For details, see DependencyMicroService.

rev

String

No

Version number cached by the client.

Table 6 FindInstance parameters

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.

Table 7 Parameters

Parameter

Type

Description

services

BatchFindResult

Response structs of microservices that are discovered.

instances

BatchFindResult

Response structs of microservice instances that are discovered.

Table 8 BatchFindResult parameters

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.

Table 9 FindFailedResult parameters

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.

Table 10 FindResult parameters

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.