import os
from gcore import Gcore
client = Gcore(
api_key=os.environ.get("GCORE_API_KEY"), # This is the default and can be omitted
)
page = client.cloud.networks.routers.list(
project_id=0,
region_id=0,
)
page = page.results[0]
print(page.id){
"count": 1,
"results": [
{
"created_at": "2023-11-07T05:31:56Z",
"distributed": true,
"id": "<string>",
"interfaces": [
{
"ip_assignments": [
{
"ip_address": "<string>",
"subnet_id": "<string>"
}
],
"network_id": "<string>",
"port_id": "<string>",
"mac_address": "00:16:3e:f2:87:16"
}
],
"name": "<string>",
"project_id": 123,
"region": "<string>",
"region_id": 123,
"routes": [
{
"destination": "<string>",
"nexthop": "<string>"
}
],
"status": "<string>",
"task_id": "<string>",
"updated_at": "2023-11-07T05:31:56Z",
"creator_task_id": "<string>",
"external_gateway_info": {
"enable_snat": true,
"external_fixed_ips": [
{
"ip_address": "<string>",
"subnet_id": "<string>"
}
],
"network_id": "<string>"
}
}
]
}List all routers in the specified project and region.
import os
from gcore import Gcore
client = Gcore(
api_key=os.environ.get("GCORE_API_KEY"), # This is the default and can be omitted
)
page = client.cloud.networks.routers.list(
project_id=0,
region_id=0,
)
page = page.results[0]
print(page.id){
"count": 1,
"results": [
{
"created_at": "2023-11-07T05:31:56Z",
"distributed": true,
"id": "<string>",
"interfaces": [
{
"ip_assignments": [
{
"ip_address": "<string>",
"subnet_id": "<string>"
}
],
"network_id": "<string>",
"port_id": "<string>",
"mac_address": "00:16:3e:f2:87:16"
}
],
"name": "<string>",
"project_id": 123,
"region": "<string>",
"region_id": 123,
"routes": [
{
"destination": "<string>",
"nexthop": "<string>"
}
],
"status": "<string>",
"task_id": "<string>",
"updated_at": "2023-11-07T05:31:56Z",
"creator_task_id": "<string>",
"external_gateway_info": {
"enable_snat": true,
"external_fixed_ips": [
{
"ip_address": "<string>",
"subnet_id": "<string>"
}
],
"network_id": "<string>"
}
}
]
}API key for authentication. Make sure to include the word apikey, followed by a single space and then your token.
Example: apikey 1234$abcdef
Limit the number of returned routers
Offset value is used to exclude the first set of records from the result
List of routers
Number of objects
x >= 0Objects
Show child attributes
Datetime when the router was created
Whether the router is distributed or centralized.
Router ID
List of router interfaces.
Show child attributes
ID of the network the port is attached to
ID of virtual ethernet port object
MAC address of the virtual port
"00:16:3e:f2:87:16"
Router name
Project ID
Region name
Region ID
Status of the router.
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.
Datetime when the router was last updated
Task that created this entity
State of this router's external gateway.
Show child attributes
Is SNAT enabled.
Id of the external network.
Was this page helpful?