九章智算云
关闭容器组端口

关闭指定容器组上已开放的自定义端口。同步完成。可先通过查询容器组已开放端口确认要关闭的端口。

POSThttps://api.alayanew.com/api/osm/v1/training/instance/{id}/{podName}/close-port

鉴权(Authorizations)

AuthorizationString必填

用户获取Authorization请求头后,通过该请求头完成身份认证。例如:Authorization: [your-auth-header]。

Path Parameters

idString必填

训练任务 ID(来自任务列表的 id)。例如:a3c8f6d1-7b42-4e95-9d20-8f1a4c6b3e58。

podNameString必填

容器组名称(来自容器组列表的 podName)。例如:train-job-01-worker-0。

Request body

portInteger必填

要关闭的端口。例如:7778。

Response

statusInteger

业务状态码,200 表示关闭成功;失败时为错误码。

messageString

响应信息,成功为 "OK";失败时为错误描述。

curl -X 'POST' \
  'https://api.alayanew.com/api/osm/v1/training/instance/a3c8f6d1-7b42-4e95-9d20-8f1a4c6b3e58/train-job-01-worker-0/close-port' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: [your-auth-header]' \
  -d '{
  "port": 7778
}'
import requests

task_id = "a3c8f6d1-7b42-4e95-9d20-8f1a4c6b3e58"
pod_name = "train-job-01-worker-0"
url = f"https://api.alayanew.com/api/osm/v1/training/instance/{task_id}/{pod_name}/close-port"
headers = {
    "accept": "application/json",
    "Content-Type": "application/json",
    "Authorization": "[your-auth-header]"
}
payload = {
    "port": 7778
}

response = requests.post(url, headers=headers, json=payload)
print(response.json())
const taskId = 'a3c8f6d1-7b42-4e95-9d20-8f1a4c6b3e58';
const podName = 'train-job-01-worker-0';
const payload = {
  port: 7778
};

fetch(`https://api.alayanew.com/api/osm/v1/training/instance/${taskId}/${podName}/close-port`, {
  method: 'POST',
  headers: {
    'accept': 'application/json',
    'Content-Type': 'application/json',
    'Authorization': '[your-auth-header]'
  },
  body: JSON.stringify(payload)
})
  .then(res => res.json())
  .then(console.log)
  .catch(console.error);
{
  "status": 200,
  "message": "OK"
}

最后更新于