شبکه

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

Endpoints شبکه

مدیریت آدرس‌ها (Allocations) و پورت‌های سرور. مجوزهای لازم: allocation.read، allocation.create، allocation.update و allocation.delete.

در مسیرهای زیر {allocation} شناسه‌ی عددی آدرس است. هر آیتم allocation شامل id، ip، ip_alias، port، notes و is_default است.
GET/api/client/servers/{server}/network/allocations

تمام آدرس‌های شبکه‌ی اختصاص‌یافته به سرور را برمی‌گرداند.

curl "https://pufferland.ir/api/client/servers/1a85a183/network/allocations" \
  -H "Authorization: Bearer ptlc_xxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Accept: application/json"
نمونه پاسخ واقعی:
{
  "object": "list",
  "data": [
    {
      "object": "allocation",
      "attributes": {
        "id": 1146,
        "ip": "37.32.43.26",
        "ip_alias": "p5.pfmc.ir",
        "port": 1038,
        "notes": null,
        "is_default": true
      }
    }
  ]
}
POST/api/client/servers/{server}/network/allocations

یک آدرس جدید به سرور اختصاص می‌دهد. این endpoint بدنه‌ای نمی‌پذیرد؛ انتخاب به‌صورت خودکار (روی IP آدرس اصلی یا بازه‌ی پورت تعریف‌شده) انجام می‌شود. تعیین IP یا پورت مشخص از طریق API کلاینت امکان‌پذیر نیست.

خطاها (400): رسیدن به سقف آدرس‌ها (DisplayException)، فعال‌نبودن تخصیص خودکار (AutoAllocationNotEnabledException) و نبود فضای پورت آزاد (NoAutoAllocationSpaceAvailableException).

curl -X POST "https://pufferland.ir/api/client/servers/1a85a183/network/allocations" \
  -H "Authorization: Bearer ptlc_xxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json"
نمونه پاسخ واقعی:
{
  "object": "allocation",
  "attributes": {
    "id": 1387,
    "ip": "37.32.43.26",
    "ip_alias": "p5.pfmc.ir",
    "port": 1279,
    "notes": null,
    "is_default": false
  }
}
POST/api/client/servers/{server}/network/allocations/{allocation}/primary

آدرس مشخص‌شده را به‌عنوان آدرس اصلی (پیش‌فرض) سرور تعیین می‌کند. در هر لحظه فقط یک آدرس می‌تواند اصلی باشد. پاسخ، آدرس با is_default: true است. خطای 400 با کد ConflictingServerStateException اگر سرور روشن باشد (باید خاموش شود).

curl -X POST "https://pufferland.ir/api/client/servers/1a85a183/network/allocations/1146/primary" \
  -H "Authorization: Bearer ptlc_xxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json"
POST/api/client/servers/{server}/network/allocations/{allocation}

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

فیلدنوعالزامتوضیح
notesstringمتن یادداشت (حداکثر ۲۵۵ کاراکتر).
curl -X POST "https://pufferland.ir/api/client/servers/1a85a183/network/allocations/1146" \
  -H "Authorization: Bearer ptlc_xxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{"notes": "سرور اصلی ماینکرفت"}'
نمونه پاسخ واقعی:
{
  "object": "allocation",
  "attributes": {
    "id": 1146,
    "ip": "37.32.43.26",
    "ip_alias": "p5.pfmc.ir",
    "port": 1038,
    "notes": "سرور اصلی ماینکرفت",
    "is_default": true
  }
}
DELETE/api/client/servers/{server}/network/allocations/{allocation}

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

خطاها (400): حذف آدرس اصلی مجاز نیست (CannotDeletePrimaryAllocationException — ابتدا آدرس اصلی را تغییر دهید) و سرور باید خاموش باشد (ConflictingServerStateException).

curl -X DELETE "https://pufferland.ir/api/client/servers/1a85a183/network/allocations/1146" \
  -H "Authorization: Bearer ptlc_xxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Accept: application/json"
نمونه پاسخ واقعی:
204 No Content