Skip to content

Commit

Permalink
Resolves Issue 38 (#1)
Browse files Browse the repository at this point in the history
* Resolves issue macadmins#38
* Resolves issue macadmins#24

- 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 Nov 5, 2021
1 parent a626f30 commit 5a93e46
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

### Added

- Ability to update the actual device name

### Changes

- Replaced `id_override` input parameters with `starting_after` and `limit` in get_logs()
Expand All @@ -12,6 +16,8 @@

- Closes issue #25
- Closes issue #26
- Closes issue #24
- Closes issue #38

## [v3.0.6]

Expand Down
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 5a93e46

Please sign in to comment.