Help Center/ ServiceStage/ API Reference/ ServiceComb APIs/ Dependency/ Querying All Providers of a Microservice
Updated on 2024-10-16 GMT+08:00

Querying All Providers of a Microservice

Function

This API is used to query all providers of a microservice based on consumer_id. For example, if service A depends on services B and C, you can query the information about services B and C based on service A ID.

URI

GET /v4/{project_id}/registry/microservices/{consumer_id}/providers

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

  • For a professional microservice engine, enter the tenant project ID. The value contains 1 to 64 characters. See Obtaining a Project ID. You can also enter the fixed value default.
  • For an exclusive microservice engine, enter the fixed value default.

consumer_id

Yes

String

Consumer service ID.

Table 2 Query parameters

Parameter

Mandatory

Type

Description

noSelf

No

Integer

Whether to return the self-dependency relationship. 0: no; 1: yes.

sameDomain

No

Integer

Whether to return the shared-service relationship. 0: no; 1: yes.

Request

Table 3 Request header parameter

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.

Response

Status code: 200

Table 4 Response body parameter

Parameter

Type

Description

providers

MicroService object

Microservice information.

Table 5 Microservice

Parameter

Type

Description

serviceId

String

Microservice ID, which must be unique. The value contains 1 to 64 characters. Regular expression: ^.*$

environment

String

Microservice environment. Value: development, testing, acceptance, or production. You can use the API for uploading schemas in batches to add or modify an existing schema only when the value is development, testing, or acceptance. Default value: development.

appId

String

Application ID, which must be unique. The value contains 1 to 160 characters. Regular expression: ^[a-zA-Z0-9]$|^[a-zA-Z0-9][a-zA-Z0-9_-.][a-zA-Z0-9]$

serviceName

String

Microservice name, which must be unique in an application. The value contains 1 to 128 characters. Regular expression: ^[a-zA-Z0-9]$|^[a-zA-Z0-9][a-zA-Z0-9_-.][a-zA-Z0-9]$

version

String

Microservice version. The value contains 1 to 64 characters. Regular expression: ^[0-9]$|^[0-9]+(.[0-9]+)$

description

String

Microservice description. The value contains a maximum of 256 characters.

level

String

Microservice level. Value: FRONT, MIDDLE, or BACK.

registerBy

String

Microservice registration mode. Value: SDK, PLATFORM, SIDECAR, or UNKNOWN.

schemas

Array of strings

Microservice schema content. The value must be 1 to 160 bytes long. Only digits, letters, underscores (_), hyphens (-), and periods (.) are allowed. An array contains a maximum of 100 schemas.

status

String

Microservice status. Value: UP or DOWN. Default value: UP.

timestamp

String

Microservice registration time.

modTimestamp

String

Latest modification time (UTC).

framework

Framework object

Development framework.

paths

Array of ServicePath objects

Service path.

properties

Object

Extended attribute. You can customize a key and value.

Table 6 Framework

Parameter

Type

Description

name

String

Microservice development framework. Default value: UNKNOWN.

version

String

Version of the microservice development framework.

Table 7 ServicePath

Parameter

Type

Description

Path

String

Route address.

Property

Object

Extended attribute. You can customize a key and value. The value must be at least 1 byte long.

Status code: 400

Table 8 Response body parameters

Parameter

Type

Description

errorCode

String

Error code.

errorMessage

String

Error message.

detail

String

Location details.

Status code: 500

Table 9 Response body parameters

Parameter

Type

Description

errorCode

String

Error code.

errorMessage

String

Error message.

detail

String

Location details.

Example Request

Query the providers of a consumer service with specified consumer_id.

GET https://{endpoint}/v4/{project_id}/registry/microservices/{consumer_id}/providers

Example Response

Status code: 200

Successfully queried. serviceId or schemaId is returned.

{
    "providers": [
        {
            "serviceId": "8aed80ea052ac04a64dfc79c24f2170224d074f5",
            "appId": "default",
            "serviceName": "test",
            "version": "1.0.0",
            "description": "this is a test",
            "level": "BACK",
            "status": "UP",
            "properties": {
                "test": "test"
            },
            "timestamp": "1650543950",
            "modTimestamp": "1650544411"
        }
    ]
}

Status Code

Status Code

Description

200

OK

400

Bad Request

500

Internal Server Error

Error Code

See ServiceComb Error Codes.