Help Center> ServiceStage> API Reference> CSE API> Dependency> Creating a Dependency Between Services

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

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Unique ID of a tenant sub-project. Length: 1–64 characters.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

x-domain-name

Yes

String

Tenant account name.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

dependencies

No

Array of MicroServiceDependency objects

Dependency list.

Table 4 MicroServiceDependency

Parameter

Mandatory

Type

Description

consumer

No

DependencyKey object

Basic information about the microservice.

providers

No

Array of DependencyKey objects

Dependent service list.

Table 5 DependencyKey

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

Table 6 Response body parameters

Parameter

Type

Description

errorCode

String

Error code.

errorMessage

String

Error information.

detail

String

Location details.

Status code: 500

Table 7 Response body parameters

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.