---
title: "Ağ — API başvurusu"
description: "Sunucunun ters DNS kayıtları ve gelen trafik güvenlik duvarı."
url: https://www.gyrohosting.com/developers/tr/api/networking.html
language: tr
openapi: https://www.gyrohosting.com/developers/openapi.json
api_version: 2.30.0
---

# Ağ

Sunucunun ters DNS kayıtları ve gelen trafik güvenlik duvarı.

Base URL: `https://www.gyrohosting.com/api/v1/client` · OpenAPI: https://www.gyrohosting.com/developers/openapi.json


## GET /cloud/servers/{id}/rdns

**Ters DNS kayıtlarını listele** · operationId `listRdns` · scope `cloud_read` · OpenAPI fragment: https://www.gyrohosting.com/developers/spec/ops/listRdns.json

**tr-ist-1 (Gyro Bulut İstanbul):** her adres (birincil ve ek IPv4) için otomatik PTR `<a-b-c-d>.ip.gyrohosting.com` ve eşleşen A kaydı vardır. `hostname` ile kendi tam alan adınızı yazın (saniyeler içinde yayında); boş değer varsayılana döndürür. Gyro alan adları altı ve korunan marka adları reddedilir (HTTP 422, açıklayıcı mesaj); sunucu başına saatte en çok 30 değişiklik. E-posta teslimi için adınızın A kaydı bu adresi göstermeli (zorunlu değil). Sunucu silinince ya da ek IP bırakılınca PTR kaldırılır. 


### Parametreler

| Alan | in | Tür | Açıklama |
|---|---|---|---|
| `id` (zorunlu) | path | integer | Server id (= service id in the client area) |

### Yanıtlar

- **200**: PTR records of the server's addresses
- **404**: Not found — also returned for objects owned by someone else

### Örnekler

```bash
curl -s 'https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/rdns' \
  -H "Authorization: Bearer $GYRO_TOKEN"
```
```bash
gyro server rdns list 12345
```
```hcl
# kaynak gyro_server_rdns: https://registry.terraform.io/providers/gyro-hosting/gyro/latest/docs/resources/server_rdns
resource "gyro_server_rdns" "mail" {
  server_id = gyro_server.web.id
  ip        = gyro_server.web.ipv4
  hostname  = "mail.example.com"
}
```
```python
import os, uuid, requests

h = {"Authorization": "Bearer " + os.environ["GYRO_TOKEN"]}
r = requests.get("https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/rdns", headers=h, timeout=60)
r.raise_for_status()
print(r.json()["data"])
```
```js
const res = await fetch("https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/rdns", {
  method: "GET",
  headers: {
    "Authorization": `Bearer ${process.env.GYRO_TOKEN}`,
  },
});
const { data, error } = await res.json();
if (!res.ok) throw new Error(`${error.code}: ${error.message}`);
```


## PUT /cloud/servers/{id}/rdns

**Bir adresin PTR kaydını ayarla (veya sıfırla)** · operationId `setRdns` · scope `cloud_write` · OpenAPI fragment: https://www.gyrohosting.com/developers/spec/ops/setRdns.json

**tr-ist-1 (Gyro Bulut İstanbul):** her adres (birincil ve ek IPv4) için otomatik PTR `<a-b-c-d>.ip.gyrohosting.com` ve eşleşen A kaydı vardır. `hostname` ile kendi tam alan adınızı yazın (saniyeler içinde yayında); boş değer varsayılana döndürür. Gyro alan adları altı ve korunan marka adları reddedilir (HTTP 422, açıklayıcı mesaj); sunucu başına saatte en çok 30 değişiklik. E-posta teslimi için adınızın A kaydı bu adresi göstermeli (zorunlu değil). Sunucu silinince ya da ek IP bırakılınca PTR kaldırılır. 


### Parametreler

| Alan | in | Tür | Açıklama |
|---|---|---|---|
| `id` (zorunlu) | path | integer | Server id (= service id in the client area) |

### İstek gövdesi

