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

Release v3.0.7 #63

Merged
merged 42 commits into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
3b9ecdf
Merge pull request #3 from MagerValp/master
Mar 2, 2021
0797af7
resolves the bug in issue #25 by removing id_override, replacing data…
bryanheinz Apr 7, 2021
308b0ab
required changes to resolve the bug in issue #25. migrated from updat…
bryanheinz Apr 7, 2021
8c89d8f
added Unreleased section and updated with issue #25 changes.
bryanheinz Apr 7, 2021
e434084
Fix calls that return a single item.
MagerValp May 5, 2021
cd39657
Return single items without wrapping in list.
MagerValp May 5, 2021
2d050db
Merge branch 'main' into issue-25
bryanheinz Nov 5, 2021
93c4ec6
added params= to be explicit, and marked a potential bug.
bryanheinz Nov 5, 2021
f3c929c
Merge 'return_one' into dev - Potentially code breaking changes
bryanheinz Nov 5, 2021
5b13660
updated CHANGELOG
bryanheinz Nov 5, 2021
9ff463c
merging unstable into issue-25
bryanheinz Nov 5, 2021
0270283
added docstring
bryanheinz Nov 5, 2021
a626f30
updated CHANGELOG
bryanheinz Nov 5, 2021
5a93e46
Resolves Issue 38 (#1)
bryanheinz Nov 5, 2021
ed525f8
Adding download option to profile
joncrain Jan 14, 2022
c6ec676
Update CHANGELOG.md
joncrain Jan 14, 2022
7b6ad8c
v3.0.7
joncrain Jan 14, 2022
b9caf13
adding _get_xml connection
joncrain Jan 14, 2022
55cf523
Merge pull request #41 from joncrain/issue-40
bryanheinz Jan 17, 2022
1307d77
update CHANGELOG
bryanheinz Jan 17, 2022
48b0be7
update README
bryanheinz Jan 17, 2022
c9ef08b
Merge branch 'dev' into unstable
bryanheinz Jan 17, 2022
e255030
Merge pull request #42 from bryanheinz/unstable
bryanheinz Jan 17, 2022
dfaa828
Adding include_awaiting_enrollment option #43 (#44)
joncrain May 29, 2022
427ad43
Merging dev branch (#46)
MagerValp May 30, 2022
16b3d2a
Updates gitignore and changelog (#47)
bryanheinz May 30, 2022
9212037
A little clean up, some fixen, and a few tests. (#48)
bryanheinz May 30, 2022
45b008f
Add script support
MagerValp Jun 10, 2022
feb05df
Add error handling for update_script
MagerValp Jun 10, 2022
19db08e
Fix handling of req_params for pagination
MagerValp Nov 24, 2022
992e0bc
Update CHANGELOG.md
MagerValp Nov 24, 2022
4e1c9fc
Merge pull request #49 from MagerValp/scripts
MagerValp Nov 24, 2022
8c7b1be
Fix handling of req_params for pagination
MagerValp Nov 24, 2022
74d7559
Merge branch 'fixpagination' of https://github.com/MagerValp/simpleMD…
MagerValp Nov 24, 2022
d822ce6
Update CHANGELOG.md
MagerValp Nov 24, 2022
45d2c6c
Merge pull request #59 from MagerValp/fixpagination
MagerValp Nov 24, 2022
029a7aa
Add Sample Projects
MagerValp Nov 24, 2022
2c5f33d
Merge pull request #60 from macadmins/MagerValp-readme-patch-1
MagerValp Nov 24, 2022
c771c71
Use monotonic time for rate limit and fix sleep time calc
MagerValp Nov 28, 2022
7df0c86
Merge pull request #61 from MagerValp/sleepfix
MagerValp Nov 28, 2022
d2a1a67
Update CHANGELOG.md
MagerValp Nov 28, 2022
5a4a973
Merge pull request #62 from SteveKueng/master
MagerValp Dec 1, 2022
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
*.pyc
*.egg*
.DS_Store
settings.py

.vscode
.vscode
54 changes: 45 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,42 @@
# CHANGELOG

## v3.0.6
## [Unreleased]

### Added
- setup.cfg - Python package setup file ([#29](https://github.com/macadmins/simpleMDMpy/issues/29)) - TY [@bryanheinz](https://github.com/bryanheinz)
- pyproject.toml - Python package meta setup file ([#29](https://github.com/macadmins/simpleMDMpy/issues/29)) - TY [@bryanheinz](https://github.com/bryanheinz)
- tests - Added a few basic tests and including a readme on how to setup testing - TY [@bryanheinz](https://github.com/bryanheinz)

### Changes

- Added ability to update the actual device name via SimpleMDM ([#24](https://github.com/macadmins/simpleMDMpy/issues/24), [#38](https://github.com/macadmins/simpleMDMpy/issues/38)) - TY [@bryanheinz](https://github.com/bryanheinz)
- Replaced get_logs() `id_override` input parameter with `starting_after` and `limit` ([#25](https://github.com/macadmins/simpleMDMpy/issues/25)) - TY [@bryanheinz](https://github.com/bryanheinz)
- Fixes calls that return a single item ([#26](https://github.com/macadmins/simpleMDMpy/issues/26)) - TY [@MagerValp](https://github.com/MagerValp)
- Add method to download profiles ([#40](https://github.com/macadmins/simpleMDMpy/issues/40)) - TY [@joncrain](https://github.com/joncrain)
- Adds option for get_devices to include_awaiting_enrollment ([#43](https://github.com/macadmins/simpleMDMpy/issues/43)) - TY [@joncrain](https://github.com/joncrain)
- Fixes `Devices.delete_device()` - TY [@MagerValp](https://github.com/MagerValp)
- Add Devices methods for enabling/disabling remote desktop, and profile and user listing ([@MagerValp](https://github.com/MagerValp))
- Add /devices request rate limiting to `_get_data` - TY [@MagerValp](https://github.com/MagerValp)
- Add retry on 5xx errors to GET requests to `_get_data` - TY [@MagerValp](https://github.com/MagerValp)
- Fixes `_get_data` so that it properly preserves all input parameters ([#45](https://github.com/macadmins/simpleMDMpy/issues/45)) - TY [@bryanheinz](https://github.com/bryanheinz)
- Adds help docs to Devices.get_device() - TY [@bryanheinz](https://github.com/bryanheinz)
- Add Scripts and ScriptJobs - TY [@MagerValp](https://github.com/MagerValp)
- Fix pagination - TY [@jcfrt](https://github.com/jcfrt)
- Fix rate limiting - TY [@MagerValp](https://github.com/MagerValp)

### Issues

- Closes issue #24
- Closes issue #38
- Closes issue #25
- Closes issue #26
- Closes issue #40
- Closes issue #43
- Closes issue #29
- Closes issue #45
- Closes issue #57

## [v3.0.6]

### PRs Included

Expand All @@ -12,7 +48,7 @@

- Add method to get all custom attributes for a device

## v3.0.5
## [v3.0.5]

### Issues

Expand All @@ -22,7 +58,7 @@

- CODEOWNERS

## v3.0.4
## [v3.0.4]

### Issues

Expand All @@ -39,7 +75,7 @@
- Merged with @MagerValp / simpleMDMpy @ [508540928](https://github.com/MagerValp/simpleMDMpy/commit/50854094bee2ac5306eded7c5614d76f3eab4c25)
- minor tweaks on the readme

## v3.0.3
## [v3.0.3]

### Issues

Expand All @@ -57,7 +93,7 @@
- default branch is now `main`
- remove `data` payload from Devices.delete_device

## v3.0.2
## [v3.0.2]

### Issues

Expand All @@ -73,7 +109,7 @@

- Changed paginaition to work without compounding to a `414`

## v3.0.1
## [v3.0.1]

### Issues

Expand All @@ -84,7 +120,7 @@
- Changed paginaition to work, now returns obj not response
- good catch @bryanheinz

## v3.0.0
## [v3.0.0]

- Closes #3

Expand All @@ -93,7 +129,7 @@
- removed forced encoding for `GET` responses
- added some pylint comments

## v2.1.0
## [v2.1.0]

### Issues

Expand All @@ -103,7 +139,7 @@

- fixed module names

## v2.0.0
## [v2.0.0]

### Issues

Expand Down
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ Your SimpleMDM API key will need to be set as an environmental variable `api_key

Help available via `help(SimpleMDMpy)`

## Sample Projects

* [Making SimpleMDM Complicated](https://github.com/lucasjhall/CONF-2021_MDO_YVR-Making_SimpleMDM_Complicated)
* [SimpleCLI](https://github.com/MagerValp/SimpleCLI)

## Available Modules

### Account
Expand Down Expand Up @@ -179,7 +184,6 @@ class CustomAttributes(SimpleMDMpy.SimpleMDM.Connection)
<!-- TODO: Custom Configuration -->

### Custom Configuration Profiles
<!-- TODO: DOWNLOAD PROFILE -->
```python
class CustomConfigurationProfiles(SimpleMDMpy.SimpleMDM.Connection)
| work with custom profiles
Expand All @@ -197,6 +201,9 @@ class CustomConfigurationProfiles(SimpleMDMpy.SimpleMDM.Connection)
| delete_profile(self, profile_id)
| deletes custom profile
|
| download_profile(self, profile_id)
| downloads custom profile
|
| get_profiles(self)
| returns profiles
|
Expand Down Expand Up @@ -258,9 +265,10 @@ class Devices(SimpleMDMpy.SimpleMDM.Connection)
| get_custom_attribute(self, device_id, custom_attribute_name)
| get a devices custom attributes
|
| get_device(self, device_id='all', search=None)
| get_device(self, device_id='all', search=None, include_awaiting_enrollment=False)
| Returns a device specified by id. If no ID or search is
| specified all devices will be returned
| specified all devices will be returned. Default does not include devices
| waiting for enrollment
|
| list_installed_apps(self, device_id)
| Returns a listing of the apps installed on a device.
Expand Down Expand Up @@ -288,7 +296,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 Expand Up @@ -374,7 +382,7 @@ class Logs(SimpleMDMpy.SimpleMDM.Connection)
|
| __init__(self, api_key)
|
| get_logs(self)
| get_logs(self, starting_after=None, limit=None)
| And I mean all the LOGS, before pagination
|

Expand Down
5 changes: 5 additions & 0 deletions SimpleMDMpy/CustomConfigurationProfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ def delete_profile(self, profile_id):
url = self.url + "/" + profile_id
return self._delete_data(url)

def download_profile(self, profile_id):
"""downloads custom profile"""
url = self.url + "/" + profile_id + "/download/"
return self._get_xml(url)

def assign_to_device_group(self, profile_id, device_group_id):
"""assigns custom profile to group"""
url = self.url + "/" + profile_id + "/device_groups/" + device_group_id
Expand Down
68 changes: 55 additions & 13 deletions SimpleMDMpy/Devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,32 @@ def __init__(self, api_key):
SimpleMDMpy.SimpleMDM.Connection.__init__(self, api_key)
self.url = self._url("/devices")

def get_device(self, device_id="all", search=None):
"""Returns a device specified by id. If no ID or search is
specified all devices will be returned"""
def get_device(self, device_id="all", search=None, include_awaiting_enrollment=False):
"""
Returns a device specified by id. If no ID or search is specified all
devices will be returned.

Args:
device_id (str, optional): Returns a dictionary of the specified
device id. By default, it returns a list of all devices. If a
device_id and search is specified, then search will be ignored.
search (str, optional): Returns a list of devices that match the
search criteria. Defaults to None. Ignored if device_id is set.
include_awaiting_enrollment (bool, optional): Returns a list of all
devices including devices in the "awaiting_enrollment" state.

Returns:
dict: A single dictionary object with device information.
array: An array of dictionary objects with device information.
"""
url = self.url
data = None
if search:
data = {'search': search}
elif device_id != 'all':
params = {'include_awaiting_enrollment': include_awaiting_enrollment}
# if a device ID is specified, then ignore any searches
if device_id != 'all':
url = url + "/" + str(device_id)
return self._get_data(url, data)
elif search:
params['search'] = search
return self._get_data(url, params)

def create_device(self, name, group_id):
"""Creates a new device object in SimpleMDM. The response
Expand All @@ -29,23 +45,38 @@ 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):
"""Unenroll a device and remove it from the account."""
url = self.url + "/" + str(device_id)
data = {}
return self._delete_data(url, data) #pylint: disable=too-many-function-args
return self._delete_data(url) #pylint: disable=too-many-function-args

def list_profiles(self, device_id):
"""Returns a listing of profiles that are directly assigned to the device."""
url = self.url + "/" + str(device_id) + "/profiles"
return self._get_data(url)

def list_installed_apps(self, device_id):
"""Returns a listing of the apps installed on a device."""
url = self.url + "/" + str(device_id) + "/installed_apps"
return self._get_data(url)

def list_users(self, device_id):
"""Returns a listing of the user accounts on a device."""
url = self.url + "/" + str(device_id) + "/users"
return self._get_data(url)

def push_apps_device(self, device_id):
"""You can use this method to push all assigned apps
to a device that are not already installed."""
Expand Down Expand Up @@ -102,6 +133,17 @@ def update_os(self, device_id):
data = {}
return self._post_data(url, data)

def enable_remote_desktop(self, device_id):
"""You can use this method to enable remote desktop. Supported by macOS 10.14.4+ devices only."""
url = self.url + "/" + str(device_id) + "/remote_desktop"
data = {}
return self._post_data(url, data)

def disable_remote_desktop(self, device_id):
"""You can use this method to disable remote desktop. Supported by macOS 10.14.4+ devices only."""
url = self.url + "/" + str(device_id) + "/remote_desktop"
return self._delete_data(url)

def refresh_device(self, device_id):
"""Request a refresh of the device information and app inventory.
SimpleMDM will update the inventory information when the device responds
Expand Down
25 changes: 20 additions & 5 deletions SimpleMDMpy/Logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,24 @@ class Logs(SimpleMDMpy.SimpleMDM.Connection):
def __init__(self, api_key):
SimpleMDMpy.SimpleMDM.Connection.__init__(self, api_key)
self.url = self._url("/logs")

def get_logs(self, id_override=0):
"""And I mean all the LOGS"""

def get_logs(self, starting_after=None, limit=None):
"""Returns logs, and I mean all the LOGS

Args:
starting_after (str, optional): set to the id of the log object you
want to start with. Defaults to the first object.
limit (str, optional): A limit on the number of objects that will be
returned per API call. Setting this will still return all logs.
Defaults to 100.

Returns:
array: An array of dictionary log objects.
"""
url = self.url
data = {}
return self._get_data(url, data, id_override=id_override)
params = {}
if starting_after:
params['starting_after'] = starting_after
if limit:
params['limit'] = limit
return self._get_data(url, params=params)
Loading