API documentation Web hosting accessible to everyone Visit LWS

Modificare un set di regole

PUT /api/v1/firewall/sets/{id}

operationIdputFirewallSet

Livello richiesto
Operatività
Quota
modifica, 300 chiamate all'ora

Sostituisce il nome e la totalità delle regole: non si tratta di un'unione, le regole assenti dal corpo scompaiono. Una description assente dal corpo viene conservata; se presente e vuota, viene cancellata.

L'aggiornamento del firewall di tutti i VPS su cui il set è applicato viene messo in coda immediatamente (servono alcuni minuti): modificare un set in uso cambia il firewall di più macchine in un colpo solo (applied_to indica quali).

Con una chiave limitata a una selezione di VPS, un set applicato anche a un VPS non coperto dalla chiave non può essere né modificato né eliminato (409 invalid_state): proceda dal pannello oppure estenda l'ambito della chiave.

Path parameters

id string required

Identificativo del set di regole.

pattern ^\d+$ Example: 34

Request body

  • name string

    max 100 characters

    required
  • description string
    optional
  • rules object[]
    required
  • port string

    Porta (443) o intervallo (8000-8100), limiti da 1 a 65535

    Example: 443

    required
  • protocol string

    one of: TCP, UDP

    required
  • subnet string

    Indirizzi IPv4/IPv6 (CIDR accettato, tranne /0 in IPv6) separati da virgole; assente, vuoto o NULL: da qualsiasi origine, sia in IPv4 sia in IPv6

    Example: 45.54.45.54

    optional
Example request
{
  "name": "Web public",
  "rules": [
    {
      "port": "443",
      "protocol": "TCP",
      "subnet": "45.54.45.54"
    },
    {
      "port": "8000-8100",
      "protocol": "TCP",
      "subnet": "NULL"
    }
  ]
}

Responses

200

Set aggiornato

{
  "data": {
    "id": "34",
    "name": "Web public",
    "description": "HTTPS depuis le bureau",
    "rules": [
      {
        "port": "443",
        "protocol": "TCP",
        "sources": [
          "45.54.45.54"
        ],
        "open_to_any": false
      }
    ],
    "applied_to": [
      "116807"
    ]
  }
}
Response fields 10
  • data object required
  • id string

    Example: 34

  • name string
  • description string
  • rules object[]
  • port string

    Porta o intervallo inizio-fine

    Example: 443

  • protocol string

    Protocollo, sempre in maiuscolo

    one of: TCP, UDP

  • sources string[]

    Indirizzi o intervalli CIDR autorizzati; vuoto se la regola è aperta a tutti

  • open_to_any boolean

    true se nessun indirizzo limita la regola

  • applied_to string[]

    VPS (coperti dalla chiave) a cui il set è applicato

400

Parametri non validi: validation_failed — nome assente o troppo lungo, oppure regola non valida (ne viene indicata la posizione).

{
  "type": "https://docs.lws.fr/kvm/errors/validation-failed",
  "title": "Paramètres invalides",
  "status": 400,
  "code": "validation_failed",
  "detail": "Règle #2 : port hors limites (99999)",
  "request_id": "3f9a1c07b2e45d18",
  "errors": {
    "rules": "Règle #2 : port hors limites (99999)"
  }
}
Response fields 18
  • type string (uri)

    Example: https://docs.lws.fr/kvm/errors/vm-not-found

    required
  • title string

    Titolo breve

    Example: VPS introuvable

    required
  • status integer (int64)

    Stato HTTP

    Example: 404

    required
  • code string

    Codice macchina stabile (vedere «Errori» in Per iniziare)

    Example: vm_not_found

    required
  • detail string

    Messaggio dettagliato

    Example: Aucun VPS 999999 sur ce compte.

    required
  • request_id string

    Identificativo della richiesta, da comunicare al supporto

    Example: 3f9a1c07b2e45d18

    required
  • errors object

    validation_failed: messaggio per ogni parametro errato

  • required_level string

    insufficient_scope: livello richiesto dall'operazione

    one of: read, exploitation, full

  • task_id string

    task_already_running: task in corso su questo VPS

    Example: tsk_000002d5

  • family string

    rate_limited: famiglia di quota esaurita

    one of: read, mutation, heavy

  • limit integer (int64)

    rate_limited: limite orario della famiglia

  • retry_after integer (int64)

    rate_limited: secondi da attendere

  • lock string

    server_locked: blocco impostato dall'hypervisor (backup, snapshot, suspended…)

    Example: snapshot

  • reason string

    server_locked: operation_in_progress, è in corso un'operazione, riprovi dopo Retry-After; suspended, il VPS è in ibernazione, lo avvii prima; support_notified, blocco anomalo, il team LWS è stato avvisato e sta intervenendo

    one of: operation_in_progress, suspended, support_notified

  • maintenance object

    server_maintenance: natura dell'intervento, inizio e fine prevista (null per un incidente)

  • kind string

    one of: works, incident

  • started_at string (date-time)
  • expected_end string (date-time)
