From c16e246ac0b7bb447b80ad98f9ac5f1e63c35dbe Mon Sep 17 00:00:00 2001 From: Pallab Pain Date: Fri, 17 Nov 2023 22:59:44 +0530 Subject: [PATCH] feat(device): accepts feature config in toggle_features The toggle_features method now accepts additional feature config that allows us to invoke the patch device daemons API with daemon config. Usage: >>> from rapyuta_io import Client >>> client = Client(auth_token='auth_token', project='project_guid') >>> client.toggle_features('device-id', [('vpn', True), ('tracing', False)], config={'vpn': {'advertise_routes': True}}) --- rapyuta_io/rio_client.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/rapyuta_io/rio_client.py b/rapyuta_io/rio_client.py index 89fa6e5f..96d48ef9 100644 --- a/rapyuta_io/rio_client.py +++ b/rapyuta_io/rio_client.py @@ -485,7 +485,7 @@ def delete_device(self, device_id): raise InvalidParameterException('device_id needs to be a non empty string') return self._dmClient.delete_device(device_id) - def toggle_features(self, device_id, features): + def toggle_features(self, device_id, features, config=None): """ Patch a device on rapyuta.io platform. @@ -493,12 +493,14 @@ def toggle_features(self, device_id, features): :type device_id: str :param features: A tuple of featues and their states :type features: list + :param config: A dict of additional feature configuration + :type config: dict Following example demonstrates how to toggle features a device. >>> from rapyuta_io import Client >>> client = Client(auth_token='auth_token', project='project_guid') - >>> client.toggle_features('device-id', [('vpn', True), ('tracing', False)]) + >>> client.toggle_features('device-id', [('vpn', True), ('tracing', False)], config={'vpn': {'advertise_routes': True}}) """ if not device_id or not isinstance(device_id, six.string_types): raise InvalidParameterException('device_id needs to be a non empty string') @@ -510,6 +512,9 @@ def toggle_features(self, device_id, features): feature, state = entry data[feature] = state + if config is not None: + data['config'] = config + return self._dmClient.patch_daemons(device_id, data) def create_package_from_manifest(self, manifest_filepath, retry_limit=0):