Closed mhrono closed 4 months ago
Researching.
One quick thing with your example:
## get existing group data
updatedDevicesGroupData = jamfClient.classic_api_request("get", "computergroups/name/[jamf sdk test] macOS Version Current")
## get group ID etc if exists
if updatedDevicesGroupData.ok:
groupID = updatedDevicesGroupData.json().get("computer_group").get("id")
groupData = jamfClient.classic_api.get_computer_group_by_id(groupID)
## set new criterion value and update group
groupData.criteria[0].value = productVersion
jamfClient.classic_api.update_smart_computer_group_by_id(groupID, groupData)
You're making two calls for the same object. You can init a model from the response of the first computergroups/name
request:
updatedDevicesGroupData = jamfClient.classic_api_request("get", "computergroups/name/[jamf sdk test] macOS Version Current")
computer_groups.ClassicComputerGroup(**updatedDevicesGroupData.json()["computer_group"])
Ahh excellent, I hadn't considered I could just re-use the data I already fetched.
Anyway, I've tested with the branch containing the fix for this, and can confirm it now works as expected! There was one warning (which is easily worked around by typecasting the value as a string):
/Users/$me/Library/Python/3.12/lib/python/site-packages/pydantic/main.py:364: UserWarning: Pydantic serializer warnings:
Expected `str` but got `int` - serialized value may not be as expected
return self.__pydantic_serializer__.to_python(
Array item: {'name': 'Operating System Version', 'priority': 0, 'and_or': 'and', 'search_type': 'greater than or equal', 'value': 15, 'opening_paren': False, 'closing_paren': False}```
When attempting to create a smart group, the API is returning
Error: Name, and/or, search_type are required in criterion.
According to the SDK models in the docs, the data I'm giving it is valid, but the XML conversion seems to be broken. See below.Steps to Reproduce
Expected Result
The smart computer group should either be updated or created with the correct criteria.
Actual Result
The same result is observed with both create and update operation attempts. The SDK appears to validate the input, but the XML generated and sent to jamf is incorrect. Specifically, the
and_or
andsearch_type
values are being split into single-characterNone
items, when they should be simple strings. The API response also references a missingName
criterion attribute, but I'm not sure what's causing that, as that key seems to be generated properly.SDK generated XML:
System Information
macOS 14.5 Python 3.12.1 Jamf Pro 11.7.0 Jamf Python SDK 0.6a1