401

Autenticazione rifiutata: invalid_token — intestazione Authorization assente o non valida, oppure chiave sconosciuta; access_disabled — accesso API disattivato per questo account, oppure servizio API momentaneamente sospeso da LWS.

intestazione Authorization assente o non valida, oppure chiave sconosciuta

{
  "type": "https://docs.lws.fr/kvm/errors/invalid-token",
  "title": "Authentification invalide",
  "status": 401,
  "code": "invalid_token",
  "detail": "Clé inconnue ou révoquée.",
  "request_id": "3f9a1c07b2e45d18"
}

accesso API disattivato per questo account, oppure servizio API momentaneamente sospeso da LWS

{
  "type": "https://docs.lws.fr/kvm/errors/access-disabled",
  "title": "Accès API désactivé",
  "status": 401,
  "code": "access_disabled",
  "detail": "L'accès API est désactivé pour ce compte. Réactivez-le depuis la page « API / MCP » du panel.",
  "request_id": "3f9a1c07b2e45d18"
}
Response fields 18
  • type string (uri)

    Example: https://docs.lws.fr/kvm/errors/vm-not-found

    required
  • title string

    Titolo breve

    Example: VPS introuvable

    required
  • status integer (int64)

    Stato HTTP

    Example: 404

    required
  • code string

    Codice macchina stabile (vedere «Errori» in Per iniziare)

    Example: vm_not_found

    required
  • detail string

    Messaggio dettagliato

    Example: Aucun VPS 999999 sur ce compte.

    required
  • request_id string

    Identificativo della richiesta, da comunicare al supporto

    Example: 3f9a1c07b2e45d18

    required
  • errors object

    validation_failed: messaggio per ogni parametro errato

  • required_level string

    insufficient_scope: livello richiesto dall'operazione

    one of: read, exploitation, full

  • task_id string

    task_already_running: task in corso su questo VPS

    Example: tsk_000002d5

  • family string

    rate_limited: famiglia di quota esaurita

    one of: read, mutation, heavy

  • limit integer (int64)

    rate_limited: limite orario della famiglia

  • retry_after integer (int64)

    rate_limited: secondi da attendere

  • lock string

    server_locked: blocco impostato dall'hypervisor (backup, snapshot, suspended…)

    Example: snapshot

  • reason string

    server_locked: operation_in_progress, è in corso un'operazione, riprovi dopo Retry-After; suspended, il VPS è in ibernazione, lo avvii prima; support_notified, blocco anomalo, il team LWS è stato avvisato e sta intervenendo

    one of: operation_in_progress, suspended, support_notified

  • maintenance object

    server_maintenance: natura dell'intervento, inizio e fine prevista (null per un incidente)

  • kind string

    one of: works, incident

  • started_at string (date-time)
  • expected_end string (date-time)
403

Accesso negato: insufficient_scope — livello della chiave insufficiente; ip_not_allowed — indirizzo di chiamata non autorizzato.

livello della chiave insufficiente

{
  "type": "https://docs.lws.fr/kvm/errors/insufficient-scope",
  "title": "Droits insuffisants",
  "status": 403,
  "code": "insufficient_scope",
  "detail": "Niveau de permission « exploitation » requis.",
  "request_id": "3f9a1c07b2e45d18",
  "required_level": "exploitation"
}

indirizzo di chiamata non autorizzato

