
# 获取实例执行图 - ShowJobInstanceDag
#### 功能介绍
获取实例执行图
#### 调用方法
请参见[如何调用API](https://support.huaweicloud.com/api-tics/tics_05_0021.html)。
#### URI
GET /v1/{project_id}/leagues/{league_id}/job-instances/{instance_id}/dag
表1路径参数 
| 参数          | 是否必选 | 参数类型   | 描述                 |
|:---|:---|:---|:---|
| project_id  | 是    | String | 项目id，最大32位，字母和数字组成 |
| league_id   | 是    | String | 空间id，最大32位，字母和数字组成 |
| instance_id | 是    | String | 实例id，最大32位，字母和数字组成 |
   
表2Query参数 
| 参数       | 是否必选 | 参数类型    | 描述                   |
|:---|:---|:---|:---|
| round_id | 是    | Integer | 轮数，最小值0最大值0x7fffffff |
   
#### 请求参数
表3请求Header参数 
| 参数           | 是否必选 | 参数类型   | 描述                                                       |
|:---|:---|:---|:---|
| X-Auth-Token | 是    | String | 用户凭证                                                     |
| Content-Type | 是    | String | 消息体的类型（格式），必选，默认取值为"application/json"，有其他取值时会在具体接口中专门说明。 |
   
#### 响应参数
**状态码：200**
表4响应Body参数 
| 参数       | 参数类型                                                                | 描述 |
|:---|:---|:---|
| \[数组元素\] | Array of [DeployVo] objects | -- |
   
 表5DeployVo 
| 参数                 | 参数类型                                                              | 描述                                                   |
|:---|:---|:---|
| node_id            | String                                                            | 节点Id                                                 |
| node_name          | String                                                            | 节点名称                                                 |
| node_partner_alias | String                                                            | 参与方别名                                                |
| node_type          | String                                                            | 节点类型。AGENT计算节点，AGG聚合节点，AGG_MANAGER聚合器管理节点，SERVER控制节点 |
| stages             | Array of [StageVo] objects | 执行阶段                                                 |
   
 表6StageVo 
| 参数                 | 参数类型                                                                      | 描述         |
|:---|:---|:---|
| id                 | Integer                                                                   | 执行阶段id     |
| last_step_stage_id | Array of integers                                                         | 上游的stageId |
| processors         | Array of [ProcessorVo] objects | 执行过程       |
| stage_name         | String                                                                    | 执行阶段名称     |
   
 表7ProcessorVo 
| 参数                    | 参数类型             | 描述                                                                                                                             |
|:---|:---|:---|
| end_time              | Long             | 结束时间                                                                                                                           |
| exec_duration_nano    | Long             | 执行时长                                                                                                                           |
| id                    | String           | 执行过程id                                                                                                                         |
| last_step_task_ins_id | Array of strings | 上游子任务id                                                                                                                        |
| start_time            | Long             | 开始时间                                                                                                                           |
| task_in_record_cnt    | Long             | 输入个数                                                                                                                           |
| task_name             | String           | 执行过程名称                                                                                                                         |
| task_out_record_cnt   | Long             | 输出个数                                                                                                                           |
| task_show_info        | Object           | processor对外展示信息                                                                                                                |
| task_status           | String           | 执行状态。作业任务状态，NEW新建，SUBMITING提交中，ACCEPTED已接收，DEPLOYING部署中，RUNNING运行中，SUCCEEDED成功，FAILED失败，TERMINATED中止，TERMINATING中止中，PENDING等待中 |
   
**状态码：401**
表8响应Body参数 
| 参数         | 参数类型   | 描述   |
|:---|:---|:---|
| error_code | String | 错误码  |
| error_msg  | String | 错误信息 |
   
**状态码：500**
表9响应Body参数 
| 参数         | 参数类型   | 描述   |
|:---|:---|:---|
| error_code | String | 错误码  |
| error_msg  | String | 错误信息 |
   
#### 请求示例
获取实例执行图
```
get /v1/{project_id}/leagues/{league_id}/job-instances/{instance_id}/dag?round_id=1
```
#### 响应示例
**状态码：200**
获取实例执行图成功
```
[ {
  "node_id" : "efb586519206414eb280e5ea1693cbe3",
  "node_name" : "agent_跨region_ief",
  "node_type" : "AGENT",
  "node_partner_alias" : "space_creator",
  "stages" : [ {
    "id" : 502,
    "stage_name" : "最终结果存储阶段_502",
    "processors" : [ {
      "id" : "SQLExecute_@efb586519206414eb280e5ea1693cbe3#be9d",
      "task_name" : "本地SQL计算",
      "last_step_task_ins_id" : [ "SQLValidate_@efb586519206414eb280e5ea1693cbe3#e660" ],
      "start_time" : 1667482475000,
      "end_time" : 1667482476000,
      "exec_duration_nano" : 361,
      "task_in_record_cnt" : 0,
      "task_out_record_cnt" : 14,
      "task_status" : "SUCCEEDED",
      "task_show_info" : {
        "LAST_ITERATION_PROCESS_INPUT_END_TIME" : "2022/11/03 21:34:35 GMT+8:00",
        "FIRST_ITERATION_COLLECT_INPUT_START_TIME" : "2022/11/03 21:34:35 GMT+8:00",
        "CURRENT_ITERATION_COUNT" : "1",
        "FIRST_ITERATION_PROCESS_INPUT_START_TIME" : "2022/11/03 21:34:35 GMT+8:00",
        "ACCUMULATED_COLLECT_INPUT_TIME" : "2ms",
        "ACCUMULATED_OUTPUT_SIZE" : "14",
        "ACCUMULATED_PROCESS_INPUT_TIME" : "359ms",
        "datasets" : "de",
        "LAST_ITERATION_COLLECT_INPUT_END_TIME" : "2022/11/03 21:34:35 GMT+8:00",
        "sql" : "SELECT `DEPARTMENT_ID`, `EMPLOYEE_ID`, `AVG_SALARY`, `NEW_TIME` FROM `SPACE_CREATOR`.`DE`"
      }
    }, {
      "id" : "SQLValidate_@efb586519206414eb280e5ea1693cbe3#e660",
      "task_name" : "隐私规则检查",
      "last_step_task_ins_id" : [ ],
      "start_time" : 1667482475000,
      "end_time" : 1667482475000,
      "exec_duration_nano" : 0,
      "task_in_record_cnt" : 0,
      "task_out_record_cnt" : 0,
      "task_status" : "SUCCEEDED",
      "task_show_info" : {
        "LAST_ITERATION_PROCESS_INPUT_END_TIME" : "2022/11/03 21:34:35 GMT+8:00",
        "FIRST_ITERATION_COLLECT_INPUT_START_TIME" : "2022/11/03 21:34:35 GMT+8:00",
        "CURRENT_ITERATION_COUNT" : "1",
        "FIRST_ITERATION_PROCESS_INPUT_START_TIME" : "2022/11/03 21:34:35 GMT+8:00",
        "ACCUMULATED_COLLECT_INPUT_TIME" : "0ms",
        "sqlValidateResult" : "success",
        "ACCUMULATED_OUTPUT_SIZE" : "0",
        "ACCUMULATED_PROCESS_INPUT_TIME" : "0ms",
        "LAST_ITERATION_COLLECT_INPUT_END_TIME" : "2022/11/03 21:34:35 GMT+8:00",
        "sql" : "SELECT `DEPARTMENT_ID`, `EMPLOYEE_ID`, `AVG_SALARY`, `NEW_TIME`FROM `SPACE_CREATOR`.`DE`"
      }
    }, {
      "id" : "SaveResult_@efb586519206414eb280e5ea1693cbe3#cbf4",
      "task_name" : "结果存储",
      "last_step_task_ins_id" : [ "SQLExecute_@efb586519206414eb280e5ea1693cbe3#be9d" ],
      "start_time" : 1667482475000,
      "end_time" : 1667482476000,
      "exec_duration_nano" : 364,
      "task_in_record_cnt" : 14,
      "task_out_record_cnt" : 0,
      "task_status" : "SUCCEEDED",
      "task_show_info" : {
        "LAST_ITERATION_PROCESS_INPUT_END_TIME" : "2022/11/03 21:34:35 GMT+8:00",
        "FIRST_ITERATION_COLLECT_INPUT_START_TIME" : "2022/11/03 21:34:35 GMT+8:00",
        "CURRENT_ITERATION_COUNT" : "1",
        "FIRST_ITERATION_PROCESS_INPUT_START_TIME" : "2022/11/03 21:34:35 GMT+8:00",
        "filename" : "/output/sql/efb586519206414eb280e5ea1693cbe3/0c8c73c00d3d4b59a820e39f319d8204/20221103213432-709b11224f3d4804b2bb4abc4b809d55.csv",
        "ACCUMULATED_COLLECT_INPUT_TIME" : "362ms",
        "ACCUMULATED_OUTPUT_SIZE" : "0",
        "saveResultRecordCount" : "14",
        "ACCUMULATED_PROCESS_INPUT_TIME" : "2ms",
        "LAST_ITERATION_COLLECT_INPUT_END_TIME" : "2022/11/03 21:34:35 GMT+8:00"
      }
    } ],
    "last_step_stage_id" : [ ]
  } ]
} ]
```
#### SDK代码示例
SDK代码示例如下。
- [Java]
  ```
  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.tics.v1.region.TicsRegion;
  import com.huaweicloud.sdk.tics.v1.*;
  import com.huaweicloud.sdk.tics.v1.model.*;
  public class ShowJobInstanceDagSolution {
      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);
          TicsClient client = TicsClient.newBuilder()
                  .withCredential(auth)
                  .withRegion(TicsRegion.valueOf("<YOUR REGION>"))
                  .build();
          ShowJobInstanceDagRequest request = new ShowJobInstanceDagRequest();
          request.withInstanceId("{instance_id}");
          request.withLeagueId("{league_id}");
          try {
              ShowJobInstanceDagResponse response = client.showJobInstanceDag(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());
          }
      }
  }
  ```
- [Python]
  ```
  # coding: utf-8
  import os
  from huaweicloudsdkcore.auth.credentials import BasicCredentials
  from huaweicloudsdktics.v1.region.tics_region import TicsRegion
  from huaweicloudsdkcore.exceptions import exceptions
  from huaweicloudsdktics.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 = TicsClient.new_builder() \
          .with_credentials(credentials) \
          .with_region(TicsRegion.value_of("<YOUR REGION>")) \
          .build()
      try:
          request = ShowJobInstanceDagRequest()
          request.instance_id = "{instance_id}"
          request.league_id = "{league_id}"
          response = client.show_job_instance_dag(request)
          print(response)
      except exceptions.ClientRequestException as e:
          print(e.status_code)
          print(e.request_id)
          print(e.error_code)
          print(e.error_msg)
  ```
- [Go]
  ```
  package main
  import (
  "fmt"
  "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
      tics "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/tics/v1"
  "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/tics/v1/model"
      region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/tics/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 := basic.NewCredentialsBuilder().
          WithAk(ak).
          WithSk(sk).
          WithProjectId(projectId).
          Build()
      client := tics.NewTicsClient(
          tics.TicsClientBuilder().
              WithRegion(region.ValueOf("<YOUR REGION>")).
              WithCredential(auth).
              Build())
      request := &model.ShowJobInstanceDagRequest{}
  request.InstanceId = "{instance_id}"
  request.LeagueId = "{league_id}"
  response, err := client.ShowJobInstanceDag(request)
  if err == nil {
          fmt.Printf("%+v\n", response)
      } else {
          fmt.Println(err)
      }
  }
  ```
- [更多]
  更多编程语言的SDK代码示例，请参见[API Explorer](https://console.huaweicloud.com/apiexplorer/#/openapi/TICS/sdk?api=ShowJobInstanceDag)的代码示例页签，可生成自动对应的SDK代码示例。
#### 状态码
| 状态码 | 描述        |
|:---|:---|
| 200 | 获取实例执行图成功 |
| 401 | 操作无权限     |
| 500 | 内部服务器错误   |
   
