همهٔ سیستم‌ها عملیاتی‌اند

مرجع API · نسخهٔ v1

API فایروال سرور

وضعیت فایروال هر سرور، افزودن و حذف قانون و روشن یا خاموش کردن آن. این گروه با شناسهٔ vm-firewall در فایل OpenAPI آمده و ۴ endpoint دارد.

نمونه‌های curl توکن را از متغیر محیطی IRANCLAUD_TOKEN می‌خوانند؛ ساخت توکن و تنظیم این متغیر در راهنمای شروع سریع آمده است.

GET /api/v1/vms/{uuid}/firewall #

Get the firewall state and rules of a server

دسترسی لازم: vm:firewall:read محدودیت نرخ: خواندن
پارامترهای مسیر (۱)
uuid string
الزامی Server UUID (from GET /api/v1/vms)
پاسخ‌ها (۶)
  • 200 Enabled flag, default policies and rules (pos = position used by DELETE) data: enabledpolicy_inpolicy_outrules
  • 401 unauthenticated — Authorization header missing or not "Bearer …"; token_invalid — token unknown or secret wrong; token_expired / token_revoked / ip_blocked — the secret is right but the token has expired, was revoked or is not allowed from this IP (details.manage_url)
  • 403 scope_missing — the token lacks vm:firewall:read (details.required_scope); account_suspended — the account of this token is suspended
  • 404 not_found — unknown server or owned by another account
  • 429 rate_limited — read limit reached; wait Retry-After seconds (details.retry_after_sec)
  • 503 compute_unavailable — the server platform did not answer; retry later
نمونهٔ curl
curl
curl \
  -H "Authorization: Bearer $IRANCLAUD_TOKEN" \
  "https://iranclaud.ir/api/v1/vms/YOUR_UUID/firewall"

بازگشت به فهرست این بخش

POST /api/v1/vms/{uuid}/firewall/rules #

Add an inbound firewall rule

دسترسی لازم: vm:firewall:write محدودیت نرخ: تغییر
پارامترهای مسیر (۱)
uuid string
الزامی Server UUID (from GET /api/v1/vms)
فیلدهای بدنه (JSON) (۵)
action string
اختیاری Case-insensitive — one of: ACCEPT | DROP; default: ACCEPT
proto string
الزامی one of: tcp | udp | icmp
port string
اختیاری Required for tcp/udp: 1-65535 or a "low:high" range with low <= high (8000:8999); ignored for icmp — pattern ^[0-9]{1,5}(:[0-9]{1,5})?$
source string
اختیاری "any", or an IPv4/IPv6 address with an optional prefix: /0-/32 for IPv4, /0-/128 for IPv6 — default: 0.0.0.0/0; max 43 chars
comment string
اختیاری Up to 120 characters (not bytes), no control characters such as line breaks or tabs — max 120 chars
نمونهٔ بدنهٔ درخواست (JSON)
application/json
{
    "proto": "tcp",
    "port": "443",
    "source": "203.0.113.0/24",
    "comment": "HTTPS"
}
پاسخ‌ها (۷)
  • 201 Rule created data: vm_uuidrule
  • 401 unauthenticated — Authorization header missing or not "Bearer …"; token_invalid — token unknown or secret wrong; token_expired / token_revoked / ip_blocked — the secret is right but the token has expired, was revoked or is not allowed from this IP (details.manage_url)
  • 403 scope_missing — the token lacks vm:firewall:write (details.required_scope); account_suspended — the account of this token is suspended; vm_access_locked — access to this server is locked by support (open a ticket to change it)
  • 404 not_found — unknown server or owned by another account
  • 422 validation_failed — details.fields names action, proto, port, source or comment (e.g. an IPv4 prefix above /32 or a comment over 120 characters)
  • 429 rate_limited — write limit reached; wait Retry-After seconds (details.retry_after_sec)
  • 503 compute_unavailable — the server platform did not answer; retry later
نمونهٔ curl
curl
curl -X POST \
  -H "Authorization: Bearer $IRANCLAUD_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"proto":"tcp","port":"443","source":"203.0.113.0/24","comment":"HTTPS"}' \
  "https://iranclaud.ir/api/v1/vms/YOUR_UUID/firewall/rules"

بازگشت به فهرست این بخش

DELETE /api/v1/vms/{uuid}/firewall/rules/{pos} #

Remove a firewall rule by position

دسترسی لازم: vm:firewall:write محدودیت نرخ: تغییر
پارامترهای مسیر (۲)
uuid string
الزامی Server UUID (from GET /api/v1/vms)
pos integer
الزامی Rule position (rules[].pos from GET …/firewall); positions shift after a delete — read the list again
پاسخ‌ها (۶)
  • 204 Removed
  • 401 unauthenticated — Authorization header missing or not "Bearer …"; token_invalid — token unknown or secret wrong; token_expired / token_revoked / ip_blocked — the secret is right but the token has expired, was revoked or is not allowed from this IP (details.manage_url)
  • 403 scope_missing — the token lacks vm:firewall:write (details.required_scope); account_suspended — the account of this token is suspended; vm_access_locked — access to this server is locked by support (open a ticket to change it)
  • 404 not_found — unknown server or owned by another account
  • 429 rate_limited — write limit reached; wait Retry-After seconds (details.retry_after_sec)
  • 503 compute_unavailable — the server platform did not answer; retry later
نمونهٔ curl
curl
curl -X DELETE \
  -H "Authorization: Bearer $IRANCLAUD_TOKEN" \
  "https://iranclaud.ir/api/v1/vms/YOUR_UUID/firewall/rules/0"

بازگشت به فهرست این بخش

POST /api/v1/vms/{uuid}/firewall/toggle #

Enable or disable the server firewall

دسترسی لازم: vm:firewall:write محدودیت نرخ: تغییر
پارامترهای مسیر (۱)
uuid string
الزامی Server UUID (from GET /api/v1/vms)
فیلدهای بدنه (JSON) (۱)
enabled boolean
الزامی
نمونهٔ بدنهٔ درخواست (JSON)
application/json
{
    "enabled": true
}
پاسخ‌ها (۷)
  • 200 New state data: vm_uuidenabled
  • 401 unauthenticated — Authorization header missing or not "Bearer …"; token_invalid — token unknown or secret wrong; token_expired / token_revoked / ip_blocked — the secret is right but the token has expired, was revoked or is not allowed from this IP (details.manage_url)
  • 403 scope_missing — the token lacks vm:firewall:write (details.required_scope); account_suspended — the account of this token is suspended; vm_access_locked — access to this server is locked by support (open a ticket to change it)
  • 404 not_found — unknown server or owned by another account
  • 422 validation_failed — enabled missing or not a boolean
  • 429 rate_limited — write limit reached; wait Retry-After seconds (details.retry_after_sec)
  • 503 compute_unavailable — the server platform did not answer; retry later
نمونهٔ curl
curl
curl -X POST \
  -H "Authorization: Bearer $IRANCLAUD_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"enabled":true}' \
  "https://iranclaud.ir/api/v1/vms/YOUR_UUID/firewall/toggle"

بازگشت به فهرست این بخش

همهٔ گروه‌های API