{
  "type": "https://docs.lws.fr/kvm/errors/ip-not-allowed",
  "title": "Adresse non autorisée",
  "status": 403,
  "code": "ip_not_allowed",
  "detail": "L'adresse 203.0.113.10 ne figure pas parmi les adresses autorisées de ce compte.",
  "request_id": "3f9a1c07b2e45d18"
}
Response fields 18
  • type string (uri)

    Example: https://docs.lws.fr/kvm/errors/vm-not-found

    required
  • title string

    Titolo breve

    Example: VPS introuvable

    required
  • status integer (int64)

    Stato HTTP

    Example: 404

    required
  • code string

    Codice macchina stabile (vedere «Errori» in Per iniziare)

    Example: vm_not_found

    required
  • detail string

    Messaggio dettagliato

    Example: Aucun VPS 999999 sur ce compte.

    required
  • request_id string

    Identificativo della richiesta, da comunicare al supporto

    Example: 3f9a1c07b2e45d18

    required
  • errors object

    validation_failed: messaggio per ogni parametro errato

  • required_level string

    insufficient_scope: livello richiesto dall'operazione

    one of: read, exploitation, full

  • task_id string

    task_already_running: task in corso su questo VPS

    Example: tsk_000002d5

  • family string

    rate_limited: famiglia di quota esaurita

    one of: read, mutation, heavy

  • limit integer (int64)

    rate_limited: limite orario della famiglia

  • retry_after integer (int64)

    rate_limited: secondi da attendere

  • lock string

    server_locked: blocco impostato dall'hypervisor (backup, snapshot, suspended…)

    Example: snapshot

  • reason string

    server_locked: operation_in_progress, è in corso un'operazione, riprovi dopo Retry-After; suspended, il VPS è in ibernazione, lo avvii prima; support_notified, blocco anomalo, il team LWS è stato avvisato e sta intervenendo

    one of: operation_in_progress, suspended, support_notified

  • maintenance object

    server_maintenance: natura dell'intervento, inizio e fine prevista (null per un incidente)

  • kind string

    one of: works, incident

  • started_at string (date-time)
  • expected_end string (date-time)
404

Risorsa non trovata: set_not_found — set sconosciuto o appartenente a un altro account.

{
  "type": "https://docs.lws.fr/kvm/errors/set-not-found",
  "title": "Jeu de règles introuvable",
  "status": 404,
  "code": "set_not_found",
  "detail": "Jeu de règles introuvable.",
  "request_id": "3f9a1c07b2e45d18"
}
Response fields 18
  • type string (uri)

    Example: https://docs.lws.fr/kvm/errors/vm-not-found

    required
  • title string

    Titolo breve

    Example: VPS introuvable

    required
  • status integer (int64)

    Stato HTTP

    Example: 404

    required
  • code string

    Codice macchina stabile (vedere «Errori» in Per iniziare)

    Example: vm_not_found

    required
  • detail string

    Messaggio dettagliato

    Example: Aucun VPS 999999 sur ce compte.

    required
  • request_id string

    Identificativo della richiesta, da comunicare al supporto

    Example: 3f9a1c07b2e45d18

    required
  • errors object

    validation_failed: messaggio per ogni parametro errato

  • required_level string

    insufficient_scope: livello richiesto dall'operazione

    one of: read, exploitation, full

  • task_id string

    task_already_running: task in corso su questo VPS

    Example: tsk_000002d5

  • family string

    rate_limited: famiglia di quota esaurita

    one of: read, mutation, heavy

  • limit integer (int64)

    rate_limited: limite orario della famiglia

  • retry_after integer (int64)

    rate_limited: secondi da attendere

  • lock string

    server_locked: blocco impostato dall'hypervisor (backup, snapshot, suspended…)

    Example: snapshot

  • reason string

    server_locked: operation_in_progress, è in corso un'operazione, riprovi dopo Retry-After; suspended, il VPS è in ibernazione, lo avvii prima; support_notified, blocco anomalo, il team LWS è stato avvisato e sta intervenendo

    one of: operation_in_progress, suspended, support_notified

  • maintenance object

    server_maintenance: natura dell'intervento, inizio e fine prevista (null per un incidente)

  • kind string

    one of: works, incident

  • started_at string (date-time)
  • expected_end string (date-time)
409

Conflitto con lo stato attuale: invalid_state — set applicato anche a VPS non coperti dalla chiave.

