Skip to main content

Highly opinionated SimpleMDM Python library

Project description

SimpleMDM SDK Python

Python library for interacting with SimpleMDM's REST API. Pseudo-spiritual successor to SteveKueng/MacAdmin's SimpleMDMpy, with a focus on type hinting through Pydantic models.

Note: Library is highly opinionated and may not be suitable for all use cases. Use at your own discretion.

Notable differences from SimpleMDMpy

  • Implicit conversion of parameters to strings when generating URLs.
    • ex. Passing device IDs as integers will no longer raises an error.
  • Single public class for all API endpoints
    • No need to pass API keys to individual endpoint classes.
  • Feature parity with SimpleMDM's API.
    • Currently validated against version 1.51.
  • Function names matching SimpleMDM's API documentation.
    • ex. SimpleMDM.Accounts.show() instead of SimpleMDM.Accounts.get_account().
    • Easier cross referencing of https://api.simplemdm.com.
  • Pydantic models for API responses.
    • Provides type hints and validation for API responses.
    • Configure strictness of validation with os.environ["SimpleMDMSDKModelExtra"] = "xxx" before importing the library.
    • Defaults to allow, see Pydantic's ConfigDict.extra documentation for more information.
  • Automatic ratelimit handling for all REST methods.
  • Enums for static properties in function parameters.
    • ex. SimpleMDM.AssignmentGroups.MunkiInstallType instead of strings.

Installation

python3 -m pip install simplemdm-sdk

Usage

from simplemdm_sdk import SimpleMDM

api_key = "your_api_key"
simplemdm = SimpleMDM(api_key)

# List all device names
for device in simplemdm.devices.list_all().data:
    print(device.attributes.name)
  • Recommend right clicking data and selecting "Go to definition" in your IDE to see the Pydantic model for the response.
class DeviceData(SimpleMDMSDKModel):
    type:          str
    id:            int
    attributes:    Optional[DeviceAttributes]    = None
    relationships: Optional[DeviceRelationships] = None


class DevicesListAllResponse(SimpleMDMSDKModel):
    data: list[DeviceData]

Supported functions

For a complete list of function descriptions, please refer to the SimpleMDM API documentation.

from simplemdm_sdk import SimpleMDM

simplemdm_object = SimpleMDM(api_key)

account

simplemdm_obj.account.show()
simplemdm_obj.account.update()

apps

simplemdm_obj.apps.create()
simplemdm_obj.apps.delete()
simplemdm_obj.apps.delete_munki_pkginfo()
simplemdm_obj.apps.list_all()
simplemdm_obj.apps.list_installs()
simplemdm_obj.apps.retrieve_one()
simplemdm_obj.apps.update()
simplemdm_obj.apps.update_munki_pkginfo()

assignment_groups

simplemdm_obj.assignment_groups.assign_app()
simplemdm_obj.assignment_groups.assign_device()
simplemdm_obj.assignment_groups.assign_device_group()
simplemdm_obj.assignment_groups.assign_profile()
simplemdm_obj.assignment_groups.clone()
simplemdm_obj.assignment_groups.create()
simplemdm_obj.assignment_groups.delete()
simplemdm_obj.assignment_groups.list_all()
simplemdm_obj.assignment_groups.push_apps()
simplemdm_obj.assignment_groups.retrieve_one()
simplemdm_obj.assignment_groups.sync_profiles()
simplemdm_obj.assignment_groups.unassign_app()
simplemdm_obj.assignment_groups.unassign_device()
simplemdm_obj.assignment_groups.unassign_device_group()
simplemdm_obj.assignment_groups.unassign_profile()
simplemdm_obj.assignment_groups.update()
simplemdm_obj.assignment_groups.update_apps()

custom_attributes

simplemdm_obj.custom_attributes.create()
simplemdm_obj.custom_attributes.delete()
simplemdm_obj.custom_attributes.get_values_for_device()
simplemdm_obj.custom_attributes.get_values_for_group()
simplemdm_obj.custom_attributes.list_all()
simplemdm_obj.custom_attributes.retrieve_one()
simplemdm_obj.custom_attributes.set_custom_attribute_value_for_multiple_devices()
simplemdm_obj.custom_attributes.set_multiple_values_for_a_device()
simplemdm_obj.custom_attributes.set_value_for_device()
simplemdm_obj.custom_attributes.set_value_for_group()
simplemdm_obj.custom_attributes.update()

custom_configuration_profiles

simplemdm_obj.custom_configuration_profiles.assign_to_device()
simplemdm_obj.custom_configuration_profiles.assign_to_device_group()
simplemdm_obj.custom_configuration_profiles.create()
simplemdm_obj.custom_configuration_profiles.delete()
simplemdm_obj.custom_configuration_profiles.download()
simplemdm_obj.custom_configuration_profiles.list_all()
simplemdm_obj.custom_configuration_profiles.unassign_from_device()
simplemdm_obj.custom_configuration_profiles.unassign_from_device_group()
simplemdm_obj.custom_configuration_profiles.update()

