Skip to content

Commit

Permalink
Resolves issue macadmins#38
Browse files Browse the repository at this point in the history
- Updated update_device input to accept both name and device_name input (breaking change)
- data is now updated with the inputs
- Added validation that data has input
- Updated the README with update_device's new inputs
  • Loading branch information
bryanheinz committed Sep 28, 2021
1 parent 6539f94 commit 9fb7345
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ class Devices(SimpleMDMpy.SimpleMDM.Connection)
| shutdown_device(self, device_id)
| This command sends a shutdown command to the device.
|
| update_device(self, name, device_id)
| update_device(self, device_id, name=None, device_name=None)
| Update the SimpleMDM name or device name of a device object.
|
| update_os(self, device_id)
Expand Down
12 changes: 9 additions & 3 deletions SimpleMDMpy/Devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,16 @@ def create_device(self, name, group_id):
data = {'name': name, 'group_id': group_id}
return self._post_data(self.url, data)

def update_device(self, name, device_id):
"""Update the SimpleMDM name or device name of a device object."""
def update_device(self, device_id, name=None, device_name=None):
"""Update the SimpleMDM name and/or device name of a device object."""
url = self.url + "/" + str(device_id)
data = {'name': name}
data = {}
if name is not None:
data.update({'name':name})
if device_name is not None:
data.update({'device_name':device_name})
if data == {}:
raise Exception(f"Missing name and/or device_name variables.")
return self._patch_data(url, data)

def delete_device(self, device_id):
Expand Down

0 comments on commit 9fb7345

Please sign in to comment.