`python-jamf` is a library for connecting to a Jamf Server that maps directly to the Jamf Pro Classic API.

Overview

python-jamf

Programmatic Automation, Access & Control of Jamf Pro

python_jamf_logo

Introduction

python-jamf is a Python 3 module to access the Jamf Pro Classic API. The Classic API is the primary tool for programmatic access to data on a Jamf Pro server to allow integrations with other utilities or systems. The concept behind it is to have a class or simply a collection of data (variables) and methods (functions) that maps directly to the API (https://example.com:8443/api).

The python-jamf API class doesn't hide anything from you. It handles the URL requests, authentication, and converts between XML/JSON to Python dictionaries/lists.

The python-jamf module also provides undocumented access to Jamf Admin functionality used for uploading items to Jamf Distribution Points.

python_jamf workflow

What are python-jamf and jctl?

Originally, it was a "patch" project that was focused on patch management including installer package management, patch management, including assigning package to patch definition, updating versions, version release branching (i.e. development, testing, production), and scripting and automation. Later, it was split into two projects, python-jamf, which is a python library that connects to a Jamf Pro server using Jamf Pro Classic API, including keychain support for Jamf Pro credentials via keyring python project, support for PyPi to support pip installation and currently supports 56 Jamf Pro record types which will expand in number as the project continues.

The second project, jctl,  is a command-line tool that uses the python-jamf library to select objects to create, delete, print and update. It allows performing Jamf Pro repetitive tasks quickly and provides options not available in the web GUI. It is similar to SQL statements, but far less complex. And recently added PyPi to support pip installation.

Please check out the jctl github page for more information.

Supported Jamf Records

Currently, the python-jamf supports about 50 Jamf records like Buildings, Categories, Computers, OSXConfigurationProfiles, and Policies for example.

Each record is a singleton Python object, but they are generic and most functionality comes from the parent Record class. Objects do not have member variables for Jamf data. All Jamf Pro data is stored as a Python dictionary that is accessed with the data() method. All lists of records are singleton subclasses of the Records class.

By being singleton classes, you perform one fetch to the server for each list or record. This prevents multiple fetches for the same object. All changes you make are local until you save or refresh the object.

Quick Start

Installing

For those that want to try python-jamf quickly here are some general steps:

  • Install Module & Requirements: sudo pip3 install python-jamf
  • Create an Jamf Pro API User
  • Enter hostname, username, and password
  • Test: conf-python-jamf -t

Uninstalling

Uninstalling python-jamf is easy if you installed it via pip. pip is the Package Installer for Python.

To uninstall python-jamf run the following command:

sudo pip3 uninstall python-jamf

Getting Help

Wiki

More Documentation

For further in-depth details please check out the wiki.

Searching the wiki

To search this wiki use the "Search" field in the GitHub navigation bar above. Then on the search results page select the "Wiki" option or click here and search.

MacAdmin Slack Channel

If you have additional questions, or need more help getting started, post a question on the MacAdmin's Slack jctl channel.

MacAdmin's Slack Logo

Latest Status

Since we recorded our session over a month ago, some of the information in our presentation is out of date already. We have spent the time between when we recorded the presentation and now (October 14, 2021) getting GitHub actions working so that it will test and publish to pypi.com. It took longer to get this working than we thought. So that's about where we are. But it works now. We also added some Docker containers that you can run locally to try out python-jamf and jctl. There are also some minor differences in pkgctl than what is shown in the presentation.

I should also mention, one of us also had an issue where we assumed that pkgctl was crashing our production Jamf Pro server. But, increasing the amount of RAM and CPU's for that server fixed this issue.

Comments
  • how to format put for specific ID of computer and static group IP

    how to format put for specific ID of computer and static group IP

    so far i get the computers for a user (sometimes singular, sometimes multiple), but im trying to figure out the appropriate api.put command for it.

    i usually work in bash so i know there the command ends with "<computer_group><computer_additions>$serial</computer_additions></computer_group>" https://JSS.jamfcloud.com/JSSResource/computergroups/id/{id} -X PUT >", but now sure how to translate it to python.

    opened by grainofric3 6
  • docker-compose doesn't create network automatically

    docker-compose doesn't create network automatically

    Issue

    Testing the stable docker version of python-jamf and the build process is failing at network creation.

    Steps to reproduce

    Have only tried with python-jamf-github, but suspect it's the same for python-jamf-dev.

    $ cd python-jamf/python-jamf-docker
    $ docker-compose run --rm python-jamf-github
    network jamfpro_jamfnet declared as external, but could not be found
    

    Workaround

    Create the jamfpro_jamfnet docker network manually.

    $ docker network create -d bridge jamfpro_jamfnet
    4576<snip>
    $ docker-compose run --rm python-jamf-github
    [+] Building 106.1s (6/8)
     => [internal] load build definition from Dockerfile                                                                                                                            0.0s
    
    bug 
    opened by pythoninthegrass 5
  • Consider using Python Black for automatic formatting consistency

    Consider using Python Black for automatic formatting consistency

    For your consideration, this pull request applies Python Black formatting.

    Benefits

    In the projects I've worked on, I've found that applying consistent autoformatting (whether Black or something similar like autopep8 or yapf) significantly streamlines contributions. Discussions about code style fade away, allowing contributors to focus on the function.

    Also, Black's tendency to split long lines up slightly reduces the risk of merge conflicts if multiple elements of the same list/tuple/dict are edited by two different PRs.

    Black sometimes also surfaces syntax bugs before commit, since the formatting won't run if the Python doesn't compile.

    Risks

    Because this PR touches almost every Python file in the project, it's likely that it will conflict with changes on contributors' branches downstream. Any contributors will need to rebase their changes on the main branch (and possibly resolve conflicts manually) in order to continue. (At the moment, I don't see any non-merged branches here on GitHub, so it's probably a good time for a change like this.)

    The most streamlined way to use Black is to configure your local development environment with it, so that every time you save, the formatting is applied. In my VSCode prefs, I have settings to facilitate this:

    "python.formatting.provider": "black",
    "python.formatting.blackPath": "/opt/homebrew/bin/black",
    

    This optional streamlining creates a small additional setup burden for people who are regularly contributing, but shouldn't prevent those who wish to contribute more casually.

    Output

    The changes in this PR were produced with black ., resulting in the output below. No changes to actual function were made.

    % black .
    reformatted jamf/convert.py
    reformatted jamf/version.py
    reformatted setup.py
    reformatted jamf/config.py
    reformatted jamf/setconfig.py
    reformatted jamf/api.py
    reformatted tests/api_mock_test.py
    reformatted tests/convert_json_xml_test.py
    reformatted tests/test_package.py
    reformatted tests/test_config.py
    reformatted jamf/admin.py
    reformatted jamf/package.py
    reformatted tests/test_records.py
    reformatted jamf/records.py
    All done! ✨ 🍰 ✨
    14 files reformatted, 2 files left unchanged.
    

    For more context, see this portion of my 2019 PSU MacAdmins talk, which covers Black specifically.

    Thanks for considering!

    opened by homebysix 4
  • Turn README into wiki

    Turn README into wiki

    Not really an issue. Just a point I wanted to raise for discussion. The README is now getting to a length and if I add documentation for my work it will get longer.

    So how do you feel about me taking the existing README and my documentation and turning it onto a shorter README and a wiki? I was thinking of just a top page and only one layer of sub pages corresponding with the current headlines.

    I also have no idea if I can PR the wiki but I'm guessing I can.

    opened by Honestpuck 4
  • FileShare.mount uses macOS binaries and thus does not support linux

    FileShare.mount uses macOS binaries and thus does not support linux

    SMB could be supported using pysmb (without subprocess calls) I'm not sure about AFP though.

    We could also use 'mount' for linux machines (but then im unsure about other bsd distros)

    opened by yairf-s1 3
  • Add pre-commit configuration and corresponding GH Actions job

    Add pre-commit configuration and corresponding GH Actions job

    This pull request creates a pre-commit configuration and GitHub Actions job that runs it upon submitting PRs or pushing to main. The configuration includes two major formatting automations:

    • Python Black: The project already uses Black manually; adding a pre-commit and CI config makes this formatting easier for contributors to adopt and ensures standard style for submitted pull requests
    • iSort: Sorts Python imports in a consistent way, slightly reducing chances of merge conflict

    The above two changes will result in a new commit being made to the codebase automatically once merged. The changes will be to style only, and should not affect function at all. Here is a preview of that commit.

    I've included a few other relatively minor checks. The codebase already complies with all of these, so no changes are needed for these.

    • check-added-large-files: Helps prevent accidentally committing binary or image files to the repo by limiting new files to 100KB.
    • fix-byte-order-marker: Ensures files have consistent byte order markers (e.g. after being edited by a contributor using Windows)
    • check-case-conflict: Ensures no files are committed that would cause a conflict on case-insensitive file systems
    • check-docstring-first: Ensures Python docstrings are in the proper place
    • check-merge-conflict: Ensures no merge conflict markers are present in committed files
    • mixed-line-ending: Forbids CRLF line endings

    Once this is merged, it may be helpful to add a section to the jctl Contribute wiki page, between the "Clone the Forked Repository" and "Create a Feature Branch" sections:

    ### Install and enable pre-commit
    
    Pre-commit is a framework that automatically runs linting and consistency checks before changes
    are committed to the repository locally. For contributors who will be working in Python code, we
    recommend [installing pre-commit](https://pre-commit.com/#install) and running `pre-commit install`
    in the repo to activate these checks.
    

    (Note that even if contributors don't install pre-commit locally, GH Actions will run the checks upon submitting PRs and fix what it can.)

    On the AutoPkg project, we made a similar change recently, and it's worked well.

    opened by homebysix 2
  • Fixed README section on tests and did some more testing in test_records

    Fixed README section on tests and did some more testing in test_records

    The README section on testing was seriously wrong. I also attempted (and failed) to fix a problem where test_records.py won't run the tests if called on its own. It does run the tests if you use discovery. Not sure if it's worth opening an issue on it, but if you do assign it to me.

    opened by Honestpuck 2
  • All tests now running. Currently 9 fail.

    All tests now running. Currently 9 fail.

    I figured out why python3 -m unittest discover -v wasn't working. When we moved tests out of jamf and put them on the same level in python-jamf the imports tried to import from a parent that didn't exist.

    So all the from .. import <package> had to be changed to from jamf import <package>

    Tomorrow I will see about fixing the 9 tests that error.

    opened by Honestpuck 2
  • Add Support for Detecting Jamf Pro Version & Bearer Token Authentication

    Add Support for Detecting Jamf Pro Version & Bearer Token Authentication

    Hi:

    Jamf will deprecate support for Basic Authentication in Jamf Pro v10.35.0 or later. python-jamf will need to add support for Bearer Token authentication by implementing a version check of Jamf Pro, your application can determine whether Bearer Token authentication is supported (v10.35.0 or later) or if use of Basic authentication is required (v10.34.0 and earlier).

    The jamf-pro-version endpoint within the Jamf Pro API returns the version of the Jamf Pro Server, to help your application determine authentication compatibility with a given Jamf Pro Server. Jamf recommends including a preference to allow users to select the authentication schema based on their environment configuration or dynamically determining which authentication mechanism to use based on the Jamf Pro Server version.

    In addition to the recommendations provided above, Jamf has updated the Classic API Postman Collection to now default to the use of Bearer Token authentication. Older versions of the collection will continue to be available for interaction with environments not yet upgraded to 10.35.0 or later, however the new collection will default to using Bearer Token authentication.

    Additional details regarding the changes, including best practices are detailed on the Jamf Developer Portal.

    enhancement 
    opened by uurazzle 1
  • Added subcommands: packages view_included and scripts script_contents

    Added subcommands: packages view_included and scripts script_contents

    Output looks like this.

    ./jctl packages -S view_included

    BBEdit-13.5.5.pkg Policies Install Bare Bones BBEdit PatchSoftwareTitles Bare Bones BBEdit - 13.5.5 PatchPolicies 13.5.5 SS

    BBEdit-13.5.6.pkg

    Xcode-11.3.1.pkg Policies Install Xcode 11.3 (macOS 10.15) ComputerGroups 02 - Needs Xcode-11.3.1.pkg (Staff, Student, Opt-In, 10.15)

    Zoom-5.6.4.765.pkg Policies Install Zoom Client for Meetings

    ./jctl scripts -S script_contents #!/usr/bin/perl -w

    use strict;

    print "Hi mom";

    opened by magnusviri 1
  • Store prefs in Elektra

    Store prefs in Elektra

    "Elektra stores configuration in a global, hierarchical key database."

    https://www.libelektra.org/plugins/python

    Should be this easy.

    import kdb
    kdb.Key("user:/jamf_server")
    kdb.Key("user:/jamf_username")
    
    opened by magnusviri 1
  • test_package - problem with path

    test_package - problem with path

    test_package has six tests failing. All appear to be failing because the path passed to tar in a call to get package information points to the actual package and not the the expanded package so tar barfs on it.

    bug 
    opened by Honestpuck 2
Releases(0.8.2)
Owner
University of Utah, Marriott Library, Apple Support
Apple Support & Integration in a Heterogeneous Environment
University of Utah, Marriott Library, Apple Support
API which uses discord+mojang api to scrape NameMC searches/droptime/dropping status of minecraft names, and texture links

API which uses discord+mojang api to scrape NameMC searches/droptime/dropping status of minecraft names, and texture links

2 Dec 22, 2021
A Python wrapper for the DeepL API

deepl.py A Python wrapper for the DeepL API installing Install and update using pip: pip install deepl.py A simple example. # Sync Sample import deep

grarich 18 Dec 12, 2022
Discord-Wrapper - Discord Websocket Wrapper in python

This does not currently work and is in development Discord Websocket Wrapper in

3 Oct 25, 2022
A Telegram mirror bot which can be deployed using Heroku.

Slam Mirror Bot This is a telegram bot writen in python for mirroring files on the internet to our beloved Google Drive. Getting Google OAuth API cred

Hafitz Setya 1.2k Jan 01, 2023
Telegram 隨機色圖,支援每日自動爬取

Telegram 隨機色圖機器人 使用此原始碼的Bot 開放的隨機色圖機器人: @katonei_bot 已實現的功能 爬取每日R18排行榜 不夠色!再來一張 Tag 索引,指定Tag色圖 將爬取到的色圖轉為 WebP 格式儲存,節省空間 需要注意的事件 好久之前的怪東西,代碼質量不保證 請在使用A

cluckbird 15 Oct 18, 2021
Brute force instagram account / actonetor, 2021

Brute force instagram account / actonetor, 2021

actonetor 6 Nov 16, 2022
PRNT.sc Image Grabber

PRNTSender PRNT.sc Image Grabber PRNTSender is a script that takes images posted on PRNT.sc and sends them to a Discord webhook, if you want to know h

neox 2 Dec 10, 2021
Google Sheets Python API v4

pygsheets - Google Spreadsheets Python API v4 A simple, intuitive library for google sheets which gets your work done. Features: Open, create, delete

Nithin Murali 1.4k Jan 08, 2023
A wrapper to stream information from Twitter's Full-Archive Search Endpoint

A wrapper to stream information from Twitter's Full-Archive Search Endpoint. To exploit this library, one must have approved academic research access.

Daniela Pinto Veizaga 9 Nov 28, 2022
A Telegram UserBot to Play Radio in Voice Chats. This is also the source code of the userbot which is being used for playing Radio in @AsmSafone Channel.

Telegram Radio Player UserBot A Telegram UserBot to Play Radio in Channel or Group Voice Chats. This is also the source code of the userbot which is b

SAF ONE 44 Nov 12, 2022
PRAW, an acronym for "Python Reddit API Wrapper", is a python package that allows for simple access to Reddit's API.

PRAW: The Python Reddit API Wrapper PRAW, an acronym for "Python Reddit API Wrapper", is a Python package that allows for simple access to Reddit's AP

Python Reddit API Wrapper Development 3k Dec 29, 2022
Exporta archivos masivamente del TEC Digital.

TEC Digital Files Exporter Script que permite exportar los archivos de cursos del TEC Digital del Instituto Tecnológico de Costa Rica, debido al borra

Joseph Vargas 22 Apr 08, 2021
Enigma simulator with python and clean code.

Enigma simulator with python and clean code.

Mohammad Dori 3 Jul 21, 2022
Telegram Voice Chat UserBot made with Pyrogram and MarshalX/tgcalls with playlist and Heroku support

Telegram Voice Chat UserBot A Telegram UserBot to Play Audio in Voice Chats. This is also the source code of the userbot which is being used for playi

Calls Music 164 Nov 12, 2022
Contrastive Language-Audio Pretraining

CLAP Contrastive Language-Audio Pretraining In due time this repo will be full of lovely things, I hope. Feel free to check out the Issues if you're i

Charles Foster 83 Dec 01, 2022
Simple screen recorder

Kooha Simple screen recorder Description Kooha is a simple screen recorder built with GTK. It allows you to record your screen and also audio from you

Dave Patrick 1.2k Jan 03, 2023
Connects to a local SenseCap M1 Helium Hotspot and pulls API Data.

sensecap_api_checker_HELIUM Connects to a local SenseCap M1 Helium Hotspot and pulls API Data.

Lorentz Factr 1 Nov 03, 2021
Boto is a Python package that provides interfaces to Amazon Web Services.

Boto is a Python package that provides interfaces to Amazon Web Services.

the boto project 6.5k Jan 01, 2023
A Telegram user bot to count telegram channel subscriber or group member.

Subscriber Count Userbot A Telegram user bot to count telegram channel subscriber or group member. This tool is only for educational purpose. You coul

IDNCoderX 8 Nov 30, 2022
Reverse engineered connection to the TradingView ticker in Python

Tradingview-ticker Reverse engineered connection to the TradingView ticker in Python. Makes a websocket connection to the Tradeview website and receiv

Aaron 20 Dec 02, 2022