文档

查询数据导入状态API

更新时间:

1. 参数

1.1. 入参

参数

类型

是否必传

说明

dataImportIds

List<Long>

导入id集合

{
  "dataImportIds": [1, 2, 3]
}

1.2. 响应出参

参数名称

参数类型

参数描述

code

Integer

错误码

success

Boolean

是否成功

requestId

String

请求id

msg

String

响应信息

data

Map

响应内容,key为导入id,value参考下表

参数名称

参数类型

参数描述

serviceId

Long

服务id

status

String

导入状态

code

Integer

错误码

message

String

错误信息

{
  "code": 200,
  "data": {
    "1": {
      "serviceId": 1,
      "status": "finished"
    },
    "2": {
      "serviceId": 1,
      "status": "finished"
    },
    "3": {
      "serviceId": 1,
      "status": "failed",
      "code": 6003,
      "message": "数据导入失败"
    }
  },
  "success": true,
  "msg": null,
  "requestId": "4117446A-308C-4CA6-B265-39F4A96C30B5"
}

1.3. 状态表

状态

描述

init

任务初始化

data_exporting

数据导出中

data_exported

数据导出完成

txt_extractioning

文本抽取中

txt_extractioned

文本抽取完成

chunking

分块处理中

chunked

分块处理完成

feature_analysising

特征提取中

feature_analysised

特征提取完成

data_importing

数据导入中

finished

任务完成

failed

任务失败

2. SDK调用

2.1. Java SDK

2.1.1. Maven依赖

<dependency>
    <groupId>com.aliyun</groupId>
    <artifactId>aliyun-java-sdk-core</artifactId>
    <version>4.6.0</version>
</dependency>

<dependency>
    <groupId>com.aliyun</groupId>
    <artifactId>alinlp20200629</artifactId>
    <version>2.2.0</version>
</dependency>

2.1.2. 调用示例

/**
 * 使用AK&SK初始化账号Client
 * @param accessKeyId
 * @param accessKeySecret
 * @return Client
 * @throws Exception
 */
public static Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
    Config config = new Config()
    // 必填,您的 AccessKey ID
    .setAccessKeyId(accessKeyId)
    // 必填,您的 AccessKey Secret
    .setAccessKeySecret(accessKeySecret);
    // Endpoint 请参考 https://api.aliyun.com/product/alinlp
    config.endpoint = "alinlp.cn-beijing.aliyuncs.com";
    return new Client(config);
}


public static void main(String[] args_) throws Exception {
    GetServiceDataImportStatus();
}

public static void GetServiceDataImportStatus() throws Exception {
    // 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378657.html
    Client client = createClient(AccessConstant.AK3, AccessConstant.SK3);
    GetServiceDataImportStatusRequest requset = new GetServiceDataImportStatusRequest()
    .setDataImportIds(Arrays.asList(1L));
    try {
        GetServiceDataImportStatusResponse response = client.getServiceDataImportStatus(requset);
        System.out.println(JSON.toJSONString(response.getBody(), SerializerFeature.PrettyFormat));
    } catch (Exception e) {
        e.printStackTrace();
    }
}

2.2. Python SDK

2.2.1. pip源

pip install aliyun-python-sdk-alinlp==1.0.23
pip install aliyun-python-sdk-core

2.2.2. 调用示例

from aliyunsdkalinlp.request.v20200629 import GetServiceDataImportStatusRequest
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.auth.credentials import AccessKeyCredential
import os

os.environ['ALIBABA_CLOUD_ACCESS_KEY_ID'] = 'xxxx'
os.environ['ALIBABA_CLOUD_ACCESS_KEY_SECRET'] = 'xxxx'


def data_import_status():
    credentials = AccessKeyCredential(os.environ['ALIBABA_CLOUD_ACCESS_KEY_ID'],
                                      os.environ['ALIBABA_CLOUD_ACCESS_KEY_SECRET'])
    client = AcsClient(region_id='cn-beijing', credential=credentials)
    request = GetServiceDataImportStatusRequest.GetServiceDataImportStatusRequest()
    request.set_DataImportIds([32])
    request.set_accept_format('json')
    response = client.do_action_with_exception(request)
    # python2:  print(response)
    print(str(response, encoding='utf-8'))


if __name__ == '__main__':
    data_import_status()
   
  • 本页导读 (0)