| Alan | Tür | Açıklama |
|---|---|---|
| `ip` (zorunlu) | string | An address of this server (IPv6 addresses inside the server's /64 are allowed) |
| `hostname` | string | FQDN; empty string resets to the default |

### Yanıtlar

- **200**: Updated list
- **404**: Not found — also returned for objects owned by someone else
- **422**: Validation or business rule failure (`confirm_required`, `invalid_image`, `tool_action_failed` ...)

### Örnekler

```bash
curl -s -X PUT 'https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/rdns' \
  -H "Authorization: Bearer $GYRO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"ip": "string", "hostname": "string"}'
```
```bash
gyro server rdns set 12345 --help    # tüm seçenekler
```
```hcl
# kaynak gyro_server_rdns: https://registry.terraform.io/providers/gyro-hosting/gyro/latest/docs/resources/server_rdns
resource "gyro_server_rdns" "mail" {
  server_id = gyro_server.web.id
  ip        = gyro_server.web.ipv4
  hostname  = "mail.example.com"
}
```
```python
import os, uuid, requests

h = {"Authorization": "Bearer " + os.environ["GYRO_TOKEN"]}
r = requests.put("https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/rdns", headers=h, json={"ip": "string", "hostname": "string"}, timeout=60)
r.raise_for_status()
print(r.json()["data"])
```
```js
const res = await fetch("https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/rdns", {
  method: "PUT",
  headers: {
    "Authorization": `Bearer ${process.env.GYRO_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({"ip": "string", "hostname": "string"}),
});
const { data, error } = await res.json();
if (!res.ok) throw new Error(`${error.code}: ${error.message}`);
```


## GET /cloud/servers/{id}/firewall

**Gelen trafik güvenlik duvarı kuralları** · operationId `getFirewall` · scope `cloud_read` · OpenAPI fragment: https://www.gyrohosting.com/developers/spec/ops/getFirewall.json

v1'de salt okunur. Boş liste Gyro güvenlik duvarı uygulanmadığı (tüm gelen trafiğin sunucuya ulaştığı) anlamına gelir.


### Parametreler

| Alan | in | Tür | Açıklama |
|---|---|---|---|
| `id` (zorunlu) | path | integer | Server id (= service id in the client area) |

### Yanıtlar

- **200**: Rules
- **404**: Not found — also returned for objects owned by someone else

### Örnekler

```bash
curl -s 'https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/firewall' \
  -H "Authorization: Bearer $GYRO_TOKEN"
```
```bash
gyro server firewall list 12345
```
```hcl
# kaynak gyro_firewall: https://registry.terraform.io/providers/gyro-hosting/gyro/latest/docs/resources/firewall
# Web server: 80/443 open to everyone, SSH only from the office, everything else denied.
resource "gyro_firewall" "web" {
  server_id      = 1234
  default_action = "deny"

  rule {
    action      = "allow"
    protocol    = "tcp"
    port        = "80,443"
    description = "web"
  }
  rule {
    action   = "allow"
    protocol = "udp"
    port     = "443"
  }
  rule {
    action = "allow"
    port   = "22"
    source = "203.0.113.10"
  }
}

# Database: open, but 3306 closed to one address; outbound SMTP blocked.
resource "gyro_firewall" "db" {
  server_id      = 1235
  default_action = "allow"

  rule {
    action = "deny"
    port   = "3306"
    source = "198.51.100.7"
  }
  rule {
    direction = "out"
    action    = "deny"
    port      = "25"
  }
}
```
```python
import os, uuid, requests

