Skip to content

Commit cb3839a

Browse files
committed
Added get_applied_connection_profile to device interface
Retrieves applied connection as a profile object.
1 parent 4bc4bff commit cb3839a

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

sdbus_async/networkmanager/interfaces_devices.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
dbus_signal_async,
2929
)
3030

31+
from .settings import ConnectionProfile
32+
3133

3234
class NetworkManagerDeviceBluetoothInterfaceAsync(
3335
DbusInterfaceCommonAsync,
@@ -1020,6 +1022,25 @@ def state_changed(self) -> Tuple[int, int, int]:
10201022
"""
10211023
raise NotImplementedError
10221024

1025+
async def get_applied_connection_profile(
1026+
self
1027+
) -> Tuple[ConnectionProfile, int]:
1028+
"""Get the currently applied connection on the device.
1029+
1030+
.. note::
1031+
1032+
This method cannot fetch secrets. Use
1033+
:py:meth:`NetworkManagerSettingsConnectionInterfaceAsync.get_profile`
1034+
to acquire profile with secrets.
1035+
1036+
:returns: Tuple of profile and version id.
1037+
:rtype: Tuple[ConnectionProfile, int]
1038+
"""
1039+
1040+
connection_vardict, version_id = await self.get_applied_connection(0)
1041+
1042+
return ConnectionProfile.from_dbus(connection_vardict), version_id
1043+
10231044

10241045
class NetworkManagerPPPInterfaceAsync(
10251046
DbusInterfaceCommonAsync,

sdbus_block/networkmanager/interfaces_devices.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
from sdbus import DbusInterfaceCommon, dbus_method, dbus_property
2525

26+
from .settings import ConnectionProfile
27+
2628

2729
class NetworkManagerDeviceBluetoothInterface(
2830
DbusInterfaceCommon,
@@ -985,6 +987,25 @@ def hw_address(self) -> str:
985987
"""Hardware address"""
986988
raise NotImplementedError
987989

990+
def get_applied_connection_profile(
991+
self
992+
) -> Tuple[ConnectionProfile, int]:
993+
"""Get the currently applied connection on the device.
994+
995+
.. note::
996+
997+
This method cannot fetch secrets. Use
998+
:py:meth:`NetworkManagerSettingsConnectionInterfaceAsync.get_profile`
999+
to acquire profile with secrets.
1000+
1001+
:returns: Tuple of profile and version id.
1002+
:rtype: Tuple[ConnectionProfile, int]
1003+
"""
1004+
1005+
connection_vardict, version_id = self.get_applied_connection(0)
1006+
1007+
return ConnectionProfile.from_dbus(connection_vardict), version_id
1008+
9881009

9891010
class NetworkManagerPPPInterface(
9901011
DbusInterfaceCommon,

0 commit comments

Comments
 (0)