{
  "type": "https://docs.lws.fr/kvm/errors/invalid-state",
  "title": "Opération impossible en l'état",
  "status": 409,
  "code": "invalid_state",
  "detail": "Ce jeu de règles est aussi appliqué à des VPS que cette clé ne couvre pas. Modifiez-le depuis le panel, ou étendez la portée de la clé à ces VPS.",
  "request_id": "3f9a1c07b2e45d18"
}
Response fields 18
  • type string (uri)

    Example: https://docs.lws.fr/kvm/errors/vm-not-found

    required
  • title string

    Titolo breve

    Example: VPS introuvable

    required
  • status integer (int64)

    Stato HTTP

    Example: 404

    required
  • code string

    Codice macchina stabile (vedere «Errori» in Per iniziare)

    Example: vm_not_found

    required
  • detail string

    Messaggio dettagliato

    Example: Aucun VPS 999999 sur ce compte.

    required
  • request_id string

    Identificativo della richiesta, da comunicare al supporto

    Example: 3f9a1c07b2e45d18

    required
  • errors object

    validation_failed: messaggio per ogni parametro errato

  • required_level string

    insufficient_scope: livello richiesto dall'operazione

    one of: read, exploitation, full

  • task_id string

    task_already_running: task in corso su questo VPS

    Example: tsk_000002d5

  • family string

    rate_limited: famiglia di quota esaurita

    one of: read, mutation, heavy

  • limit integer (int64)

    rate_limited: limite orario della famiglia

  • retry_after integer (int64)

    rate_limited: secondi da attendere

  • lock string

    server_locked: blocco impostato dall'hypervisor (backup, snapshot, suspended…)

    Example: snapshot

  • reason string

    server_locked: operation_in_progress, è in corso un'operazione, riprovi dopo Retry-After; suspended, il VPS è in ibernazione, lo avvii prima; support_notified, blocco anomalo, il team LWS è stato avvisato e sta intervenendo

    one of: operation_in_progress, suspended, support_notified

  • maintenance object

    server_maintenance: natura dell'intervento, inizio e fine prevista (null per un incidente)

  • kind string

    one of: works, incident

  • started_at string (date-time)
  • expected_end string (date-time)
429

Quota superata: rate_limited — quota oraria della famiglia esaurita.

{
  "type": "https://docs.lws.fr/kvm/errors/rate-limited",
  "title": "Quota dépassé",
  "status": 429,
  "code": "rate_limited",
  "detail": "Quota dépassé pour les opérations de type « mutation » : 300 appels par heure. Réessayez dans 95 seconde(s).",
  "request_id": "3f9a1c07b2e45d18",
  "family": "mutation",
  "limit": 300,
  "retry_after": 95
}
Response fields 18
  • type string (uri)

    Example: https://docs.lws.fr/kvm/errors/vm-not-found

    required
  • title string

    Titolo breve

    Example: VPS introuvable

    required
  • status integer (int64)

    Stato HTTP

    Example: 404

    required
  • code string

    Codice macchina stabile (vedere «Errori» in Per iniziare)

    Example: vm_not_found

    required
  • detail string

    Messaggio dettagliato

    Example: Aucun VPS 999999 sur ce compte.

    required
  • request_id string

    Identificativo della richiesta, da comunicare al supporto

    Example: 3f9a1c07b2e45d18

    required
  • errors object

    validation_failed: messaggio per ogni parametro errato

  • required_level string

    insufficient_scope: livello richiesto dall'operazione

    one of: read, exploitation, full

  • task_id string

    task_already_running: task in corso su questo VPS

    Example: tsk_000002d5

  • family string

    rate_limited: famiglia di quota esaurita

    one of: read, mutation, heavy

  • limit integer (int64)

    rate_limited: limite orario della famiglia

  • retry_after integer (int64)

    rate_limited: secondi da attendere

  • lock string

    server_locked: blocco impostato dall'hypervisor (backup, snapshot, suspended…)

    Example: snapshot

  • reason string

    server_locked: operation_in_progress, è in corso un'operazione, riprovi dopo Retry-After; suspended, il VPS è in ibernazione, lo avvii prima; support_notified, blocco anomalo, il team LWS è stato avvisato e sta intervenendo

    one of: operation_in_progress, suspended, support_notified

  • maintenance object

    server_maintenance: natura dell'intervento, inizio e fine prevista (null per un incidente)

  • kind string

    one of: works, incident

  • started_at string (date-time)
  • expected_end string (date-time)
502

Dipendenza irraggiungibile: upstream_unavailable — registrazione impossibile.

