Skip to content

Commit a9fec27

Browse files
progress
1 parent bd504e0 commit a9fec27

File tree

3 files changed

+119
-61
lines changed

3 files changed

+119
-61
lines changed

linode_api4/objects/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from .region import Region
77
from .image import Image
88
from .linode import *
9+
from .linode_interfaces import *
910
from .volume import *
1011
from .domain import *
1112
from .account import *

linode_api4/objects/linode.py

+1-61
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import string
22
import sys
3-
from dataclasses import dataclass, field
3+
from dataclasses import dataclass
44
from datetime import datetime
55
from enum import Enum
66
from os import urandom
@@ -653,66 +653,6 @@ 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-
716656
class Instance(Base):
717657
"""
718658
A Linode Instance.
+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
from dataclasses import dataclass, field
2+
from typing import List, Optional
3+
4+
from linode_api4.objects.base import Base, Property
5+
from linode_api4.objects.serializable import JSONObject
6+
7+
8+
@dataclass
9+
class LinodeInterfaceDefaultRoute(JSONObject):
10+
ipv4: bool = False
11+
ipv6: bool = False
12+
13+
14+
@dataclass
15+
class LinodeInterfaceVPCIPv4Address(JSONObject):
16+
address: str = ""
17+
primary: bool = False
18+
19+
20+
@dataclass
21+
class LinodeInterfaceVPCIPv4Range(JSONObject):
22+
range: str = ""
23+
24+
25+
@dataclass
26+
class LinodeInterfaceVPCIPv4(JSONObject):
27+
addresses: List[LinodeInterfaceVPCIPv4Address] = field(default_factory=list)
28+
ranges: List[LinodeInterfaceVPCIPv4Range] = field(default_factory=list)
29+
30+
31+
@dataclass
32+
class LinodeInterfaceVPC(JSONObject):
33+
vpc_id: int = 0
34+
vpc_subnet: int = 0
35+
36+
ipv4: Optional[LinodeInterfaceVPCIPv4] = None
37+
38+
39+
@dataclass
40+
class LinodeInterfacePublicIPv4Address(JSONObject):
41+
address: str = ""
42+
primary: bool = False
43+
44+
45+
@dataclass
46+
class LinodeInterfacePublicIPv4Shared(JSONObject):
47+
address: str = ""
48+
linode_id: int = 0
49+
50+
51+
@dataclass
52+
class LinodeInterfacePublicIPv4(JSONObject):
53+
addresses: List[LinodeInterfacePublicIPv4Address] = field(
54+
default_factory=list
55+
)
56+
shared: List[LinodeInterfacePublicIPv4Shared] = field(default_factory=list)
57+
58+
59+
@dataclass
60+
class LinodeInterfacePublicIPv6SLAAC(JSONObject):
61+
address: str = ""
62+
prefix: int = 0
63+
64+
65+
@dataclass
66+
class LinodeInterfacePublicIPv6Shared(JSONObject):
67+
range: str = ""
68+
route_target: Optional[str] = ""
69+
70+
71+
@dataclass
72+
class LinodeInterfacePublicIPv6Range(JSONObject):
73+
range: str = ""
74+
route_target: Optional[str] = ""
75+
76+
77+
@dataclass
78+
class LinodeInterfacePublicIPv6(JSONObject):
79+
slaac: List[LinodeInterfacePublicIPv6SLAAC] = field(default_factory=list)
80+
shared: List[LinodeInterfacePublicIPv6Shared] = field(default_factory=list)
81+
ranges: List[LinodeInterfacePublicIPv6Range] = field(default_factory=list)
82+
83+
84+
@dataclass
85+
class LinodeInterfacePublic(JSONObject):
86+
ipv4: Optional[LinodeInterfacePublicIPv4] = None
87+
ipv6: Optional[LinodeInterfacePublicIPv6] = None
88+
89+
90+
@dataclass
91+
class LinodeInterfaceVLAN(JSONObject):
92+
vlan_label: str = ""
93+
ipam_address: Optional[str] = ""
94+
95+
96+
class LinodeInterface(Base):
97+
"""
98+
A Linode's network interface.
99+
100+
API Documentation: Not yet available.
101+
"""
102+
103+
api_endpoint = "/linode/instances/{linode_id}/interfaces/{id}"
104+
derived_url_path = "interfaces"
105+
parent_id_name = "linode_id"
106+
107+
properties = {
108+
"id": Property(identifier=True),
109+
"mac_address": Property(),
110+
"created": Property(is_datetime=True),
111+
"updated": Property(is_datetime=True),
112+
"version": Property(),
113+
"default_route": Property(json_object=LinodeInterfaceDefaultRoute),
114+
"public": Property(json_object=LinodeInterfacePublic),
115+
"vlan": Property(json_object=LinodeInterfaceVLAN),
116+
"vpc": Property(json_object=LinodeInterfaceVPC),
117+
}

0 commit comments

Comments
 (0)