-
Couldn't load subscription status.
- Fork 17
Working with Record Classes
Currently, the python-jamf module supports about 50 Jamf records like Buildings, Categories, Computers, OSXConfigurationProfiles, and Policies for example. Each record is a Python object, but they are generic, so all of the data in the supported records are accessible. The record classes 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.
There are record classes that represent lists of records, and there are record classes that represent individual records. All class names that are plural are lists, and all class names that are singular represent a single record. Example: computers is a list of computers, but computer is a single computer record.
We realize that we made this too complex and it needs to be simplified. We are working on it right now.
Here is an example of working with the Categories record. Because this is plural, it is a list of record.
from jamf.records import Categories
allcategories = Categories()
allcategories.names()
allcategories.ids()
for item in allcategories:
repr(item)The following methods return a list of records. This is a regular list class, not a Categories class.
cat_util = allcategories.recordsWithName("Utilities")
cat_macos = allcategories.recordsWithRegex("[Mm]ac ?OS")
type(cat_macos) # <class 'list'>
type(allcategories) # <class 'jamf.records.Categories'>Starting where we left off above, we can get an individual record.
category = allcategories.recordWithId(141)
category = Categories().find("Utilities")
repr(category)
category = Categories().find(141)
repr(category)
type(category) # <class 'jamf.records.Category'>The detailed data is not retrieved from the Jamf server until it is accessed.
category.dataTo edit the data, just set it and save.
category.data['name'] = "Bla"
category.save()Data in record classes are cached. If it changes on the server, it must be updated.
allcategories.refresh()