Creating a Dependency Between Services
Function
This API is used to create a dependency between services. The consumer service must be an existing service. Its version must be a confirmed version and serviceName cannot be an asterisk (*). The provider can be a service that has not been created.
URI
POST /v4/{project_id}/registry/dependencies
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String | Unique ID of a tenant sub-project. Length: 1–64 characters. |
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| x-domain-name | Yes | String | Tenant account name. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| dependencies | No | Array of MicroServiceDependency objects | Dependency list. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| consumer | No | DependencyKey object | Basic information about the microservice. |
| providers | No | Array of DependencyKey objects | Dependent service list. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| environment | No | String | development|testing|acceptance|production |
| appId | Yes | String | Application ID, which must be unique. |
| serviceName | Yes | String | Microservice name. For a provider microservice, the name can be set to an asterisk (*), indicating that the microservice depends on all services of the same tenant. When the microservice name is *, appId and version can be left blank. For a consumer microservice, the name cannot be set to *. |
| version | Yes | String | Microservice version. For a provider microservice, the version can be subsequent versions of a certain version (example: 1.0.1+, which indicates a version later than 1.0.1), a fixed version, or the latest version. For a consumer microservice, the version must be a fixed version. |
Response Parameters
Status code: 400
| Parameter | Type | Description |
|---|---|---|
| errorCode | String | Error code. |
| errorMessage | String | Error information. |
| detail | String | Location details. |
Status code: 500
| Parameter | Type | Description |
|---|---|---|
| errorCode | String | Error code. |
| errorMessage | String | Error information. |
| detail | String | Location details. |
Example Requests
PUT https://{endpoint}/v4/{project_id}/registry/dependencies
{
"dependencies" : [ {
"consumer" : {
"appId" : "TestApp",
"serviceName" : "ServiceRegistry",
"version" : "1.0.0"
},
"providers" : [ {
"appId" : "default",
"serviceName" : "SERVICECENTER",
"version" : "3.0.0"
} ]
} ]
} Example Responses
None
Status Codes
| Status Code | Description |
|---|---|
| 200 | OK |
| 400 | Bad Request |
| 500 | Internal Server Error |
Error Codes
See Error Codes.
Last Article: Dependency
Next Article: Querying All Providers of a Microservice
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.