dep_servers

simplemdm_obj.dep_servers.list_all()
simplemdm_obj.dep_servers.list_dep_devices()
simplemdm_obj.dep_servers.retrieve_one()
simplemdm_obj.dep_servers.retrieve_one_dep_device()
simplemdm_obj.dep_servers.sync_with_apple()

device_groups

simplemdm_obj.device_groups.assign_device()
simplemdm_obj.device_groups.clone()
simplemdm_obj.device_groups.list_all()
simplemdm_obj.device_groups.retrieve_one()

devices

simplemdm_obj.devices.clear_firmware_password()
simplemdm_obj.devices.clear_passcode()
simplemdm_obj.devices.clear_recovery_lock_password()
simplemdm_obj.devices.clear_restrictions_password()
simplemdm_obj.devices.create()
simplemdm_obj.devices.delete()
simplemdm_obj.devices.delete_user()
simplemdm_obj.devices.disable_bluetooth()
simplemdm_obj.devices.disable_remote_desktop()
simplemdm_obj.devices.enable_bluetooth()
simplemdm_obj.devices.enable_remote_desktop()
simplemdm_obj.devices.list_all()
simplemdm_obj.devices.list_installed_apps()
simplemdm_obj.devices.list_profiles()
simplemdm_obj.devices.list_users()
simplemdm_obj.devices.lock()
simplemdm_obj.devices.push_assigned_apps()
simplemdm_obj.devices.refresh()
simplemdm_obj.devices.restart()
simplemdm_obj.devices.retrieve_one()
simplemdm_obj.devices.rotate_admin_password()
simplemdm_obj.devices.rotate_filevault_recovery_key()
simplemdm_obj.devices.rotate_firmware_password()
simplemdm_obj.devices.rotate_recovery_lock_password()
simplemdm_obj.devices.set_admin_password()
simplemdm_obj.devices.set_time_zone()
simplemdm_obj.devices.shut_down()
simplemdm_obj.devices.unenroll()
simplemdm_obj.devices.update()
simplemdm_obj.devices.update_os()
simplemdm_obj.devices.wipe()

enrollments

simplemdm_obj.enrollments.delete()
simplemdm_obj.enrollments.list_all()
simplemdm_obj.enrollments.retrieve_one()
simplemdm_obj.enrollments.send_invitation()

installed_apps

simplemdm_obj.installed_apps.install_update()
simplemdm_obj.installed_apps.request_management_of_app()
simplemdm_obj.installed_apps.retrieve_one()
simplemdm_obj.installed_apps.uninstall()

logs

simplemdm_obj.logs.list_all()
simplemdm_obj.logs.retrieve_one()

lost_mode

simplemdm_obj.lost_mode.disable()
simplemdm_obj.lost_mode.enable()
simplemdm_obj.lost_mode.play_a_sound()
simplemdm_obj.lost_mode.update_location()

managed_app_configs

simplemdm_obj.managed_app_configs.create()
simplemdm_obj.managed_app_configs.delete()
simplemdm_obj.managed_app_configs.get()
simplemdm_obj.managed_app_configs.push_updates()

profiles

simplemdm_obj.profiles.assign_to_device()
simplemdm_obj.profiles.assign_to_device_group()
simplemdm_obj.profiles.list_all()
simplemdm_obj.profiles.retrieve_one()
simplemdm_obj.profiles.unassign_from_device()
simplemdm_obj.profiles.unassign_from_device_group()

push_certificate

simplemdm_obj.push_certificate.get_signed_csr()
simplemdm_obj.push_certificate.show()
simplemdm_obj.push_certificate.update()

script_jobs

simplemdm_obj.script_jobs.cancel_job()
simplemdm_obj.script_jobs.create()
simplemdm_obj.script_jobs.list_all()
simplemdm_obj.script_jobs.retrieve_one()

scripts

simplemdm_obj.scripts.create()
simplemdm_obj.scripts.delete()
simplemdm_obj.scripts.list_all()
simplemdm_obj.scripts.retrieve_one()
simplemdm_obj.scripts.update()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simplemdm_sdk-0.1.0.tar.gz (20.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simplemdm_sdk-0.1.0-py3-none-any.whl (33.5 kB view details)

Uploaded Python 3

File details

Details for the file simplemdm_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: simplemdm_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for simplemdm_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6cd04e8e7369d78c6b502282a3dbf68ee4706c08e4cc42bc2a009349be5d84e3
MD5 d9c3260100c8d2b0eeea477ad5823921
BLAKE2b-256 abd05b1064187254be5388e906222e59288859883f4536ee79821b63d3811b0b

See more details on using hashes here.

File details

Details for the file simplemdm_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: simplemdm_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 33.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for simplemdm_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d698316ed69c5154be65d9bd99d4d0c161b865740a4f85b7550275eeed61bc74
MD5 3d6b384f2e89f8c48650b87e2f2a33f1
BLAKE2b-256 6d1edfe78636fb0648c09fc4d3ff1d9503ccc74b2aeabccf2033cd56c4480695

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page