زمان‌بندی

مرجع کامل endpointهای بخش «زمان‌بندی» در API کلاینت پافرلند.

Endpoints زمان‌بندی

ساخت و مدیریت وظایف خودکار با زمان‌بندی کرون (cron). مجوزهای لازم: schedule.read، schedule.create، schedule.update، schedule.delete و schedule.execute.

در مسیرهای زیر {schedule} شناسه‌ی عددی زمان‌بندی و {task} شناسه‌ی عددی وظیفه است. محدودیت‌ها: ۱۰ تا ۵۰ زمان‌بندی برای هر سرور، حداکثر ۲۰ وظیفه برای هر زمان‌بندی و ۳ زمان‌بندی همزمان در حال اجرا.
GET/api/client/servers/{server}/schedules

تمام زمان‌بندی‌های سرور را برمی‌گرداند.

curl "https://pufferland.ir/api/client/servers/1a85a183/schedules" \
  -H "Authorization: Bearer ptlc_xxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Accept: application/json"
نمونه پاسخ واقعی:
{
  "object": "list",
  "data": []
}
GET/api/client/servers/{server}/schedules/{schedule}

جزئیات یک زمان‌بندی شامل تمام وظایف آن را برمی‌گرداند: name، cron (با فیلدهای minute، hour، day_of_month، month، day_of_weekis_active، is_processing، last_run_at، next_run_at و relationships.tasks.

curl "https://pufferland.ir/api/client/servers/1a85a183/schedules/1" \
  -H "Authorization: Bearer ptlc_xxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Accept: application/json"
POST/api/client/servers/{server}/schedules

یک زمان‌بندی جدید می‌سازد. خطاها: 400 با کد TooManySchedulesException و 422 با کد ValidationException برای الگوی کرون نامعتبر.

فیلدنوعالزامتوضیح
namestringنام زمان‌بندی (حداکثر ۲۵۵ کاراکتر).
minutestringکرون دقیقه: ۰–۵۹ یا *.
hourstringکرون ساعت: ۰–۲۳ یا *.
day_of_monthstringروز ماه: ۱–۳۱ یا *.
monthstringماه: ۱–۱۲ یا *.
day_of_weekstringروز هفته: ۰–۶ یا *.
is_activebooleanپیش‌فرض true.
only_when_onlinebooleanاجرا فقط وقتی سرور روشن است؛ پیش‌فرض false.
curl -X POST "https://pufferland.ir/api/client/servers/1a85a183/schedules" \
  -H "Authorization: Bearer ptlc_xxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{"name": "Nightly Restart", "minute": "0", "hour": "4", "day_of_month": "*", "month": "*", "day_of_week": "*", "is_active": true}'
await fetch('https://pufferland.ir/api/client/servers/1a85a183/schedules', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer ptlc_xxxxxxxxxxxxxxxxxxxxxxxx',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    name: 'Nightly Restart', minute: '0', hour: '4',
    day_of_month: '*', month: '*', day_of_week: '*', is_active: true,
  }),
}).then(r => r.json()).then(console.log);
import requests

r = requests.post(
    "https://pufferland.ir/api/client/servers/1a85a183/schedules",
    json={
        "name": "Nightly Restart", "minute": "0", "hour": "4",
        "day_of_month": "*", "month": "*", "day_of_week": "*",
        "is_active": True,
    },
    headers={"Authorization": "Bearer ptlc_xxxxxxxxxxxxxxxxxxxxxxxx"},
)
print(r.json())
curl_post('https://pufferland.ir/api/client/servers/1a85a183/schedules', [
    CURLOPT_POSTFIELDS => json_encode(['name' => 'Nightly Restart', 'minute' => '0', 'hour' => '4', 'day_of_month' => '*', 'month' => '*', 'day_of_week' => '*', 'is_active' => true]),
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ptlc_xxxxxxxxxxxxxxxxxxxxxxxx',
        'Content-Type: application/json',
    ],
]);
نمونه پاسخ واقعی:
{
  "object": "server_schedule",
  "attributes": {
    "id": 78,
    "name": "docs-sample",
    "cron": {
      "day_of_week": "*",
      "day_of_month": "*",
      "month": "*",
      "hour": "5",
      "minute": "0"
    },
    "is_active": false,
    "is_processing": false,
    "only_when_online": false,
    "last_run_at": null,
    "next_run_at": "2026-09-17T05:00:00+03:30",
    "created_at": "2026-09-16T05:38:49+03:30",
    "updated_at": "2026-09-16T05:38:49+03:30",
    "relationships": {
      "tasks": {
        "object": "list",
        "data": []
      }
    }
  }
}
POST/api/client/servers/{server}/schedules/{schedule}

