添加依赖

Description 说明

object service.adddependencies(object/array serviceDependencies)

This method allows to create dependencies between services. 此方法允许创建服务之间的依赖关系。

Parameters 参数

(object/array) Service dependencies to create. (object/array)创建服务依赖关系。

Each service dependency has the following parameters. 每个服务依赖项具有以下参数。

Parameter 参数 T pe 类型 Des ription 说明
serviceid string 字符串 ID of the service that depends on a service, that is, the parent service. 依赖父服务的服务ID。
dependsOnServiceid string 字符串 ID of the service that a service depends on, that is, the child service. 被子服务依赖的服务ID。
soft string 字符串 Ty e of dependency. 依赖类型。

Refer to the service dependency object page for more information on dependency types. 有关依赖关系类型的更多信息,请参阅service dependency object page

Return values 返回值

(object) Returns an object containing the IDs of the affected parent services under the serviceids property. (object)返回一个对象,该对象包含在serviceids属性中受影响父服务的ID。

Examples 范例

Creating a hard dependency 创建一个硬依赖

Make service "2" a hard-dependent child of service "3". 使服务"2"成为服务"3"强依赖的子服务。

Request 请求:

{
           "jsonrpc": "2.0",
           "method": "service.adddependencies",
           "params": {
               "serviceid": "3",
               "dependsOnServiceid": "2",
               "soft": 0
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response 响应:

{
           "jsonrpc": "2.0",
           "result": {
               "serviceids": [
                   "3"
               ]
           },
           "id": 1
       }

See also 参考

Source 源码

CService::addDependencies() in frontends/php/include/classes/api/services/CService.php. CService::addDependencies()方法可在frontends/php/include/classes/api/services/CService.php中参考。