h = {"Authorization": "Bearer " + os.environ["GYRO_TOKEN"]}
r = requests.get("https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/firewall", headers=h, timeout=60)
r.raise_for_status()
print(r.json()["data"])
```
```js
const res = await fetch("https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/firewall", {
  method: "GET",
  headers: {
    "Authorization": `Bearer ${process.env.GYRO_TOKEN}`,
  },
});
const { data, error } = await res.json();
if (!res.ok) throw new Error(`${error.code}: ${error.message}`);
```


## POST /cloud/servers/{id}/firewall/rules

**Gelen trafik kuralı ekle** · operationId `addFirewallRule` · scope `cloud_write` · OpenAPI fragment: https://www.gyrohosting.com/developers/spec/ops/addFirewallRule.json




### Parametreler

| Alan | in | Tür | Açıklama |
|---|---|---|---|
| `id` (zorunlu) | path | integer | Server id (= service id in the client area) |

### İstek gövdesi

| Alan | Tür | Açıklama |
|---|---|---|
| `priority` | integer | Position (1 = evaluated first). Default = last. First matching rule wins. |
| `direction` | string (in, out) | in = inbound to the server, out = new outbound connections (network firewall only) |
| `action` | string (allow, deny) |  |
| `protocol` | string (tcp, udp, tcp_udp, icmp, all) |  |
| `source` | string | any / IPv4/CIDR list (comma separated, max 10). For direction out: the remote address. Country sources (country:XX / not-country:XX) are accepted only when capabilities.country_filter is true (currently not offered). |
| `destination` | string | any (all IPs of the server) or one IP address of the server |
| `port` | string | any / 22 / 80,443 / 1000-2000 (not for icmp/all) |
| `description` | string |  |
| `source_ips` | array<string> | Legacy - CIDRs (use source) |
| `permanent` | boolean | Network firewall - skip the 5 minute trial and make the change permanent at once |
| `confirm_warnings` | boolean | Apply even when the change has warnings (lock-out risk, shadowed or duplicate rules, private sources) |

### Yanıtlar

- **201**: All rules after the change
- **404**: Not found — also returned for objects owned by someone else
- **422**: Validation or business rule failure (`confirm_required`, `invalid_image`, `tool_action_failed` ...)

### Örnekler

```bash
curl -s -X POST 'https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/firewall/rules' \
  -H "Authorization: Bearer $GYRO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"protocol": "tcp", "port": "22", "source_ips": ["203.0.113.0/24"]}'
```
```bash
gyro server firewall rule add 12345 --help    # tüm seçenekler
```
```hcl
# kaynak gyro_firewall: https://registry.terraform.io/providers/gyro-hosting/gyro/latest/docs/resources/firewall
# Web server: 80/443 open to everyone, SSH only from the office, everything else denied.
resource "gyro_firewall" "web" {
  server_id      = 1234
  default_action = "deny"

  rule {
    action      = "allow"
    protocol    = "tcp"
    port        = "80,443"
    description = "web"
  }
  rule {
    action   = "allow"
    protocol = "udp"
    port     = "443"
  }
  rule {
    action = "allow"
    port   = "22"
    source = "203.0.113.10"
  }
}

# Database: open, but 3306 closed to one address; outbound SMTP blocked.
resource "gyro_firewall" "db" {
  server_id      = 1235
  default_action = "allow"

  rule {
    action = "deny"
    port   = "3306"
    source = "198.51.100.7"
  }
  rule {
    direction = "out"
    action    = "deny"
    port      = "25"
  }
}
```
```python
import os, uuid, requests

h = {"Authorization": "Bearer " + os.environ["GYRO_TOKEN"]}
r = requests.post("https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/firewall/rules", headers=h, json={"protocol": "tcp", "port": "22", "source_ips": ["203.0.113.0/24"]}, timeout=60)
r.raise_for_status()
print(r.json()["data"])
```
```js
const res = await fetch("https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/firewall/rules", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.GYRO_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({"protocol": "tcp", "port": "22", "source_ips": ["203.0.113.0/24"]}),
});
const { data, error } = await res.json();
if (!res.ok) throw new Error(`${error.code}: ${error.message}`);
```


## DELETE /cloud/servers/{id}/firewall/rules/{n}

**Güvenlik duvarı kuralı sil (son kural confirm ister)** · operationId `deleteFirewallRule` · scope `cloud_write` · OpenAPI fragment: https://www.gyrohosting.com/developers/spec/ops/deleteFirewallRule.json




### Parametreler

| Alan | in | Tür | Açıklama |
|---|---|---|---|
| `id` (zorunlu) | path | integer | Server id (= service id in the client area) |
| `n` (zorunlu) | path | integer | 1-based position from GET /firewall |
| `confirm` | query | boolean |  |

### Yanıtlar

- **200**: Remaining rules
- **404**: Not found — also returned for objects owned by someone else
- **422**: Validation or business rule failure (`confirm_required`, `invalid_image`, `tool_action_failed` ...)

### Örnekler

```bash
curl -s -X DELETE 'https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/firewall/rules/1' \
  -H "Authorization: Bearer $GYRO_TOKEN"
