Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ feat(device): accepts feature config in toggle_features #70

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions rapyuta_io/rio_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,20 +485,22 @@ 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.

:param device_id: Device ID
:type device_id: str
:param features: A tuple of featues and their states
:type features: list<tuple>
: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')
Expand All @@ -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):
Expand Down
Loading