Skip to content

Commit bd504e0

Browse files
WIP
1 parent a7a33da commit bd504e0

File tree

2 files changed

+114
-1
lines changed

2 files changed

+114
-1
lines changed

linode_api4/objects/linode.py

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import string
22
import sys
3-
from dataclasses import dataclass
3+
from dataclasses import dataclass, field
44
from datetime import datetime
55
from enum import Enum
66
from os import urandom
@@ -653,6 +653,66 @@ class MigrationType:
653653
WARM = "warm"
654654

655655

656+
@dataclass
657+
class LinodeInterfaceDefaultRoute(JSONObject):
658+
ipv4: bool = False
659+
660+
661+
@dataclass
662+
class LinodeInterfaceVPCIPv4Address(JSONObject):
663+
address: str = ""
664+
primary: bool = False
665+
666+
667+
@dataclass
668+
class LinodeInterfaceVPCIPv4Range(JSONObject):
669+
range: str = ""
670+
671+
672+
@dataclass
673+
class LinodeInterfaceVPCIPv4(JSONObject):
674+
addresses: List[LinodeInterfaceVPCIPv4Address] = field(default_factory=list)
675+
ranges: List[LinodeInterfaceVPCIPv4Range] = field(default_factory=list)
676+
677+
678+
@dataclass
679+
class LinodeInterfaceVPC(JSONObject):
680+
vpc_id: int = 0
681+
vpc_subnet: int = 0
682+
683+
ipv4: Optional[LinodeInterfaceVPCIPv4] = None
684+
685+
686+
@dataclass
687+
class LinodeInterfacePublic(JSONObject):
688+
vpc_id: int = 0
689+
vpc_subnet: int = 0
690+
691+
ipv4: Optional[LinodeInterfaceVPCIPv4] = None
692+
693+
694+
class LinodeInterface(Base):
695+
"""
696+
A Linode's network interface.
697+
698+
API Documentation: Not yet available.
699+
"""
700+
701+
api_endpoint = "/linode/instances/{linode_id}/interfaces/{id}"
702+
derived_url_path = "interfaces"
703+
parent_id_name = "linode_id"
704+
705+
properties = {
706+
"id": Property(identifier=True),
707+
"mac_address": Property(),
708+
"created": Property(is_datetime=True),
709+
"updated": Property(is_datetime=True),
710+
"version": Property(),
711+
"default_route": Property(json_object=LinodeInterfaceDefaultRoute),
712+
"vpc": Property(json_object=LinodeInterfaceVPC),
713+
}
714+
715+
656716
class Instance(Base):
657717
"""
658718
A Linode Instance.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"created": "2025-01-01T00:01:01",
3+
"default_route": {
4+
"ipv4": true,
5+
"ipv6": true
6+
},
7+
"id": 1234,
8+
"mac_address": "22:00:AB:CD:EF:01",
9+
"public": {
10+
"ipv4": {
11+
"addresses": [
12+
{
13+
"address": "172.30.0.5O",
14+
"primary": true
15+
}
16+
],
17+
"shared": [
18+
{
19+
"address": "172.30.0.51",
20+
"linode_id": 12345
21+
}
22+
]
23+
},
24+
"ipv6": {
25+
"ranges": [
26+
{
27+
"range": "2600:3cO9:e001:59::/64",
28+
"route_target": "2600:3cO9::ff:feab:cdef"
29+
},
30+
{
31+
"range": "2600:3cO9:e001:5a::/64",
32+
"route_target": "2600:3cO9::ff:feab:cdef"
33+
}
34+
],
35+
"shared": [
36+
{
37+
"range": "2600:3cO9:e001:2a::/64",
38+
"route_target": null
39+
}
40+
],
41+
"slaac": [
42+
{
43+
"address": "2600:3cO9::ff:feab:cdef",
44+
"prefix": 64
45+
}
46+
]
47+
}
48+
},
49+
"updated": "2025-01-01T00:01:01",
50+
"version": 1,
51+
"vlan": null,
52+
"vpc": null
53+
}

0 commit comments

Comments
 (0)