Skip to content

认证授权

获取授权区域

1.接口说明

接口路径:/ac/openapi/v2/center

请求方式:GET

请求数据类型:

接口描述:获取授权区域,返回用户可用区域的信息及url地址、用户集群用户名及家目录等

备注:hpcUrls为作业相关接口调用使用url;efileUrls为文件相应接口调用使用的url;aiUrls为容器相应接口调用使用的url

以上Urls若返回为多组url时,请根据返回中的enable参数进行地址可用性判断,为true时证明url可以正常使用

2.请求消息

请求参数:

Headers:

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

3.请求示例

cURL请求示例

shell
curl --location 'https://scnet-demo.accloud.cn/ac/openapi/v2/center' \
--header 'Content-Type: application/json' \
--header 'token: <Token>'

Java请求示例

java
import okhttp3.*;

public class getAuthorizationCenterInfoDemo {

    public static final String URL = "https://scnet-demo.accloud.cn/ac/openapi/v2/center";
    
    public static final String TOKEN = "<Token>";

    public static void main(String[] args) throws Exception {
        OkHttpClient client = new OkHttpClient().newBuilder()
                .build();
        Request request = new Request.Builder()
                .url(URL)
                .method("GET", null)
                .addHeader("Content-Type", "application/json")
                .addHeader("token", TOKEN)
                .build();
        Response response = client.newCall(request).execute();
        System.out.println(response.body().string());
    }
}

Python请求示例

python
import requests
import json

url = "https://scnet-demo.accloud.cn/ac/openapi/v2/center"
payload = {}
headers = {
  "Content-Type": "application/json",
  "token": "<Token>"
}

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

4.响应消息

返回参数:

名称类型描述示例
msgstring信息success
codestring状态码0
dataarray区域信息列表
namestring区域名称OpenAPI计算中心
descriptionstring区域描述对外OpenAPI中心
clusterUserInfoobject区域用户信息
idstring区域ID11112
aiUrlsstring容器服务访问信息
efileUrlsstring文件服务访问信息
eshellUrlsstringeshell服务访问信息
hpcUrlsstring作业服务访问信息

返回示例:

json
{
  "code":"0",
  "msg":"success",
  "data":{
    "id":11112,
    "name":"OpenAPI计算中心",
    "description":"对外OpenAPI中心",
    "clusterUserInfo":{
      "userName":"test",
      "homePath":"/public/home/test"
    },
    "ingressUrls":[
      {
        "enable":"true",
        "isManagerNode":"true",
        "version":"5.2.2",
        "url":"https://scnet-demo.accloud.cn"
      }
    ],
    "efileUrls":[
      {
        "nodeName":"h04r3n07",
        "enable":"true",
        "fastTransEnable":"true",
        "udpPort":"65104",
        "version":"2.6.1",
        "url":"https://scnet-demo.accloud.cn/efile"
      }
    ],
    "eshellUrls":[
      {
        "enable":"true",
        "version":"2.4.3",
        "url":"https://scnet-demo.accloud.cn"
      }
    ],
    "hpcUrls":[
      {
        "enable":"true",
        "isManagerNode":"true",
        "version":"5.2.2",
        "url":"https://scnet-demo.accloud.cn"
      }
    ],
    "aiUrls":[
      {
        "enable":"true",
        "version":"2.4.3",
        "url":"https://scnet-demo.accloud.cn"
      }
    ]
  }
}

5.错误码

错误码说明
10001内部错误
10003参数不全
10004参数无效
10008权限不足
10009没有权限访问接口
0接口调用成功