Skip to content

Commit f22b5c3

Browse files
committed
Added add_connection_profile to networkmanager settings
Adds the connection using the profile object.
1 parent 955190d commit f22b5c3

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

sdbus_async/networkmanager/interfaces_other.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,36 @@ def connection_removed(self) -> str:
779779
"""Signal when connection was removed with the path"""
780780
raise NotImplementedError
781781

782+
async def add_connection_profile(
783+
self,
784+
profile: ConnectionProfile,
785+
save_to_disk: bool = False,
786+
) -> Tuple[str, None]:
787+
"""Add new connection using the profile object.
788+
789+
:param ConnectionProfile profile: Connection profile to update
790+
with.
791+
792+
:param bool save_to_disk: Make changes permanent by saving
793+
updated values to disk.
794+
795+
By default changes are temporary. (saved only to RAM)
796+
797+
:return: Object path of new connection and None
798+
:rtype: Tuple[str, None]
799+
"""
800+
flags = 0
801+
802+
if save_to_disk:
803+
flags |= 0x1
804+
else:
805+
flags |= 0x2
806+
807+
return (
808+
(await self.add_connection2(profile.to_dbus(), flags, {}))[0],
809+
None,
810+
)
811+
782812

783813
class NetworkManagerVPNPluginInterfaceAsync(
784814
DbusInterfaceCommonAsync,

sdbus_block/networkmanager/interfaces_other.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,36 @@ def can_modify(self) -> bool:
736736
"""If true adding and modifying connections is supported"""
737737
raise NotImplementedError
738738

739+
def add_connection_profile(
740+
self,
741+
profile: ConnectionProfile,
742+
save_to_disk: bool = False,
743+
) -> Tuple[str, None]:
744+
"""Add new connection using the profile object.
745+
746+
:param ConnectionProfile profile: Connection profile to update
747+
with.
748+
749+
:param bool save_to_disk: Make changes permanent by saving
750+
updated values to disk.
751+
752+
By default changes are temporary. (saved only to RAM)
753+
754+
:return: Object path of new connection and None
755+
:rtype: Tuple[str, None]
756+
"""
757+
flags = 0
758+
759+
if save_to_disk:
760+
flags |= 0x1
761+
else:
762+
flags |= 0x2
763+
764+
return (
765+
(self.add_connection2(profile.to_dbus(), flags, {}))[0],
766+
None,
767+
)
768+
739769

740770
class NetworkManagerVPNPluginInterface(
741771
DbusInterfaceCommon,

0 commit comments

Comments
 (0)