```
```bash
gyro server firewall rule delete 12345
```
```hcl
# kaynak gyro_firewall: https://registry.terraform.io/providers/gyro-hosting/gyro/latest/docs/resources/firewall
# Web server: 80/443 open to everyone, SSH only from the office, everything else denied.
resource "gyro_firewall" "web" {
  server_id      = 1234
  default_action = "deny"

  rule {
    action      = "allow"
    protocol    = "tcp"
    port        = "80,443"
    description = "web"
  }
  rule {
    action   = "allow"
    protocol = "udp"
    port     = "443"
  }
  rule {
    action = "allow"
    port   = "22"
    source = "203.0.113.10"
  }
}

# Database: open, but 3306 closed to one address; outbound SMTP blocked.
resource "gyro_firewall" "db" {
  server_id      = 1235
  default_action = "allow"

  rule {
    action = "deny"
    port   = "3306"
    source = "198.51.100.7"
  }
  rule {
    direction = "out"
    action    = "deny"
    port      = "25"
  }
}
```
```python
import os, uuid, requests

h = {"Authorization": "Bearer " + os.environ["GYRO_TOKEN"]}
r = requests.delete("https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/firewall/rules/1", headers=h, timeout=60)
r.raise_for_status()
print(r.json()["data"])
```
```js
const res = await fetch("https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/firewall/rules/1", {
  method: "DELETE",
  headers: {
    "Authorization": `Bearer ${process.env.GYRO_TOKEN}`,
  },
});
const { data, error } = await res.json();
if (!res.ok) throw new Error(`${error.code}: ${error.message}`);
```


## GET /cloud/servers/{id}/firewall/policy

**Ağ güvenlik duvarı politikası (kurallar, varsayılan kural, durum)** · operationId `getFirewallPolicy` · scope `cloud_read` · OpenAPI fragment: https://www.gyrohosting.com/developers/spec/ops/getFirewallPolicy.json




### Parametreler

| Alan | in | Tür | Açıklama |
|---|---|---|---|
| `id` (zorunlu) | path | integer | Server id (= service id in the client area) |

### Yanıtlar

- **200**: Policy
- **404**: Not found — also returned for objects owned by someone else
- **409**: The network firewall add-on is not active on this server (firewall_not_enabled)

### Örnekler

```bash
curl -s 'https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/firewall/policy' \
  -H "Authorization: Bearer $GYRO_TOKEN"
```
```bash
gyro firewall get 12345
```
```hcl
# kaynak gyro_firewall: https://registry.terraform.io/providers/gyro-hosting/gyro/latest/docs/resources/firewall
# Web server: 80/443 open to everyone, SSH only from the office, everything else denied.
resource "gyro_firewall" "web" {
  server_id      = 1234
  default_action = "deny"

  rule {
    action      = "allow"
    protocol    = "tcp"
    port        = "80,443"
    description = "web"
  }
  rule {
    action   = "allow"
    protocol = "udp"
    port     = "443"
  }
  rule {
    action = "allow"
    port   = "22"
    source = "203.0.113.10"
  }
}

# Database: open, but 3306 closed to one address; outbound SMTP blocked.
resource "gyro_firewall" "db" {
  server_id      = 1235
  default_action = "allow"

  rule {
    action = "deny"
    port   = "3306"
    source = "198.51.100.7"
  }
  rule {
    direction = "out"
    action    = "deny"
    port      = "25"
  }
}
```
```python
import os, uuid, requests

