JamfClient¶
- class JamfClient(config: ConfigManager, concurrency: int)[source]¶
Provides methods for interacting with the Jamf API, specifically fetching patch data, device information, and OS versions.
Note
All methods of the JamfClient class will raise an
APIResponseErrorif the API call is unsuccessful.- Parameters:
config (
ConfigManager) – Instance ofConfigManagerfor loading and storing credentials.concurrency (int) – Maximum number of concurrent API requests. See concurrency in Usage docs.
- classmethod from_credentials(client_id: str, client_secret: str, server: str, concurrency: int = 5) JamfClient[source]¶
Construct an
JamfClientdirectly from credentials, bypassing the macOS keychain. Intended for library and CI/CD use.Wraps the inputs in an in-memory
ConfigManager(the same path the CLI uses for non-interactive mode) so no keyring backend is required and nothing is persisted to disk.from patcher import JamfClient client = JamfClient.from_credentials( client_id="...", client_secret="...", server="https://myorg.jamfcloud.com", ) summaries = await client.get_summaries(await client.get_policies())
- Parameters:
client_id (str) – Jamf Pro API client ID.
client_secret (str) – Jamf Pro API client secret.
server (str) – Jamf Pro instance URL (e.g.
https://myorg.jamfcloud.com).concurrency (int) – Maximum concurrent API requests. Defaults to 5, the recommended ceiling per the Jamf Developer Guide.
- Returns:
A constructed
JamfClientready for use.- Return type:
- async _headers() dict[str, str][source]¶
Generates headers for API calls, ensuring the latest token is used.
- async get_policies() list[str][source]¶
Retrieves a list of patch software title IDs from the Jamf API.
- async get_summaries(policy_ids: list[str]) list[PatchTitle][source]¶
Retrieves patch summaries asynchronously for the specified policy IDs from the Jamf API.
- Parameters:
policy_ids (list[str]) – list of policy IDs to retrieve summaries for.
- Returns:
list of
PatchTitleobjects containing patch summaries.- Return type:
list[
PatchTitle]
- async get_title_report_csv(title_id: str) list[PatchDevice][source]¶
Retrieve the complete patch report for a specific software title using the CSV export endpoint.
This method fetches all device data in a single CSV request, avoiding pagination entirely.
- Parameters:
title_id (str) – The software title ID to retrieve the patch report for.
- Returns:
List of all PatchDevice objects for the title.
- Return type:
list[
PatchDevice]- Raises:
APIResponseError – If the CSV export fails or returns non-200 status.
- async get_title_reports(title_ids: list[str]) dict[str, list[PatchDevice]][source]¶
Retrieves patch reports for multiple software titles.
Processes titles sequentially to avoid overwhelming the Jamf API. Each title’s pagination is handled by the underlying stream/fetch methods.
- Parameters:
title_ids (list[str]) – List of software title IDs to retrieve reports for.
- Returns:
Dictionary mapping title IDs to lists of PatchDevice objects.
- Return type:
dict[str, list[
PatchDevice]]
- async get_device_ids() list[int][source]¶
Asynchronously fetches the list of mobile device IDs from the Jamf Pro API.
Note
This method is only called if the iOS option is passed to the CLI.
- async get_device_os_versions(device_ids: list[int]) list[dict[str, str]][source]¶
Asynchronously fetches the OS version and serial number for each device ID provided.
Note
This method is only called if the iOS option is passed to the CLI.
- async get_app_names(patch_titles: list[PatchTitle]) list[dict[str, Any]][source]¶
Fetches all possible app names for each
PatchTitleobject provided.- Parameters:
patch_titles (list[
PatchTitle]) – list ofPatchTitleobjects.- Returns:
list of dictionaries containing the
PatchTitletitle and correspondingappName- Return type:
- async get_sofa_feed() list[dict[str, str]][source]¶
Fetches iOS Data feeds from SOFA and extracts latest OS version information.
Note
This method is only called if the iOS option is passed to the CLI.
- Returns:
A list of dictionaries containing base OS versions, latest iOS versions, and release dates.
- Return type:
- Raises:
APIResponseError – If the SOFA feed cannot be fetched or parsed.