Skip to content

Commit 06acb2f

Browse files
progress
1 parent 8f164d1 commit 06acb2f

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

linode_api4/objects/linode.py

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from typing import Any, Dict, List, Optional, Union
99
from urllib import parse
1010

11-
from linode_api4 import LinodeInterfacesSettings
1211
from linode_api4.common import load_and_validate_keys
1312
from linode_api4.errors import UnexpectedResponseError
1413
from linode_api4.objects.base import (
@@ -20,6 +19,14 @@
2019
from linode_api4.objects.dbase import DerivedBase
2120
from linode_api4.objects.filtering import FilterableAttribute
2221
from linode_api4.objects.image import Image
22+
from linode_api4.objects.linode_interfaces import (
23+
LinodeInterface,
24+
LinodeInterfaceDefaultRouteOptions,
25+
LinodeInterfacePublicOptions,
26+
LinodeInterfacesSettings,
27+
LinodeInterfaceVLANOptions,
28+
LinodeInterfaceVPCOptions,
29+
)
2330
from linode_api4.objects.networking import (
2431
Firewall,
2532
IPAddress,
@@ -1855,6 +1862,38 @@ def stats_for(self, dt):
18551862
model=self,
18561863
)
18571864

1865+
def interface_create(
1866+
self,
1867+
firewall: Union[Firewall, int] = None,
1868+
default_route: Optional[LinodeInterfaceDefaultRouteOptions] = None,
1869+
public: Optional[LinodeInterfacePublicOptions] = None,
1870+
vlan: Optional[LinodeInterfaceVLANOptions] = None,
1871+
vpc: Optional[LinodeInterfaceVPCOptions] = None,
1872+
**kwargs,
1873+
):
1874+
params = {
1875+
"firewall_id": firewall,
1876+
"default_route": default_route,
1877+
"public": public,
1878+
"vlan": vlan,
1879+
"vpc": vpc,
1880+
}
1881+
1882+
params.update(kwargs)
1883+
1884+
result = self._client.post(
1885+
"{}/interfaces".format(Instance.api_endpoint),
1886+
model=self,
1887+
data=drop_null_keys(_flatten_request_body_recursive(params)),
1888+
)
1889+
1890+
if not "id" in result:
1891+
raise UnexpectedResponseError(
1892+
"Unexpected response creating config!", json=result
1893+
)
1894+
1895+
return LinodeInterface(self._client, result["id"], self.id, json=result)
1896+
18581897
def upgrade_interfaces(
18591898
self,
18601899
config: Union[Config, int],

linode_api4/objects/linode_interfaces.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from typing import List, Optional
33

44
from linode_api4.objects.base import Base, Property
5+
from linode_api4.objects.dbase import DerivedBase
56
from linode_api4.objects.networking import Firewall
67
from linode_api4.objects.serializable import JSONObject
78

@@ -186,7 +187,7 @@ class LinodeInterfaceVLAN(JSONObject):
186187
ipam_address: Optional[str] = None
187188

188189

189-
class LinodeInterface(Base):
190+
class LinodeInterface(DerivedBase):
190191
"""
191192
A Linode's network interface.
192193

0 commit comments

Comments
 (0)