|
8 | 8 | from typing import Any, Dict, List, Optional, Union |
9 | 9 | from urllib import parse |
10 | 10 |
|
11 | | -from linode_api4 import LinodeInterfacesSettings |
12 | 11 | from linode_api4.common import load_and_validate_keys |
13 | 12 | from linode_api4.errors import UnexpectedResponseError |
14 | 13 | from linode_api4.objects.base import ( |
|
20 | 19 | from linode_api4.objects.dbase import DerivedBase |
21 | 20 | from linode_api4.objects.filtering import FilterableAttribute |
22 | 21 | 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 | +) |
23 | 30 | from linode_api4.objects.networking import ( |
24 | 31 | Firewall, |
25 | 32 | IPAddress, |
@@ -1855,6 +1862,38 @@ def stats_for(self, dt): |
1855 | 1862 | model=self, |
1856 | 1863 | ) |
1857 | 1864 |
|
| 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 | + |
1858 | 1897 | def upgrade_interfaces( |
1859 | 1898 | self, |
1860 | 1899 | config: Union[Config, int], |
|
0 commit comments