تنظیمات زمان‌بندی موجود را تغییر می‌دهد. فیلدها همان ساخت است اما همگی اختیاری‌اند. پاسخ موفق: 204 بدون بدنه.

curl -X POST "https://pufferland.ir/api/client/servers/1a85a183/schedules/1" \
  -H "Authorization: Bearer ptlc_xxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{"name": "Restart شبانه", "is_active": true}'
DELETE/api/client/servers/{server}/schedules/{schedule}

زمان‌بندی و تمام وظایف آن را برای همیشه حذف می‌کند. پاسخ موفق: 204.

حذف زمان‌بندی دائمی و غیرقابل بازگشت است.
curl -X DELETE "https://pufferland.ir/api/client/servers/1a85a183/schedules/1" \
  -H "Authorization: Bearer ptlc_xxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Accept: application/json"
نمونه پاسخ واقعی:
204 No Content
POST/api/client/servers/{server}/schedules/{schedule}/execute

زمان‌بندی را بلافاصله و به‌صورت دستی اجرا می‌کند. پاسخ موفق: 204. خطای 409 با کد ConflictingServerStateException اگر در حال اجرا باشد و 400 اگر زمان‌بندی غیرفعال باشد.

curl -X POST "https://pufferland.ir/api/client/servers/1a85a183/schedules/1/execute" \
  -H "Authorization: Bearer ptlc_xxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json"
GET/api/client/servers/{server}/schedules/{schedule}/tasks

فهرست وظایف یک زمان‌بندی را برمی‌گرداند.

curl "https://pufferland.ir/api/client/servers/1a85a183/schedules/1/tasks" \
  -H "Authorization: Bearer ptlc_xxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Accept: application/json"
POST/api/client/servers/{server}/schedules/{schedule}/tasks

یک وظیفه‌ی جدید به زمان‌بندی اضافه می‌کند.

فیلدنوعالزامتوضیح
actionstringیکی از command، power یا backup.
payloadstringبرای command: متن دستور؛ برای power: start، stop، restart یا kill؛ برای backup: رشته‌ی خالی یا نام بکاپ.
time_offsetintegerتأخیر بر حسب ثانیه بعد از وظیفه‌ی قبلی.
continue_on_failurebooleanادامه پس از شکست؛ پیش‌فرض false.

پاسخ شامل id، action، payload، sequence_id و time_offset است.

curl -X POST "https://pufferland.ir/api/client/servers/1a85a183/schedules/1/tasks" \
  -H "Authorization: Bearer ptlc_xxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{"action": "command", "payload": "say Hello", "time_offset": 0}'
نمونه پاسخ واقعی:
{
  "object": "schedule_task",
  "attributes": {
    "id": 61,
    "sequence_id": 1,
    "action": "command",
    "payload": "say hi",
    "time_offset": 0,
    "is_queued": false,
    "continue_on_failure": false,
    "created_at": "2026-09-16T05:38:49+03:30",
    "updated_at": "2026-09-16T05:38:49+03:30"
  }
}
PATCH/api/client/servers/{server}/schedules/{schedule}/tasks/{task}

وظیفه‌ی مشخص‌شده را ویرایش می‌کند (همان فیلدهای ساخت).

curl -X PATCH "https://pufferland.ir/api/client/servers/1a85a183/schedules/1/tasks/1" \
  -H "Authorization: Bearer ptlc_xxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{"payload": "say Updated"}'
DELETE/api/client/servers/{server}/schedules/{schedule}/tasks/{task}

وظیفه را از زمان‌بندی حذف می‌کند. پاسخ موفق: 204.

curl -X DELETE "https://pufferland.ir/api/client/servers/1a85a183/schedules/1/tasks/1" \
  -H "Authorization: Bearer ptlc_xxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Accept: application/json"