Alaya NeW Cloud

开放端口

为CCI容器计算实例开放指定端口,允许外部访问。

POSThttps://api.alayanew.com/v1/cci/instance/{id}/open-port

鉴权(Authorizations)

AuthorizationString必填

用户可通过已获取的 Open API Key 做验证。例如:Bearer [YOUR_API_KEY]

Path Parameters

idString必填

实例ID,实例的唯一标识符,例如:08ba7a0e-af00-4072-a5e5-1298ed6c1aa0

Request body

protocolString必填

协议。例如:"http/https"

portInteger必填

端口。例如:80

Response

statusInteger

业务状态码,200表示成功。

messageString

接口响应信息,成功或失败原因描述。

dataObject

接口返回的数据对象,包含端口映射信息。

curl -X 'POST' \
  'https://api.alayanew.com/v1/cci/instance/08ba7a0e-af00-4072-a5e5-1298ed6c1aa0/open-port' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer [YOUR_API_KEY]' \
  -H 'Content-Type: application/json' \
  -d '{
  "protocol": "http/https",
  "port": 80
}'
import requests

url = "https://api.alayanew.com/v1/cci/instance/08ba7a0e-af00-4072-a5e5-1298ed6c1aa0/open-port"

headers = {
    "accept": "application/json",
    "Authorization": "Bearer [YOUR_API_KEY]",
    "Content-Type": "application/json"
}

data = {
    "protocol": "http/https",
    "port": 80
}

response = requests.post(url, headers=headers, json=data)

print(response.text)
fetch('https://api.alayanew.com/v1/cci/instance/08ba7a0e-af00-4072-a5e5-1298ed6c1aa0/open-port', {
  method: 'POST',
  headers: {
    'accept': 'application/json',
    'Authorization': 'Bearer [YOUR_API_KEY]',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    protocol: "http/https",
    port: 80
  })
})
  .then(response => response.text())
  .then(data => console.log(data))
  .catch(error => console.error(error));
{
  "status": 200,
  "message": "OK",
  "data": {
    "external_port": 30001,
    "internal_port": 8080,
    "protocol": "tcp"
  }
}
{
  "status": 403,
  "message": "Forbidden",
  "data": {}
}
{
  "status": 500,
  "message": "Internal Server Error",
  "data": {}
}

Last updated on