文档首页/ 数据治理中心 DataArts Studio/ API参考/ 数据开发API(V2)/ 作业开发API/ 查询实例的上下游依赖 - ShowFactoryDependInstances
更新时间:2026-09-10 GMT+08:00
分享

查询实例的上下游依赖 - ShowFactoryDependInstances

功能介绍

查询实例的上下游依赖

调用方法

请参见如何调用API

授权信息

账号具备所有API的调用权限,如果使用账号下的IAM用户调用当前API,该IAM用户需具备调用API所需的权限。

  • 如果使用角色与策略授权,具体权限要求请参见权限和授权项
  • 如果使用身份策略授权,当前API调用无需身份策略权限。

URI

GET /v2/{project_id}/factory/instances/{instance_id}/depend-instances

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

项目ID,获取方法请参见项目ID和账号ID

instance_id

Long

作业实例id,可通过作业实例列表接口获取。

表2 Query参数

参数

是否必选

参数类型

描述

relation

String

支持选择查询实例的直接上游、直接下游或者是直接上下游,取值为 parent、child、both,默认为both。

  • parent:直接上游实例

  • child:直接下游实例

  • both:直接上下游实例

depth

Integer

默认值为1, depth是上下游依赖查询的层级深度,例如 depth=1 只查直接依赖,depth=2 查到依赖的依赖。单次查询可返回的最大深度为50层。

latest

Boolean

默认值为true, 当latest=true的时候,控制是否只返回每个依赖任务的最新实例,true 时只返回endTime 最晚的执行记录,false 时返回所有历史实例。

请求参数

表3 请求Header参数

参数

是否必选

参数类型

描述

workspace

String

工作空间ID,获取方法请参见实例ID和工作空间ID

X-Auth-Token

String

IAM Token,通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值),使用Token认证时必选,最小长度:0,最大长度:4096。

X-Project-Id

String

project_id,项目编号。获取方法请参见项目ID和账号ID

多project场景采用AK/SK认证的接口请求,则该字段必选。

Content-Type

String

默认值:application/json;charset=UTF-8

可选,有Body体的情况下必选,没有Body体则无需填写和校验。

响应参数

状态码:200

表4 响应Body参数

参数

参数类型

描述

depend_instances_info

Array of depend_instances_info objects

实例详情。

total

Integer

返回的实例总数。

表5 depend_instances_info

参数

参数类型

描述

id

Long

实例ID。

job_id

Long

作业id。

job_name

String

作业名称。

directory_path

String

作业路径。

force_success

Boolean

实例是否是执行了强制成功。

ignore_success

Boolean

实例是否是执行了忽略失败。

parent_instance_ids

Array of longs

依赖的上游实例ID。

plan_time

Long

计划开始时间。

running_time

Long

运行时长,单位:毫秒。

  • 当实例是运行中时,运行时长为当前时间减去开始时间;

  • 当实例运行结束时,运行时长为结束时间减去开始时间;

start_time

Long

开始时间。

end_time

Long

结束时间。

status

String

实例状态。

submit_time

Long

提交时间。

version

Integer

版本号。

workspace_id

String

所在的工作空间ID。

workspace_name

String

所在的工作空间名称。

avg_execute_time_ms

Long

作业历史平均执行时长

状态码:400

表6 响应Body参数

参数

参数类型

描述

error_code

String

错误码。

error_msg

String

错误描述。

请求示例

  • 查询作业实例ID为461668的上下游依赖实例。

    GET /v2/62099355b894428e8916573ae635f1f9/factory/instances/461668/depend-instances
    
    {
      "depend_instances_info" : [ {
        "end_time" : 1757578181000,
        "force_success" : false,
        "avg_execute_time_ms" : 8862,
        "id" : 461668,
        "ignore_success" : false,
        "job_id" : 933213,
        "job_name" : "job_2201_xia3",
        "directory_path" : "/root",
        "parent_instance_ids" : [ 461665 ],
        "plan_time" : 1757578140000,
        "running_time" : 29000,
        "start_time" : 1757578152000,
        "status" : "success",
        "submit_time" : 1757578081111,
        "version" : 1,
        "workspace_id" : "62fbba734e634c5087656fc3ff7adf34",
        "workspace_name" : "default"
      }, {
        "end_time" : 1757578185000,
        "force_success" : false,
        "avg_execute_time_ms" : 8862,
        "id" : 461667,
        "ignore_success" : false,
        "job_id" : 933214,
        "job_name" : "job_2201_xia4",
        "directory_path" : "/root",
        "parent_instance_ids" : [ 461668 ],
        "plan_time" : 1757578140000,
        "running_time" : 3000,
        "start_time" : 1757578182000,
        "status" : "success",
        "submit_time" : 1757578081108,
        "version" : 1,
        "workspace_id" : "62fbba734e634c5087656fc3ff7adf34",
        "workspace_name" : "default"
      }, {
        "end_time" : 1757578149000,
        "force_success" : false,
        "id" : 461665,
        "ignore_success" : false,
        "avg_execute_time_ms" : 8862,
        "job_id" : 933212,
        "job_name" : "job_2201_xia2",
        "directory_path" : "/root",
        "parent_instance_ids" : [ 461664 ],
        "plan_time" : 1757578140000,
        "running_time" : 2000,
        "start_time" : 1757578147000,
        "status" : "success",
        "submit_time" : 1757578081144,
        "version" : 1,
        "workspace_id" : "62fbba734e634c5087656fc3ff7adf34",
        "workspace_name" : "default"
      } ],
      "total" : 3
    }
  • 查询作业实例ID为232853的上下游依赖实例。该作业首次运行,无历史记录

    GET /v2/62099355b894428e8916573ae635f1f9/factory/instances/232853/depend-instances
    
    {
      "depend_instances_info" : [ {
        "end_time" : 1787539358000,
        "force_success" : false,
        "avg_execute_time_ms" : 0,
        "id" : 232853,
        "ignore_success" : false,
        "job_id" : 21484495,
        "job_name" : "test_job_dummmy1",
        "parent_instance_ids" : [ ],
        "plan_time" : 1787539320000,
        "running_time" : 8000,
        "start_time" : 1787539350000,
        "status" : "success",
        "submit_time" : 1787539319253,
        "version" : 1,
        "workspace_id" : "6ec704bb7985476fa1869f4ee3d30339",
        "workspace_name" : "gg_test"
      } ],
      "total" : 1
    }