h = {"Authorization": "Bearer " + os.environ["GYRO_TOKEN"]}
r = requests.get("https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/firewall/policy", headers=h, timeout=60)
r.raise_for_status()
print(r.json()["data"])
```
```js
const res = await fetch("https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/firewall/policy", {
  method: "GET",
  headers: {
    "Authorization": `Bearer ${process.env.GYRO_TOKEN}`,
  },
});
const { data, error } = await res.json();
if (!res.ok) throw new Error(`${error.code}: ${error.message}`);
```


## PUT /cloud/servers/{id}/firewall/policy

**Ağ güvenlik duvarı politikasını değiştir** · operationId `putFirewallPolicy` · scope `cloud_write` · OpenAPI fragment: https://www.gyrohosting.com/developers/spec/ops/putFirewallPolicy.json




### Parametreler

| Alan | in | Tür | Açıklama |
|---|---|---|---|
| `id` (zorunlu) | path | integer | Server id (= service id in the client area) |

### İstek gövdesi

| Alan | Tür | Açıklama |
|---|---|---|
| `default_action` | string (allow, deny) |  |
| `ping` | boolean |  |
| `rules` (zorunlu) | array<FirewallRuleInput> |  |
| `permanent` | boolean | Skip the 5 minute trial (otherwise call POST /firewall/policy/confirm within 5 minutes or the change is reverted) |
| `confirm_warnings` | boolean |  |

### Yanıtlar

- **200**: Policy after the change
- **404**: Not found — also returned for objects owned by someone else
- **409**: firewall_not_enabled
- **422**: Validation or business rule failure (`confirm_required`, `invalid_image`, `tool_action_failed` ...)

### Örnekler

```bash
curl -s -X PUT 'https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/firewall/policy' \
  -H "Authorization: Bearer $GYRO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"default_action": "deny", "rules": [{"action": "allow", "protocol": "tcp", "port": "80,443", "source": "any"}, {"action": "allow", "protocol": "tcp", "port": "22", "source": "203.0.113.10"}]}'
```
```bash
gyro firewall set 12345 --help    # tüm seçenekler
```
```hcl
# kaynak gyro_firewall: https://registry.terraform.io/providers/gyro-hosting/gyro/latest/docs/resources/firewall
# Web server: 80/443 open to everyone, SSH only from the office, everything else denied.
resource "gyro_firewall" "web" {
  server_id      = 1234
  default_action = "deny"

  rule {
    action      = "allow"
    protocol    = "tcp"
    port        = "80,443"
    description = "web"
  }
  rule {
    action   = "allow"
    protocol = "udp"
    port     = "443"
  }
  rule {
    action = "allow"
    port   = "22"
    source = "203.0.113.10"
  }
}

# Database: open, but 3306 closed to one address; outbound SMTP blocked.
resource "gyro_firewall" "db" {
  server_id      = 1235
  default_action = "allow"

  rule {
    action = "deny"
    port   = "3306"
    source = "198.51.100.7"
  }
  rule {
    direction = "out"
    action    = "deny"
    port      = "25"
  }
}
```
```python
import os, uuid, requests

