Skip to content

Commit 2205dfc

Browse files
Add IP interface(...) method
1 parent 7994949 commit 2205dfc

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

linode_api4/objects/networking.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,33 @@ def linode(self):
9898

9999
if not hasattr(self, "_linode"):
100100
self._set("_linode", Instance(self._client, self.linode_id))
101+
101102
return self._linode
102103

103-
# TODO (Enhanced Interfaces): Add `interface` property method
104+
@property
105+
def interface(self) -> Optional["LinodeInterface"]:
106+
"""
107+
Returns the Linode Interface associated with this IP address.
108+
109+
NOTE: This function will only work with Linode-level interfaces.
110+
111+
:returns: The Linode Interface associated with this IP address.
112+
:rtype: LinodeInterface
113+
"""
114+
115+
from .linode_interfaces import LinodeInterface # pylint: disable-all
116+
117+
if self.interface_id in (None, 0):
118+
self._set("_interface", None)
119+
elif not hasattr(self, "_interface"):
120+
self._set(
121+
"_interface",
122+
LinodeInterface(
123+
self._client, self.linode_id, self.interface_id
124+
),
125+
)
126+
127+
return self._interface
104128

105129
def to(self, linode):
106130
"""

0 commit comments

Comments
 (0)