univ-of-utah-marriott-library-apple / python-jamf

Licence: MIT license
`python-jamf` is a library for connecting to a Jamf Server that maps directly to the Jamf Pro Classic API. It is the basis for the `jctl` tool to automate patch management & packages and many other items.

Programming Languages

python
139335 projects - #7 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to python-jamf

AutoBrew
AutoBrew: Homebrew deployments made easy
Stars: ✭ 71 (+91.89%)
Mutual labels:  jamf, jamf-pro
scout-public
A tool to aggregate devices across multiple MDM servers
Stars: ✭ 22 (-40.54%)
Mutual labels:  jamf, jamf-pro
jamfscripts
Scripts I use non API related
Stars: ✭ 15 (-59.46%)
Mutual labels:  jamf, jamf-pro
kinobi
An external patch definition server for Jamf Pro
Stars: ✭ 76 (+105.41%)
Mutual labels:  jamf, jamf-pro
mac scripts
A collection of scripts used to Manage Mac OS X computers.
Stars: ✭ 38 (+2.7%)
Mutual labels:  jamf, jamf-pro
JAMF-Enrollment-Kickstart
A better enrollment kickoff for JAMF machines
Stars: ✭ 74 (+100%)
Mutual labels:  jamf, jamf-pro
homebrew.sh
Install homebrew via Jamf without giving users admin rights
Stars: ✭ 52 (+40.54%)
Mutual labels:  jamf, jamf-pro
jamfpro-extension-attributes
🔍 A repository for EAs to use for reporting in the Jamf Pro Server
Stars: ✭ 30 (-18.92%)
Mutual labels:  jamf, jamf-pro
DockBuilder
A LaunchAgent and .app to build a user's Dock upon login and/or on demand.
Stars: ✭ 39 (+5.41%)
Mutual labels:  jamf, jamf-pro
TheScopeReport
This is a Java program that calls the Jamf Pro API to collect scoping details.
Stars: ✭ 13 (-64.86%)
Mutual labels:  jamf, jamf-pro
pre-commit-macadmin
Pre-commit hooks for Mac admins.
Stars: ✭ 43 (+16.22%)
Mutual labels:  autopkg, jamf
scl jamf tools
This repository contains a collection of tools written to perform as enhancements to the Jamf Pro management software.
Stars: ✭ 39 (+5.41%)
Mutual labels:  jamf, jamf-pro
prop-types-definition
Patch for prop-types to get property type definition in runtime
Stars: ✭ 15 (-59.46%)
Mutual labels:  patch
UnofficialCrusaderPatch
Unofficial balancing patch installer for Stronghold Crusader 1
Stars: ✭ 373 (+908.11%)
Mutual labels:  patch
intellij-diff-plugin
Syntax highlighting for .diff files and .patch files in IntelliJ IDEs
Stars: ✭ 17 (-54.05%)
Mutual labels:  patch
patchmanager
Patchmanager for SailfishOS
Stars: ✭ 21 (-43.24%)
Mutual labels:  patch
Mirai
Mirai 未来 - A powerful Minecraft Server Software coming from the future
Stars: ✭ 325 (+778.38%)
Mutual labels:  patch
magento1-open-source-patches
Magento Open Source 1.x patches mirror repository.
Stars: ✭ 38 (+2.7%)
Mutual labels:  patch
MacOS-All-In-One-Update-Script
Mac update shell script (Appstore, macOS, Homebrew and others)
Stars: ✭ 39 (+5.41%)
Mutual labels:  patch
duff
Pure OCaml implementation of libXdiff (Rabin's fingerprint)
Stars: ✭ 20 (-45.95%)
Mutual labels:  patch

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.

Note, python-jamf can work with unsupported Jamf records, it just isn't as easy as the next section shows.

Quick Example

This is just a quick example of the power and ease-of-use of python-jamf. The following code prints the last_contact_time from all computer records, from a computer record with the ID of 1, a computer record named "Jimmy's Mac", and computer records that match a regex. Then, it searches for a computer by name and if it exists then it changes the name. Lastly, it shows how to delete and create records.

import jamf
for computer in jamf.Computers(): # Retreive the data from the server
	print(computer.data["general"]["last_contact_time"])

computers = jamf.Computers()      # Use the data retrieved above, don't re-download
computers.refresh()               # Re-download the records from the server

if "1" in computers:
    print(computers.recordWithId(1).data['general']['last_contact_time'])

if "Jimmy's Mac" in computers:
    print(computers.recordWithName("Jimmy's Mac").data['general']['last_contact_time'])

for computer in computers.recordsWithRegex("J[ia]m[myes]{2}'s? Mac"): # Matches Jimmy's, James', and James's
	print(computer.data["general"]["last_contact_time"])

computer = computers.recordWithName("James's Mac)
if computer:
	computer.refresh()            # Re-download the record from the server
	computer.data['general']['name'] = "James' Mac"
	computer.save()

# Delete a record

computer = computers.recordWithName("Richard's Mac)
if computer:
	computer.delete()

# Create a record (2 ways)

comp1 = computers.createNewRecord("computer1") # This really is a short-cut for the next line.
comp2 = jamf.records.Computer(0, "computer2")

A few notes. You can replace jamf.Computers() with jamf.Policies() or any supported record type.

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

Upgrading

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

To upgrade python-jamf run the following command:

sudo pip3 install --upgrade 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

Releases

🆕 python-jamf - 0.8.2

  • Much better error reporting when there's a connection failure to the server
  • Checks for "http://" or "https://" when setting a hostname and when connecting to a server
  • Added conf-python-jamf -r to remove the bearer token saved in the keychain
  • Unified server connection code
  • Replaced all exit(1) with raise SystemExit
  • pre-commit updated to 4.3.0
  • GitHub action updated action names
  • Updated README

python-jamf - 0.8.1

  • This release includes the xml array fix described here.

python-jamf - 0.7.5

  • Fixed trigger_logout removal from policies triggers
  • Fixed bearer token bug
  • Lots of automated reformatting and cleaning up
  • Adds pre-commit

Thank you homebysix for your contributions.

python-jamf - 0.7.4

  • Bearer token support
  • Fixed bug when creating records (shallow vs deep copy)
  • Fixed version in setup.py bug
  • Removed jamfnet from main docker-compose and move it to it's own file
  • Support smb mounting on linux

Thank you yairf-s1 and pythoninthegrass for your contributions.

See python-jamf upgrade documentation to upgrade to latest release.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].