Welcome to jamf Pro API’s documentation!¶
Contents:
jamf Pro API¶
Provide API calls for jamf Pro (formerly JSS)
- Free software: MIT license
- Documentation: https://jamf-pro-api.readthedocs.io.
Features¶
- TODO
Credits¶
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
Installation¶
Stable release¶
To install jamf Pro API, run this command in your terminal:
$ pip install jssapi
This is the preferred method to install jamf Pro API, as it will always install the most recent stable release.
If you don’t have pip installed, this Python installation guide can guide you through the process.
From sources¶
The sources for jamf Pro API can be downloaded from the Github repo.
You can either clone the public repository:
$ git clone git://github.com/sreyemnayr/jamf_pro_api
Or download the tarball:
$ curl -OL https://github.com/sreyemnayr/jamf_pro_api/tarball/master
Once you have a copy of the source, you can install it with:
$ python setup.py install
Usage¶
To use jamf Pro API in a project:
from jssapi import JSSApi
"""Initialize the api with your credentials"""
api = JSSApi(url=JSS_URL, user=JSS_USER, pwd=JSS_PASS, dbhost=JSS_DB_HOST,
db=JSS_DB_DB, dbuser=JSS_DB_USER, dbpasswd=JSS_DB_PASS)
"""Get all mobile devices and print their names"""
devices = api.get(method='mobiledevices')
for device in devices:
print(device['name'])
"""Get device with ID #1 and print its name"""
device = api.get(method='mobiledevices/id/1')
print(device['location']['real_name'])
"""Set Wallpaper for device with ID #1"""
import base64
with open('temp.png',"rb") as image_file:
encoded_string = base64.b64encode(image_file.read()).decode()
body = str("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><mobile_device_command><command>Wallpaper</command><wallpaper_setting>1</wallpaper_setting><wallpaper_content>") + \
str(encoded_string) + \
str("</wallpaper_content><mobile_devices><mobile_device><id>%s</id></mobile_device></mobile_devices></mobile_device_command>") % str(iid)
api.post(method='mobiledevicecommands/command/Wallpaper',body=body)
jssapi¶
jssapi package¶
Submodules¶
jssapi.cli module¶
Console script for jssapi.
jssapi.cph module¶
jssapi.decorators module¶
-
class
jssapi.decorators.
alias
(*aliases)[source]¶ Bases:
object
Alias class that can be used as a decorator for making methods callable through other names (or “aliases”). Note: This decorator must be used inside an @aliased -decorated class. For example, if you want to make the method shout() be also callable as yell() and scream(), you can use alias like this:
@alias(‘yell’, ‘scream’) def shout(message):
# ….
jssapi.jssapi module¶
Main JSSApi module.
-
class
jssapi.jssapi.
JSSApi
(url='', head={'Accept': 'application/json'}, user='', pwd='', dbhost='', db='', dbuser='', dbpasswd='')[source]¶ Bases:
object
-
change
(method='mobiledevices', body='')¶ Interact with PUT methods of JSS API
-
create
(method='mobiledevices', body='')¶ Interact with POST methods of JSS API
-
edit
(method='mobiledevices', body='')¶ Interact with PUT methods of JSS API
-
find
(method='mobiledevices')¶ Interact with GET methods of JSS API
-
insert
(method='mobiledevices', body='')¶ Interact with POST methods of JSS API
-
modify
(method='mobiledevices', body='')¶ Interact with PUT methods of JSS API
-
new
(method='mobiledevices', body='')¶ Interact with POST methods of JSS API
-
remove
(method='mobiledevices')¶ Interact with DELETE methods of JSS API
-
retrieve
(method='mobiledevices')¶ Interact with GET methods of JSS API
-
set_db
(host=None, db='', user='', passwd='')[source]¶ Provide DB credentials if you want to directly interact with MySQL DB
-
update
(method='mobiledevices', body='')¶ Interact with PUT methods of JSS API
-
Module contents¶
Contributing¶
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
You can contribute in many ways:
Types of Contributions¶
Report Bugs¶
Report bugs at https://github.com/sreyemnayr/jamf_pro_api/issues.
If you are reporting a bug, please include:
- Your operating system name and version.
- Any details about your local setup that might be helpful in troubleshooting.
- Detailed steps to reproduce the bug.
Fix Bugs¶
Look through the GitHub issues for bugs. Anything tagged with “bug” and “help wanted” is open to whoever wants to implement it.
Implement Features¶
Look through the GitHub issues for features. Anything tagged with “enhancement” and “help wanted” is open to whoever wants to implement it.
Write Documentation¶
jamf Pro API could always use more documentation, whether as part of the official jamf Pro API docs, in docstrings, or even on the web in blog posts, articles, and such.
Submit Feedback¶
The best way to send feedback is to file an issue at https://github.com/sreyemnayr/jamf_pro_api/issues.
If you are proposing a feature:
- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to implement.
- Remember that this is a volunteer-driven project, and that contributions are welcome :)
Get Started!¶
Ready to contribute? Here’s how to set up jamf_pro_api for local development.
Fork the jamf_pro_api repo on GitHub.
Clone your fork locally:
$ git clone git@github.com:your_name_here/jamf_pro_api.git
Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:
$ mkvirtualenv jamf_pro_api $ cd jamf_pro_api/ $ python setup.py develop
Create a branch for local development:
$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:
$ flake8 jamf_pro_api tests $ python setup.py test or py.test $ tox
To get flake8 and tox, just pip install them into your virtualenv.
Commit your changes and push your branch to GitHub:
$ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature
Submit a pull request through the GitHub website.
Pull Request Guidelines¶
Before you submit a pull request, check that it meets these guidelines:
- The pull request should include tests.
- If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
- The pull request should work for Python 2.7 and 3.6, and for PyPy. Check https://travis-ci.org/sreyemnayr/jamf_pro_api/pull_requests and make sure that the tests pass for all supported Python versions.
Credits¶
Development Lead¶
- Ryan Meyers <ryanmeyersweb@gmail.com>
Contributors¶
None yet. Why not be the first?