h = {"Authorization": "Bearer " + os.environ["GYRO_TOKEN"]}
r = requests.put("https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/firewall/policy", headers=h, json={"default_action": "deny", "rules": [{"action": "allow", "protocol": "tcp", "port": "80,443", "source": "any"}, {"action": "allow", "protocol": "tcp", "port": "22", "source": "203.0.113.10"}]}, timeout=60)
r.raise_for_status()
print(r.json()["data"])
```
```js
const res = await fetch("https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/firewall/policy", {
  method: "PUT",
  headers: {
    "Authorization": `Bearer ${process.env.GYRO_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({"default_action": "deny", "rules": [{"action": "allow", "protocol": "tcp", "port": "80,443", "source": "any"}, {"action": "allow", "protocol": "tcp", "port": "22", "source": "203.0.113.10"}]}),
});
const { data, error } = await res.json();
if (!res.ok) throw new Error(`${error.code}: ${error.message}`);
```


## DELETE /cloud/servers/{id}/firewall/policy

**Güvenlik duvarı kurallarınızı kaldır** · operationId `deleteFirewallPolicy` · scope `cloud_write` · OpenAPI fragment: https://www.gyrohosting.com/developers/spec/ops/deleteFirewallPolicy.json




### Parametreler

| Alan | in | Tür | Açıklama |
|---|---|---|---|
| `id` (zorunlu) | path | integer | Server id (= service id in the client area) |

### Yanıtlar

- **200**: Policy after the change
- **404**: Not found — also returned for objects owned by someone else
- **409**: firewall_not_enabled

### Örnekler

```bash
curl -s -X DELETE 'https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/firewall/policy' \
  -H "Authorization: Bearer $GYRO_TOKEN"
```
```bash
gyro firewall delete 12345
```
```hcl
# kaynak gyro_firewall: https://registry.terraform.io/providers/gyro-hosting/gyro/latest/docs/resources/firewall
# Web server: 80/443 open to everyone, SSH only from the office, everything else denied.
resource "gyro_firewall" "web" {
  server_id      = 1234
  default_action = "deny"

  rule {
    action      = "allow"
    protocol    = "tcp"
    port        = "80,443"
    description = "web"
  }
  rule {
    action   = "allow"
    protocol = "udp"
    port     = "443"
  }
  rule {
    action = "allow"
    port   = "22"
    source = "203.0.113.10"
  }
}

# Database: open, but 3306 closed to one address; outbound SMTP blocked.
resource "gyro_firewall" "db" {
  server_id      = 1235
  default_action = "allow"

  rule {
    action = "deny"
    port   = "3306"
    source = "198.51.100.7"
  }
  rule {
    direction = "out"
    action    = "deny"
    port      = "25"
  }
}
```
```python
import os, uuid, requests

h = {"Authorization": "Bearer " + os.environ["GYRO_TOKEN"]}
r = requests.delete("https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/firewall/policy", headers=h, timeout=60)
r.raise_for_status()
print(r.json()["data"])
```
```js
const res = await fetch("https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/firewall/policy", {
  method: "DELETE",
  headers: {
    "Authorization": `Bearer ${process.env.GYRO_TOKEN}`,
  },
});
const { data, error } = await res.json();
if (!res.ok) throw new Error(`${error.code}: ${error.message}`);
```


## POST /cloud/servers/{id}/firewall/policy/confirm

**Güvenlik duvarı denemesini kalıcı yap** · operationId `confirmFirewallPolicy` · scope `cloud_write` · OpenAPI fragment: https://www.gyrohosting.com/developers/spec/ops/confirmFirewallPolicy.json




### Parametreler

| Alan | in | Tür | Açıklama |
|---|---|---|---|
| `id` (zorunlu) | path | integer | Server id (= service id in the client area) |

### Yanıtlar

- **200**: Policy
- **404**: Not found — also returned for objects owned by someone else
- **422**: Validation or business rule failure (`confirm_required`, `invalid_image`, `tool_action_failed` ...)

### Örnekler

```bash
curl -s -X POST 'https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/firewall/policy/confirm' \
  -H "Authorization: Bearer $GYRO_TOKEN"
```
```bash
gyro firewall confirm 12345
```
```hcl
# kaynak gyro_firewall: https://registry.terraform.io/providers/gyro-hosting/gyro/latest/docs/resources/firewall
# Web server: 80/443 open to everyone, SSH only from the office, everything else denied.
resource "gyro_firewall" "web" {
  server_id      = 1234
  default_action = "deny"

  rule {
    action      = "allow"
    protocol    = "tcp"
    port        = "80,443"
    description = "web"
  }
  rule {
    action   = "allow"
    protocol = "udp"
    port     = "443"
  }
  rule {
    action = "allow"
    port   = "22"
    source = "203.0.113.10"
  }
}

# Database: open, but 3306 closed to one address; outbound SMTP blocked.
resource "gyro_firewall" "db" {
  server_id      = 1235
  default_action = "allow"

  rule {
    action = "deny"
    port   = "3306"
    source = "198.51.100.7"
  }
  rule {
    direction = "out"
    action    = "deny"
    port      = "25"
  }
}
```
```python
import os, uuid, requests

h = {"Authorization": "Bearer " + os.environ["GYRO_TOKEN"]}
r = requests.post("https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/firewall/policy/confirm", headers=h, timeout=60)
r.raise_for_status()
print(r.json()["data"])
```
```js
const res = await fetch("https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/firewall/policy/confirm", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.GYRO_TOKEN}`,
  },
});
const { data, error } = await res.json();
if (!res.ok) throw new Error(`${error.code}: ${error.message}`);
```


## GET /cloud/servers/{id}/ips

**Sunucunun IPv4 adresleri** · operationId `listServerIps` · scope `cloud_read` · OpenAPI fragment: https://www.gyrohosting.com/developers/spec/ops/listServerIps.json

**Asgari ücret:** her eklenen IP en az 6 saat ücretlendirilir (`pricing.minimum_hours`): daha erken bırakılsa da asgari süre (bırakırken) düşülür; aynı adresi yeniden almak yeni bir asgari süre başlatır. Bir sunucuya 60 dakikada en çok `adds_per_hour` (varsayılan 10) adres eklenebilir. Ek IPv4 adresleri adres başına ön ödemeli bakiyeden saatlik ücretlendirilir (varsayılan adres başına aylık 2 €, güncel fiyat `pricing` alanında); eklendiği saatten çıkarıldığı saate kadar. Sunucu başına en çok `max` (varsayılan 5). Adres sunucuya otomatik tanımlanır (birincil arayüze /32, yeniden başlatma ve yeniden kurulumda korunur); ters DNS: PUT /cloud/servers/{id}/rdns. 


### Parametreler

| Alan | in | Tür | Açıklama |
|---|---|---|---|
| `id` (zorunlu) | path | integer | Server id (tr-ist-1) |

### Yanıtlar

- **200**: OK
- **404**: Not found — also returned for objects owned by someone else
- **409**: not_actionable (suspended / busy)
- **422**: Validation or business rule failure (`confirm_required`, `invalid_image`, `tool_action_failed` ...)
- **501**: not_supported (not a tr-ist-1 Gyro Compute server)

### Örnekler

```bash
curl -s 'https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/ips' \
  -H "Authorization: Bearer $GYRO_TOKEN"
