POST
/
api
/
open
/
v2
/
instance
/
shutdown_timer
设置定时关机
curl --request POST \
  --url https://www.chenyu.cn/api/open/v2/instance/shutdown_timer \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "enable": true,
  "shutdown_time": 123,
  "instance_uuid": "<string>"
}'
{
  "code": 123,
  "msg": "<string>"
}

设置定时关机

为指定实例设置定时关机功能,可以在指定时间后自动关闭实例。
实例定时关机时间最小为5分钟后。

请求参数

enable
boolean
required
true: 启用实例定时关机 false: 取消实例定时关机
shutdown_time
integer
required
实例定时关机时间,秒级时间戳
instance_uuid
string
required
实例uuid

响应参数

code
integer
响应码
msg
string
响应信息

代码示例

import requests

url = "https://www.chenyu.cn/api/open/v2/instance/shutdown_timer"
headers = {
    "Authorization": "Bearer your_api_key",
    "Content-Type": "application/json"
}

# 设置60分钟后自动关机
data = {
    "instance_uuid": "inst_12345678-1234-1234-1234-123456789012",
    "shutdown_time": 60
}

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

if result['code'] == 0:
    print("定时关机设置成功")
else:
    print(f"设置失败: {result['msg']}")

响应示例

{
  "code": 0,
  "msg": "设置成功"
}

注意事项

  • 设置 shutdown_time 为 0 可以取消已设置的定时关机
  • 定时关机时间以分钟为单位
  • 只有运行中的实例才能设置定时关机