作业
查看文件
1.接口说明
接口路径:/hpc/openapi/v2/file/content
请求方式:POST
请求数据类型:application/x-www-from-urlencoded
接口描述:分页查看文件内容
2.请求消息
请求参数:
Headers:
名称 | 类型 | 必填 | 描述 | 示例 |
---|---|---|---|---|
token | string | 是 | 接口凭证 | eyJhbGciOiJIUzI1N... |
参数:
名称 | 类型 | 必填 | 描述 | 示例 |
---|---|---|---|---|
hostName | string | 否 | 服务器hostname | 127.0.0.1 |
dirPath | string | 是 | 服务器文件绝对路径 | /public/home/test/BASE/STDIN_1210_114429/std.out.22 |
triggerNum | int | 是 | 翻页次数,第一次打开传1,文件每超过1000行,该参数累加1(类似分页,每页显示1000行数据) | 1 |
rollDirection | string | 是 | 文件查看方向,传参UP,从文件尾向上看;传参DOWN,从文件头向下看 | UP |
3.请求示例
cURL请求示例
curl --location 'https://api01.xxx.com:65106/hpc/openapi/v2/file/content' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb21wdXRlVXNlciI6InNsdXJtdGVzdCIsImFjY291bnRTdGF0dXMiOiJUcmlhbCIsImNyZWF0b3IiOiJhYyIsInJvbGUiOiIxIiwiZXhwaXJlVGltZSI6IjE2ODYwMzY3NjA5NTQiLCJjbHVzdGVySWQiOiIxMTExMiIsImludm9rZXIiOiI2MDQ4Y2U3YmExNWMyYWYyZThjZWMxMjk5MWVjMTNjZiIsInVzZXIiOiJzbHVybXRlc3QiLCJ1c2VySWQiOiIxMTY1NTA0ODU0MSJ9.f7nvKA2DqTsXjqF90zblMhwx0zKPpITY0uuSG2ouKG0' \
--data-urlencode 'hostName=' \
--data-urlencode 'dirPath=/public/home/test/BASE/STDIN_0531_134514/std.out.35919' \
--data-urlencode 'triggerNum=1' \
--data-urlencode 'rollDirection=UP'
Java请求示例
import okhttp3.*;
public class ReadFileContentDemo {
public static final String URL = "https://api01.xxx.com:65106/hpc/openapi/v2/file/content";
public static final String TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb21wdXRlVXNlciI6InNsdXJtdGVzdCIsImFjY291bnRTdGF0dXMiOiJUcmlhbCIsImNyZWF0b3IiOiJhYyIsInJvbGUiOiIxIiwiZXhwaXJlVGltZSI6IjE2ODY5MDg1MDkyMzEiLCJjbHVzdGVySWQiOiIxMTExMiIsImludm9rZXIiOiI2MDQ4Y2U3YmExNWMyYWYyZThjZWMxMjk5MWVjMTNjZiIsInVzZXIiOiJzbHVybXRlc3QiLCJ1c2VySWQiOiIxMTY1NTA0ODU0MSJ9.U7pZKgO_K6NuRwOWPxblDfgRpGeVxS-BYieOdLhGDK4";
public static void main(String[] args) throws Exception {
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "hostName=&dirPath=/public/home/test/BASE/STDIN_0531_134514/std.out.35919&triggerNum=1&rollDirection=UP");
Request request = new Request.Builder()
.url(URL)
.method("POST", body)
.addHeader("Content-Type", "application/x-www-form-urlencoded")
.addHeader("token", TOKEN)
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
}
}
Python请求示例
import requests
url = "https://api01.xxx.com:65106/hpc/openapi/v2/file/content"
payload = 'hostName=&dirPath=%2Fpublic%2Fhome%2Ftest%2FBASE%2FSTDIN_0531_134514%2Fstd.out.35919&triggerNum=1&rollDirection=UP'
headers = {
'Content-Type': 'application/x-www-form-urlencoded',
'token': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb21wdXRlVXNlciI6InNsdXJtdGVzdCIsImFjY291bnRTdGF0dXMiOiJUcmlhbCIsImNyZWF0b3IiOiJhYyIsInJvbGUiOiIxIiwiZXhwaXJlVGltZSI6IjE2ODYwMzY3NjA5NTQiLCJjbHVzdGVySWQiOiIxMTExMiIsImludm9rZXIiOiI2MDQ4Y2U3YmExNWMyYWYyZThjZWMxMjk5MWVjMTNjZiIsInVzZXIiOiJzbHVybXRlc3QiLCJ1c2VySWQiOiIxMTY1NTA0ODU0MSJ9.f7nvKA2DqTsXjqF90zblMhwx0zKPpITY0uuSG2ouKG0'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
4.响应消息
返回参数:
名称 | 类型 | 描述 | 示例 |
---|---|---|---|
msg | string | 信息 | success |
code | string | 状态码 | 0 |
data | object | 对象数据 | |
allLineTotal | int | 文件总行数 | 100 |
data | string | 返回的文件内容 | start time is: 2021-10-14 |
errmsg | string | 错误信息 | false |
success | string | 请求是否成功 | true |
totalTriggerTimes | int | 总次数(类似分页总页数) | 1 |
返回示例:
{
"code": "0",
"msg": "success",
"data": {
"allLineTotal": 12,
"data": "The start time is: 2021-12-10 11:44:32 \n\nMy job ID is: 22 \n\nThe total cores is: 1 \n\nThe hosts is: \n\nh04r3n07:1\n\n\nThe end time is: 2021-12-10 11:52:52",
"success": "true",
"totalTriggerTimes": 1,
"errmsg": ""
}
}
5.错误码
错误码 | 说明 |
---|---|
0 | 成功 |
10001 | 内部错误 |
10003 | 参数不全 |
10004 | 参数无效 |
10007 | 用户已被冻结 |
10008 | 权限不足 |
10009 | 没有权限访问接口 |
10010 | 文件校验失败 |
10011 | 文件过大 |
10012 | 连接中断 |
10013 | 操作超时 |
815005 | 作业提交失败(调度系统没返回) |
815007 | 作业提交失败(调度系统sbatch失败) |