{
  "type": "https://docs.lws.fr/kvm/errors/upstream-unavailable",
  "title": "Service momentanément indisponible",
  "status": 502,
  "code": "upstream_unavailable",
  "detail": "Inventaire des VM indisponible.",
  "request_id": "3f9a1c07b2e45d18"
}
Response fields 18
  • type string (uri)

    Example: https://docs.lws.fr/kvm/errors/vm-not-found

    required
  • title string

    Titolo breve

    Example: VPS introuvable

    required
  • status integer (int64)

    Stato HTTP

    Example: 404

    required
  • code string

    Codice macchina stabile (vedere «Errori» in Per iniziare)

    Example: vm_not_found

    required
  • detail string

    Messaggio dettagliato

    Example: Aucun VPS 999999 sur ce compte.

    required
  • request_id string

    Identificativo della richiesta, da comunicare al supporto

    Example: 3f9a1c07b2e45d18

    required
  • errors object

    validation_failed: messaggio per ogni parametro errato

  • required_level string

    insufficient_scope: livello richiesto dall'operazione

    one of: read, exploitation, full

  • task_id string

    task_already_running: task in corso su questo VPS

    Example: tsk_000002d5

  • family string

    rate_limited: famiglia di quota esaurita

    one of: read, mutation, heavy

  • limit integer (int64)

    rate_limited: limite orario della famiglia

  • retry_after integer (int64)

    rate_limited: secondi da attendere

  • lock string

    server_locked: blocco impostato dall'hypervisor (backup, snapshot, suspended…)

    Example: snapshot

  • reason string

    server_locked: operation_in_progress, è in corso un'operazione, riprovi dopo Retry-After; suspended, il VPS è in ibernazione, lo avvii prima; support_notified, blocco anomalo, il team LWS è stato avvisato e sta intervenendo

    one of: operation_in_progress, suspended, support_notified

  • maintenance object

    server_maintenance: natura dell'intervento, inizio e fine prevista (null per un incidente)

  • kind string

    one of: works, incident

  • started_at string (date-time)
  • expected_end string (date-time)
Show the code examples and the test console
PUT /firewall/sets/{id}
LWS_API_KEY='…'curl -X PUT \  "https://panelkvm.lwspanel.com/api/v1/firewall/sets/34" \  -H "Authorization: Bearer $LWS_API_KEY" \  -H "Content-Type: application/json" \  -d '{"name":"Web public","rules":[{"port":"443","protocol":"TCP","subnet":"45.54.45.54"},{"port":"8000-8100","protocol":"TCP","subnet":"NULL"}]}'
$lwsApiKey = '…';$ch = curl_init("https://panelkvm.lwspanel.com/api/v1/firewall/sets/34");curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_HTTPHEADER, [    "Authorization: Bearer " . $lwsApiKey,    "Content-Type: application/json",]);curl_setopt($ch, CURLOPT_POSTFIELDS, '{"name":"Web public","rules":[{"port":"443","protocol":"TCP","subnet":"45.54.45.54"},{"port":"8000-8100","protocol":"TCP","subnet":"NULL"}]}');$res = json_decode(curl_exec($ch), true);
import requestsLWS_API_KEY = "…"res = requests.put(    "https://panelkvm.lwspanel.com/api/v1/firewall/sets/34",    headers={        "Authorization": "Bearer " + LWS_API_KEY,    },    json={"name": "Web public", "rules": [{"port": "443", "protocol": "TCP", "subnet": "45.54.45.54"}, {"port": "8000-8100", "protocol": "TCP", "subnet": "NULL"}]},)print(res.json())
const LWS_API_KEY = "…";const res = await fetch("https://panelkvm.lwspanel.com/api/v1/firewall/sets/34", {  method: "PUT",  headers: {    "Authorization": "Bearer " + LWS_API_KEY,    "Content-Type": "application/json",  },  body: JSON.stringify({"name":"Web public","rules":[{"port":"443","protocol":"TCP","subnet":"45.54.45.54"},{"port":"8000-8100","protocol":"TCP","subnet":"NULL"}]}),});const data = await res.json();
lwsApiKey := "…"body := strings.NewReader(`{"name":"Web public","rules":[{"port":"443","protocol":"TCP","subnet":"45.54.45.54"},{"port":"8000-8100","protocol":"TCP","subnet":"NULL"}]}`)req, _ := http.NewRequest("PUT",    "https://panelkvm.lwspanel.com/api/v1/firewall/sets/34", body)req.Header.Set("Authorization", "Bearer "+lwsApiKey)req.Header.Set("Content-Type", "application/json")resp, err := http.DefaultClient.Do(req)