Help Center> ServiceStage> API Reference> CSE API> Microservice Instance> Querying Instances of a Microservice Based on the Service ID

Querying Instances of a Microservice Based on the Service ID

Function

This API is used to query all registered instances of a microservice based on the service ID.

URI

GET /v4/{project_id}/registry/microservices/{service_id}/instances

Table 1 Path parameters

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: ^.*$

Table 2 Query parameters

Parameter

Mandatory

Type

Description

tags

No

String

Tag. When there are multiple tags, separate them using commas (,). Regular expression: ^[a-zA-Z][a-zA-Z0-9_-.]{0,63}$

env

No

String

Environment of the instance. Value: development, testing, acceptance, or production.

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

x-domain-name

Yes

String

Tenant account name.

X-consumer_id

Yes

String

Microservice consumer ID, which must be unique.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

instances

Array of MicroServiceInstance objects

Instance list.

Table 5 MicroServiceInstance

Parameter

Type

Description

instanceId

String

Instance ID, which must be unique. During instance creation, instanceId is generated by the service center.

serviceId

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

String

Microservice version.

hostName

String

Host information.

endpoints

Array of strings

Access address.

status

String

Instance status. Value: UP (default), DOWN, STARTING, or OUTOFSERVICE.

properties

Object

Extended attribute. You can customize a key and value. The value contains at least 1 byte.

healthCheck

HealthCheck object

Health check information.

dataCenterInfo

DataCenterInfo object

Data center information.

timestamp

String

Instance creation timestamp, which is automatically generated.

modTimestamp

String

Update time.

Table 6 HealthCheck

Parameter

Type

Description

mode

String

Heartbeat mode. Value: push or pull.

port

Integer

Port.

interval

Integer

Interval for sending heartbeat messages, in seconds.

times

Integer

Number of failures that are allowed.

Table 7 DataCenterInfo

Parameter

Type

Description

name

String

Region name.

region

String

Region.

availableZone

String

AZ.

Status code: 400

Table 8 Response body parameters

Parameter

Type

Description

errorCode

String

Error code.

errorMessage

String

Error information.

detail

String

Location details.

Status code: 500

Table 9 Response body parameters

Parameter

Type

Description

errorCode

String

Error code.

errorMessage

String

Error information.

detail

String

Location details.

Example Requests

GET https://{endpoint}/v4/{project_id}/registry/existence

Example Responses

Status code: 200

OK

"{\n  \"instances\": [\n    {\n      \"instanceId\": \"string\",\n      \"serviceId\": \"string\",\n      \"version\": \"string\",\n      \"hostName\": \"string\",\n      \"endpoints\": [\n        \"string\",\n        \"string\"\n      ],\n      \"status\": \"string\",\n      \"null\": null,\n      \"healthCheck\": {\n        \"mode\": \"string\",\n        \"port\": 0,\n        \"interval\": 0,\n        \"times\": 0\n      },\n      \"dataCenterInfo\": {\n        \"name\": \"string\",\n        \"region\": \"string\",\n        \"availableZone\": \"string\"\n      },\n      \"timestamp\": \"string\",\n      \"modTimestamp\": \"string\"\n    }\n  ]\n}"

Status Codes

Status Code

Description

200

OK

400

Bad Request

500

Internal Server Error

Error Codes

See Error Codes.