响应示例

状态码:200

状态码:400

{
  "error_code" : "DLF.0137",
  "error_msg" : "Job instance does not exist."
}

SDK代码示例

SDK代码示例如下。

  • 查询作业实例ID为461668的上下游依赖实例。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    package com.huaweicloud.sdk.test;
    
    import com.huaweicloud.sdk.core.auth.ICredential;
    import com.huaweicloud.sdk.core.auth.BasicCredentials;
    import com.huaweicloud.sdk.core.exception.ConnectionException;
    import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
    import com.huaweicloud.sdk.core.exception.ServiceResponseException;
    import com.huaweicloud.sdk.dataartsstudio.v1.region.DataArtsStudioRegion;
    import com.huaweicloud.sdk.dataartsstudio.v1.*;
    import com.huaweicloud.sdk.dataartsstudio.v1.model.*;
    
    
    public class ShowFactoryDependInstancesSolution {
    
        public static void main(String[] args) {
            // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
            // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
            String ak = System.getenv("CLOUD_SDK_AK");
            String sk = System.getenv("CLOUD_SDK_SK");
            String projectId = "{project_id}";
    
            ICredential auth = new BasicCredentials()
                    .withProjectId(projectId)
                    .withAk(ak)
                    .withSk(sk);
    
            DataArtsStudioClient client = DataArtsStudioClient.newBuilder()
                    .withCredential(auth)
                    .withRegion(DataArtsStudioRegion.valueOf("<YOUR REGION>"))
                    .build();
            ShowFactoryDependInstancesRequest request = new ShowFactoryDependInstancesRequest();
            request.withInstanceId({instance_id}L);
            try {
                ShowFactoryDependInstancesResponse response = client.showFactoryDependInstances(request);
                System.out.println(response.toString());
            } catch (ConnectionException e) {
                e.printStackTrace();
            } catch (RequestTimeoutException e) {
                e.printStackTrace();
            } catch (ServiceResponseException e) {
                e.printStackTrace();
                System.out.println(e.getHttpStatusCode());
                System.out.println(e.getRequestId());
                System.out.println(e.getErrorCode());
                System.out.println(e.getErrorMsg());
            }
        }
    }
    
  • 查询作业实例ID为232853的上下游依赖实例。该作业首次运行,无历史记录

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    package com.huaweicloud.sdk.test;
    
    import com.huaweicloud.sdk.core.auth.ICredential;
    import com.huaweicloud.sdk.core.auth.BasicCredentials;
    import com.huaweicloud.sdk.core.exception.ConnectionException;
    import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
    import com.huaweicloud.sdk.core.exception.ServiceResponseException;
    import com.huaweicloud.sdk.dataartsstudio.v1.region.DataArtsStudioRegion;
    import com.huaweicloud.sdk.dataartsstudio.v1.*;
    import com.huaweicloud.sdk.dataartsstudio.v1.model.*;
    
    
    public class ShowFactoryDependInstancesSolution {
    
        public static void main(String[] args) {
            // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
            // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
            String ak = System.getenv("CLOUD_SDK_AK");
            String sk = System.getenv("CLOUD_SDK_SK");
            String projectId = "{project_id}";
    
            ICredential auth = new BasicCredentials()
                    .withProjectId(projectId)
                    .withAk(ak)
                    .withSk(sk);
    
            DataArtsStudioClient client = DataArtsStudioClient.newBuilder()
                    .withCredential(auth)
                    .withRegion(DataArtsStudioRegion.valueOf("<YOUR REGION>"))
                    .build();
            ShowFactoryDependInstancesRequest request = new ShowFactoryDependInstancesRequest();
            request.withInstanceId({instance_id}L);
            try {
                ShowFactoryDependInstancesResponse response = client.showFactoryDependInstances(request);
                System.out.println(response.toString());
            } catch (ConnectionException e) {
                e.printStackTrace();
            } catch (RequestTimeoutException e) {
                e.printStackTrace();
            } catch (ServiceResponseException e) {
                e.printStackTrace();
                System.out.println(e.getHttpStatusCode());
                System.out.println(e.getRequestId());
                System.out.println(e.getErrorCode());
                System.out.println(e.getErrorMsg());
            }
        }
    }
    
  • 查询作业实例ID为461668的上下游依赖实例。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    # coding: utf-8
    
    import os
    from huaweicloudsdkcore.auth.credentials import BasicCredentials
    from huaweicloudsdkdataartsstudio.v1.region.dataartsstudio_region import DataArtsStudioRegion
    from huaweicloudsdkcore.exceptions import exceptions
    from huaweicloudsdkdataartsstudio.v1 import *
    
    if __name__ == "__main__":
        # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak = os.environ["CLOUD_SDK_AK"]
        sk = os.environ["CLOUD_SDK_SK"]
        projectId = "{project_id}"
    
        credentials = BasicCredentials(ak, sk, projectId)
    
        client = DataArtsStudioClient.new_builder() \
            .with_credentials(credentials) \
            .with_region(DataArtsStudioRegion.value_of("<YOUR REGION>")) \
            .build()
    
        try:
            request = ShowFactoryDependInstancesRequest()
            request.instance_id = {instance_id}
            response = client.show_factory_depend_instances(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • 查询作业实例ID为232853的上下游依赖实例。该作业首次运行,无历史记录

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    # coding: utf-8
    
    import os
    from huaweicloudsdkcore.auth.credentials import BasicCredentials
    from huaweicloudsdkdataartsstudio.v1.region.dataartsstudio_region import DataArtsStudioRegion
    from huaweicloudsdkcore.exceptions import exceptions
    from huaweicloudsdkdataartsstudio.v1 import *
    
    if __name__ == "__main__":
        # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak = os.environ["CLOUD_SDK_AK"]
        sk = os.environ["CLOUD_SDK_SK"]
        projectId = "{project_id}"
    
        credentials = BasicCredentials(ak, sk, projectId)
    
        client = DataArtsStudioClient.new_builder() \
            .with_credentials(credentials) \
            .with_region(DataArtsStudioRegion.value_of("<YOUR REGION>")) \
            .build()
    
        try:
            request = ShowFactoryDependInstancesRequest()
            request.instance_id = {instance_id}
            response = client.show_factory_depend_instances(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • 查询作业实例ID为461668的上下游依赖实例。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    package main
    
    import (
    	"fmt"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
        dataartsstudio "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dataartsstudio/v1"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dataartsstudio/v1/model"
        region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dataartsstudio/v1/region"
    )
    
    func main() {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak := os.Getenv("CLOUD_SDK_AK")
        sk := os.Getenv("CLOUD_SDK_SK")
        projectId := "{project_id}"
    
        auth, err := basic.NewCredentialsBuilder().
            WithAk(ak).
            WithSk(sk).
            WithProjectId(projectId).
            SafeBuild()
    
        if err != nil {
            fmt.Println(err)
            return
        }
    
        hcClient, err := dataartsstudio.DataArtsStudioClientBuilder().
             WithRegion(region.ValueOf("<YOUR REGION>")).
             WithCredential(auth).
             SafeBuild()
    
    
        if err != nil {
            fmt.Println(err)
            return
        }
    
        client := dataartsstudio.NewDataArtsStudioClient(hcClient)
    
        request := &model.ShowFactoryDependInstancesRequest{}
    	request.InstanceId = int64({instance_id})
    	response, err := client.ShowFactoryDependInstances(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    
  • 查询作业实例ID为232853的上下游依赖实例。该作业首次运行,无历史记录

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    package main
    
    import (
    	"fmt"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
        dataartsstudio "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dataartsstudio/v1"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dataartsstudio/v1/model"
        region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dataartsstudio/v1/region"
    )
    
    func main() {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak := os.Getenv("CLOUD_SDK_AK")
        sk := os.Getenv("CLOUD_SDK_SK")
        projectId := "{project_id}"
    
        auth, err := basic.NewCredentialsBuilder().
            WithAk(ak).
            WithSk(sk).
            WithProjectId(projectId).
            SafeBuild()
    
        if err != nil {
            fmt.Println(err)
            return
        }
    
        hcClient, err := dataartsstudio.DataArtsStudioClientBuilder().
             WithRegion(region.ValueOf("<YOUR REGION>")).
             WithCredential(auth).
             SafeBuild()
    
    
        if err != nil {
            fmt.Println(err)
            return
        }
    
        client := dataartsstudio.NewDataArtsStudioClient(hcClient)
    
        request := &model.ShowFactoryDependInstancesRequest{}
    	request.InstanceId = int64({instance_id})
    	response, err := client.ShowFactoryDependInstances(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    

更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。

状态码

状态码

描述

200

响应成功的状态码。

400

响应失败的状态码。

相关文档