```
```bash
gyro server ip list 12345
```
```hcl
# kaynak gyro_server_ip: https://registry.terraform.io/providers/gyro-hosting/gyro/latest/docs/resources/server_ip
resource "gyro_server_ip" "extra" {
  count     = 2
  server_id = gyro_server.web.id
}

output "extra_ips" {
  value = gyro_server_ip.extra[*].ip
}
```
```python
import os, uuid, requests

h = {"Authorization": "Bearer " + os.environ["GYRO_TOKEN"]}
r = requests.get("https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/ips", headers=h, timeout=60)
r.raise_for_status()
print(r.json()["data"])
```
```js
const res = await fetch("https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/ips", {
  method: "GET",
  headers: {
    "Authorization": `Bearer ${process.env.GYRO_TOKEN}`,
  },
});
const { data, error } = await res.json();
if (!res.ok) throw new Error(`${error.code}: ${error.message}`);
```


## POST /cloud/servers/{id}/ips

**Ek IPv4 adresi ekle** · operationId `addServerIps` · scope `cloud_write` · OpenAPI fragment: https://www.gyrohosting.com/developers/spec/ops/addServerIps.json

**Asgari ücret:** her eklenen IP en az 6 saat ücretlendirilir (`pricing.minimum_hours`): daha erken bırakılsa da asgari süre (bırakırken) düşülür; aynı adresi yeniden almak yeni bir asgari süre başlatır. Bir sunucuya 60 dakikada en çok `adds_per_hour` (varsayılan 10) adres eklenebilir. Ek IPv4 adresleri adres başına ön ödemeli bakiyeden saatlik ücretlendirilir (varsayılan adres başına aylık 2 €, güncel fiyat `pricing` alanında); eklendiği saatten çıkarıldığı saate kadar. Sunucu başına en çok `max` (varsayılan 5). Adres sunucuya otomatik tanımlanır (birincil arayüze /32, yeniden başlatma ve yeniden kurulumda korunur); ters DNS: PUT /cloud/servers/{id}/rdns. Yalnız ön ödemeli tr-ist-1 sunucuları; askıdayken eklenemez.


### Parametreler

| Alan | in | Tür | Açıklama |
|---|---|---|---|
| `id` (zorunlu) | path | integer | Server id (tr-ist-1) |

### İstek gövdesi

| Alan | Tür | Açıklama |
|---|---|---|
| `count` | integer |  |

### Yanıtlar

- **201**: OK
- **404**: Not found — also returned for objects owned by someone else
- **409**: not_actionable (suspended / busy)
- **422**: Validation or business rule failure (`confirm_required`, `invalid_image`, `tool_action_failed` ...)
- **501**: not_supported (not a tr-ist-1 Gyro Compute server)

### Örnekler

```bash
curl -s -X POST 'https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/ips' \
  -H "Authorization: Bearer $GYRO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"count": 1}'
