Skip to main content
PATCH
/
cloud
/
v1
/
subnets
/
{project_id}
/
{region_id}
/
{subnet_id}
Python
from gcore import Gcore

client = Gcore(
    api_key="My API Key",
)
subnet = client.cloud.networks.subnets.update(
    subnet_id="b39792c3-3160-4356-912e-ba396c95cdcf",
    project_id=1,
    region_id=1,
)
print(subnet.cidr)
{
  "available_ips": 250,
  "cidr": "192.168.13.0/24",
  "created_at": "2019-06-13T13:58:12+0000",
  "creator_task_id": "5cc890da-d031-4a23-ac31-625edfa22812",
  "dns_nameservers": [
    "8.8.8.8",
    "8.8.4.4"
  ],
  "enable_dhcp": true,
  "gateway_ip": "192.168.13.1",
  "has_router": false,
  "host_routes": [],
  "id": "b39792c3-3160-4356-912e-ba396c95cdcf",
  "ip_version": 4,
  "name": "subnet_3",
  "network_id": "b30d0de7-bca2-4c83-9c57-9e645bd2cc92",
  "project_id": 1337,
  "region": "Luxembourg 1",
  "region_id": 7,
  "tags": [
    {
      "key": "my-tag",
      "read_only": false,
      "value": "my-tag-value"
    }
  ],
  "task_id": null,
  "total_ips": 253,
  "updated_at": "2019-06-13T13:58:12+0000"
}

Authorizations

Authorization
string
header
required

API key for authentication. Make sure to include the word apikey, followed by a single space and then your token. Example: apikey 1234$abcdef

Path Parameters

project_id
integer
required

Project ID

Examples:

1

region_id
integer
required

Region ID

Examples:

1

subnet_id
string<uuid4>
required

Subnet ID

Examples:

"b39792c3-3160-4356-912e-ba396c95cdcf"

Body

application/json
dns_nameservers
string<ipvanyaddress>[] | null

List IP addresses of DNS servers to advertise via DHCP.

Examples:
["8.8.4.4", "1.1.1.1"]
enable_dhcp
boolean | null

True if DHCP should be enabled

Examples:

true

gateway_ip
string<ipvanyaddress> | null

Default GW IPv4 address to advertise in DHCP routes in this subnet. Omit this field to let the cloud backend allocate it automatically. Set to null if no gateway must be advertised by this subnet's DHCP (useful when attaching instances to multiple subnets in order to prevent default route conflicts).

Examples:

"192.168.10.1"

host_routes
RouteInSerializer · object[] | null

List of custom static routes to advertise via DHCP.

Examples:
[
{
"destination": "10.0.3.0/24",
"nexthop": "10.0.0.13"
}
]
name
string | null

Name

Examples:

"some_name"

tags
object | null

Update key-value tags using JSON Merge Patch semantics (RFC 7386). Provide key-value pairs to add or update tags. Set tag values to null to remove tags. Unspecified tags remain unchanged. Read-only tags are always preserved and cannot be modified.

Examples:

* Add/update tags: {'tags': {'environment': 'production', 'team': 'backend'}} adds new tags or updates existing ones.

* Delete tags: {'tags': {'old_tag': null}} removes specific tags.

* Remove all tags: {'tags': null} removes all user-managed tags (read-only tags are preserved).

* Partial update: {'tags': {'environment': 'staging'}} only updates specified tags.

* Mixed operations: {'tags': {'environment': 'production', 'cost_center': 'engineering', 'deprecated_tag': null}} adds/updates 'environment' and 'cost_center' while removing 'deprecated_tag', preserving other existing tags.

* Replace all: first delete existing tags with null values, then add new ones in the same request.

Examples:
{
"my-tag": "my-tag-value",
"my-tag-to-remove": null
}

Response

200 - application/json

OK

cidr
string<ipvanynetwork>
required

CIDR

Examples:

"192.168.13.0/24"

created_at
string<date-time>
required

Datetime when the subnet was created

Examples:

"2019-06-13T13:58:12+0000"

enable_dhcp
boolean
required

True if DHCP should be enabled

Examples:

true

ip_version
enum<integer>
required

IP version

Available options:
4,
6
name
string
required

Subnet name

Examples:

"subnet_3"

network_id
string<uuid4>
required

Network ID

Examples:

"b30d0de7-bca2-4c83-9c57-9e645bd2cc92"

project_id
integer
required

Project ID

Examples:

1337

region
string
required

Region name

Examples:

"Luxembourg 1"

region_id
integer
required

Region ID

Examples:

7

tags
TagSerializer · object[]
required

List of key-value tags associated with the resource. A tag is a key-value pair that can be associated with a resource, enabling efficient filtering and grouping for better organization and management. Some tags are read-only and cannot be modified by the user. Tags are also integrated with cost reports, allowing cost data to be filtered based on tag keys or values.

Examples:
[
{
"key": "my-tag",
"read_only": false,
"value": "my-tag-value"
}
]
updated_at
string<date-time>
required

Datetime when the subnet was last updated

Examples:

"2019-06-13T13:58:12+0000"

available_ips
integer | null

Number of available ips in subnet

Examples:

250

creator_task_id
string<uuid4> | null

Task that created this entity

Examples:

"5cc890da-d031-4a23-ac31-625edfa22812"

dns_nameservers
string<ipvanyaddress>[] | null

List IP addresses of a DNS resolver reachable from the network

Examples:
["8.8.8.8", "8.8.4.4"]
gateway_ip
string<ipvanyaddress> | null

Default GW IPv4 address, advertised in DHCP routes of this subnet. If null, no gateway is advertised by this subnet.

Examples:

"192.168.13.1"

has_router
boolean
default:false
deprecated

Deprecated. Always returns false.

Examples:

false

host_routes
RouteOutSerializer · object[] | null

List of custom static routes to advertise via DHCP.

Examples:
[]
id
string<uuid4> | null

Subnet id.

Examples:

"b39792c3-3160-4356-912e-ba396c95cdcf"

task_id
string<uuid4> | null

The UUID of the active task that currently holds a lock on the resource. This lock prevents concurrent modifications to ensure consistency. If null, the resource is not locked.

Examples:

null

total_ips
integer | null

Total number of ips in subnet

Examples:

253

I