Skip to content

作业

查看文件

1.接口说明

接口路径:/hpc/openapi/v2/file/content

请求方式:POST

请求数据类型:application/x-www-from-urlencoded

接口描述:分页查看文件内容

2.请求消息

请求参数:

Headers:

名称类型必填描述示例
tokenstring接口凭证eyJhbGciOiJIUzI1N...

参数:

名称类型必填描述示例
hostNamestring服务器hostname127.0.0.1
dirPathstring服务器文件绝对路径/public/home/test/BASE/STDIN_1210_114429/std.out.22
triggerNumint翻页次数,第一次打开传1,文件每超过1000行,该参数累加1(类似分页,每页显示1000行数据)1
rollDirectionstring文件查看方向,传参UP,从文件尾向上看;传参DOWN,从文件头向下看UP

3.请求示例

cURL请求示例

shell
curl --location 'https://scnet-demo.accloud.cn/hpc/openapi/v2/file/content' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'token: <Token>' \
--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请求示例

java
import okhttp3.*;

public class ReadFileContentDemo {
    
    public static final String URL = "https://scnet-demo.accloud.cn/hpc/openapi/v2/file/content";
    
    public static final String TOKEN = "<Token>";

    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请求示例

python
import requests

url = "https://scnet-demo.accloud.cn/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": "<Token>"
}

response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)

4.响应消息

返回参数:

名称类型描述示例
msgstring信息success
codestring状态码0
dataobject对象数据
allLineTotalint文件总行数100
datastring返回的文件内容start time is: 2021-10-14
errmsgstring错误信息false
successstring请求是否成功true
totalTriggerTimesint总次数(类似分页总页数)1

返回示例:

json
{
  "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失败)