```
```bash
gyro server ip add 12345 --help    # tüm seçenekler
```
```hcl
# kaynak gyro_server_ip: https://registry.terraform.io/providers/gyro-hosting/gyro/latest/docs/resources/server_ip
resource "gyro_server_ip" "extra" {
  count     = 2
  server_id = gyro_server.web.id
}

output "extra_ips" {
  value = gyro_server_ip.extra[*].ip
}
```
```python
import os, uuid, requests

h = {"Authorization": "Bearer " + os.environ["GYRO_TOKEN"]}
r = requests.post("https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/ips", headers=h, json={"count": 1}, timeout=60)
r.raise_for_status()
print(r.json()["data"])
```
```js
const res = await fetch("https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/ips", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.GYRO_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({"count": 1}),
});
const { data, error } = await res.json();
if (!res.ok) throw new Error(`${error.code}: ${error.message}`);
```


## DELETE /cloud/servers/{id}/ips/{ip}

**Ek IPv4 adresini bırak** · operationId `removeServerIp` · scope `cloud_write` · OpenAPI fragment: https://www.gyrohosting.com/developers/spec/ops/removeServerIp.json

**Asgari ücret:** her eklenen IP en az 6 saat ücretlendirilir (`pricing.minimum_hours`): daha erken bırakılsa da asgari süre (bırakırken) düşülür; aynı adresi yeniden almak yeni bir asgari süre başlatır. Bir sunucuya 60 dakikada en çok `adds_per_hour` (varsayılan 10) adres eklenebilir. Adres sunucudan kaldırılır ve havuza döner (aynı adresi geri alma garantisi yok); ücret bırakınca durur (asgari süre yine uygulanır). `confirm=true` gerekir.


### Parametreler

| Alan | in | Tür | Açıklama |
|---|---|---|---|
| `id` (zorunlu) | path | integer | Server id (tr-ist-1) |
| `ip` (zorunlu) | path | string |  |
| `confirm` (zorunlu) | query | boolean |  |

### Yanıtlar

- **200**: OK
- **404**: Not found — also returned for objects owned by someone else
- **409**: not_actionable (suspended / busy)
- **422**: Validation or business rule failure (`confirm_required`, `invalid_image`, `tool_action_failed` ...)
- **501**: not_supported (not a tr-ist-1 Gyro Compute server)

### Örnekler

```bash
curl -s -X DELETE 'https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/ips/1' \
  -H "Authorization: Bearer $GYRO_TOKEN"
```
```bash
gyro server ip remove 12345
```
```hcl
# kaynak gyro_server_ip: https://registry.terraform.io/providers/gyro-hosting/gyro/latest/docs/resources/server_ip
resource "gyro_server_ip" "extra" {
  count     = 2
  server_id = gyro_server.web.id
}

output "extra_ips" {
  value = gyro_server_ip.extra[*].ip
}
```
```python
import os, uuid, requests

h = {"Authorization": "Bearer " + os.environ["GYRO_TOKEN"]}
r = requests.delete("https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/ips/1", headers=h, timeout=60)
r.raise_for_status()
print(r.json()["data"])
```
```js
const res = await fetch("https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/ips/1", {
  method: "DELETE",
  headers: {
    "Authorization": `Bearer ${process.env.GYRO_TOKEN}`,
  },
});
const { data, error } = await res.json();
if (!res.ok) throw new Error(`${error.code}: ${error.message}`);
```
