Skip to content

Replace deprecated Jamf Pro API endpoints with supported alternatives#79

Open
cr3ation wants to merge 2 commits intomacadmins:mainfrom
cr3ation:main
Open

Replace deprecated Jamf Pro API endpoints with supported alternatives#79
cr3ation wants to merge 2 commits intomacadmins:mainfrom
cr3ation:main

Conversation

@cr3ation
Copy link

@cr3ation cr3ation commented Mar 3, 2026

Summary

This PR replaces deprecated Jamf Pro API endpoints with their supported alternatives, targeting Jamf Pro 11.25.0. All existing methods are preserved with DeprecationWarning notices, and new methods are added alongside them. No breaking changes.

  • Replace GET /v1/computers-inventory (deprecated 2025-06-30) with GET /v3/computers-inventory
  • Replace POST /preview/mdm/commands (removed from API schema) with POST /v2/mdm/commands
  • Replace JCDS v1 S3-based upload (deprecated 2025-08-28) with POST /v1/packages/{id}/upload
  • Fix typo in api_options: serAndLocation.buildingIduserAndLocation.buildingId
  • Add cfBundleShortVersionString and cfBundleVersion fields to ComputerApplication
  • Add ~25 new V2 MDM command models
  • Add unit tests for new Pro API models (30 new tests, 66 total)

Deprecation warnings

Calling any deprecated method will emit a DeprecationWarning pointing to the replacement:

>>> client.pro_api.get_computer_inventory_v1()
DeprecationWarning: get_computer_inventory_v1() is deprecated. The v1 computer inventory API
was deprecated by Jamf on 2025-06-30. Use get_computer_inventory_v3() instead.

>>> client.pro_api.send_mdm_command_preview(...)
DeprecationWarning: send_mdm_command_preview() is deprecated. The preview MDM commands API
has been removed from the Jamf Pro API schema. Use send_mdm_command_v2() instead.

>>> client.pro_api.create_jcds_file_v1()
DeprecationWarning: create_jcds_file_v1() is deprecated. The JCDS v1 API was deprecated
by Jamf on 2025-08-28. Use upload_package_v1() instead.

>>> client.jcds2.upload_file("/path/to/package.pkg")
DeprecationWarning: upload_file() is deprecated. The JCDS v1 API was deprecated by Jamf
on 2025-08-28. Use upload_package() instead, which does not require the 'aws' extra dependency.

Migration examples

Computer Inventory: v1 → v3

# Before (deprecated)
computers = client.pro_api.get_computer_inventory_v1(
    sections=["GENERAL", "HARDWARE"],
    sort_expression=SortField("general.name").asc(),
)

# After
computers = client.pro_api.get_computer_inventory_v3(
    sections=["GENERAL", "HARDWARE"],
    sort_expression=SortField("general.name").asc(),
)

# The returned Computer model is the same. The v3 API adds cfBundle fields
# to applications and removes the PLUGINS/FONTS sections.
for computer in computers:
    for app in computer.applications or []:
        print(app.cfBundleShortVersionString)  # New in v3
        print(app.cfBundleVersion)             # New in v3

# New v3-only methods:
computer = client.pro_api.get_computer_inventory_detail_v3(computer_id=42)
computer = client.pro_api.get_computer_v3(computer_id=42, sections=["GENERAL", "HARDWARE"])
client.pro_api.update_computer_v3(computer_id=42, data={"general": {"name": "New Name"}})
client.pro_api.delete_computer_v3(computer_id=42)

MDM Commands: preview → v2

# Before (deprecated)
from jamf_pro_sdk.models.pro.mdm import EraseDeviceCommand

client.pro_api.send_mdm_command_preview(
    management_ids=["4eecc1fb-f52d-48c5-9560-c246b23601d3"],
    command=EraseDeviceCommand(pin="123456"),
)

# After
client.pro_api.send_mdm_command_v2(
    management_ids=["4eecc1fb-f52d-48c5-9560-c246b23601d3"],
    command=EraseDeviceCommand(pin="123456"),
)

# The v2 API supports many more command types:
from jamf_pro_sdk.models.pro.mdm import (
    DeviceLockCommand,
    DeviceInformationCommand,
    EnableRemoteDesktopCommand,
    SecurityInfoCommand,
    # ... ~25 command types total
)

client.pro_api.send_mdm_command_v2(
    management_ids=["4eecc1fb-f52d-48c5-9560-c246b23601d3"],
    command=DeviceLockCommand(pin="123456", message="This device is locked."),
)

Package Upload: JCDS v1 (S3/boto3) → direct upload

# Before (deprecated, requires boto3)
client.jcds2.upload_file("/path/to/package.pkg")

# After (no boto3 required)
client.jcds2.upload_package("/path/to/package.pkg")

# Or use the Pro API method directly if you manage packages yourself:
package_id = client.classic_api.create_package(data=new_package)
client.pro_api.upload_package_v1(package_id=package_id, file_path="/path/to/package.pkg")

Files changed

File Change
src/jamf_pro_sdk/models/pro/api_options.py Bug fix + v3 sections/sort/filter options
src/jamf_pro_sdk/models/pro/computers.py Add cfBundleShortVersionString/cfBundleVersion to ComputerApplication
src/jamf_pro_sdk/models/pro/mdm.py Add ~25 v2 MDM command models, MdmCommandRequest
src/jamf_pro_sdk/models/pro/__init__.py Add HrefResponse model
src/jamf_pro_sdk/clients/pro_api/__init__.py Add v3 computer methods, upload_package_v1, send_mdm_command_v2, deprecation warnings
src/jamf_pro_sdk/clients/jcds2.py Add upload_package(), deprecate upload_file()
tests/unit/models/test_models_pro_computers.py New: 8 tests for Pro computer models
tests/unit/models/test_models_pro_mdm.py New: 22 tests for MDM command models

Test plan

  • All 66 unit tests pass (pytest tests/unit/ -v)
  • Integration test against Jamf Pro 11.25.0 with v3 computer inventory
  • Integration test with v2 MDM commands
  • Integration test with package upload via upload_package_v1
  • Verify deprecation warnings appear when calling old methods

cr3ation and others added 2 commits March 3, 2026 15:36
- Add v3 computer inventory methods (get_computer_inventory_v3, get_computer_v3,
  get_computer_inventory_detail_v3, update_computer_v3, delete_computer_v3) to
  replace deprecated v1 endpoint (2025-06-30)
- Add send_mdm_command_v2() with ~25 new command models to replace the preview
  MDM endpoint removed from the API schema
- Add upload_package_v1() for direct multipart file upload, replacing the
  deprecated JCDS v1 S3-based workflow (2025-08-28) without requiring boto3
- Add upload_package() to JCDS2 client using the new upload endpoint
- Add HrefResponse model, v3 api_options (sections/sort/filter fields)
- Add cfBundleShortVersionString and cfBundleVersion to ComputerApplication
- Mark deprecated methods with DeprecationWarning (v1 inventory, JCDS v1,
  preview MDM commands)
- Fix typo in api_options: "serAndLocation.buildingId" → "userAndLocation.buildingId"

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- test_models_pro_computers.py: ComputerApplication v1/v3 parsing, roundtrip,
  Computer model with/without plugins/fonts, extra fields
- test_models_pro_mdm.py: all v2 MDM command models, MdmCommandRequest
  construction/serialization/parsing, CustomCommand, SettingsCommand extra fields

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant