Setup¶
Setup Class¶
- class Setup(config: ConfigManager, ui_config: UIConfigManager, plist_manager: PropertylistManager)[source]¶
Handles the initial setup process for the Patcher CLI tool.
This class guides users through configuring the necessary components to integrate with their Jamf environment. The setup includes creating API roles, clients, and configuring user interface settings for PDF reports.
- Parameters:
config (
ConfigManager) – Manages application configuration, including credential storage.ui_config (
UIConfigManager) – Handles UI-related configurations for the setup process.plist_manager (
PropertylistManager) – Handles read/write operations to project property list.
- property completed: bool[source]¶
Indicates whether the setup process has been completed.
- Returns:
True if setup has been completed, False otherwise.
- Return type:
- async prompt_credentials(setup_type: SetupType) dict[source]¶
Prompt for credentials based on the credential type.
- async prompt_ui_settings() None[source]¶
Drive the interactive UI configuration prompts (header/footer text, font, logo, header color) and persist them via the
UIConfigManager. Triggers font downloads on first run.Replaces the legacy
UIConfigManager.setup_uimethod, moved to the CLI layer so the core UI config object stays free ofasyncclickandPILdependencies for library callers.- Return type:
None
- async prompt_font_config() dict[str, str][source]¶
Prompt for custom font paths and copy them into Patcher’s font directory.
- async prompt_logo_config() str[source]¶
Prompt for a logo file path, validate it as an image, and copy it into Patcher’s Application Support directory.
- Returns:
The path to the saved logo file.
- Return type:
- Raises:
SetupError – If the provided logo path does not exist.
PatcherError – If the file is not a valid image, or copying fails.
- validate_creds(creds: dict, required_keys: tuple[str, ...], setup_type: SetupType) None[source]¶
Validates all required keys are present in the credentials.
- Parameters:
- Raises:
SetupError – If any credentials are missing.
- Return type:
None
- prompt_installomator() None[source]¶
Prompts user to enable or disable InstallomatorClient support.
If enabled, assists in identifying
PatchTitleobjects with InstallomatorClient support, used during analyze commands.- Return type:
None
- async get_token(setup_type: SetupType = SetupType.STANDARD, creds: dict | None = None) str | AccessToken[source]¶
Fetches a Token (basic or
AccessToken) depending on setup type (Standard or SSO).- Parameters:
- Raises:
SetupError – If either type of Token could not be obtained.
- Returns:
For
SetupType.STANDARD, the basic token is returned. ForSetupType.SSO, theAccessTokenobject is returned.- Return type:
- async create_api_client(basic_token: str, jamf_url: str) tuple[str, str][source]¶
Creates API Role and Client for standard setup types.
- Parameters:
- Raises:
SetupError – If either the API Role or API Client could not be created.
- Returns:
The client ID and client secret of the created API Client and Role.
- Return type:
- async bootstrap_noninteractive(client_id: str, client_secret: str, url: str) None[source]¶
Non-interactive setup path for CI/CD environments.
Skips all prompts (setup type, InstallomatorClient, UI configuration). The provided credentials are stored via the configured
ConfigManager. When that manager is in in-memory mode (the typical CI/CD setup) the macOS keychain is not touched. An access token is then fetched so subsequent API calls succeed.Setup completion is marked in memory only, with no plist mutation. The next invocation will need to provide credentials again, which is the desired behavior on ephemeral runners.
- Parameters:
- Raises:
SetupError – If a token cannot be obtained with the provided credentials.
- Return type:
None
- async start(spinner=None, fresh: bool = False) None[source]¶
Run the interactive setup flow end-to-end.
Returns early if setup has already completed unless
fresh=Trueis passed (which re-runs the full flow regardless of previous completion). Prompts for setup type, then walks the full path: credentials → API role + client creation (Standard only) → bearer token fetch →JamfClientsave → UI configuration → mark complete.Options:
STANDARDprompts for admin username/password, fetches a basic token, creates the API role + client on the Jamf side, and saves the resulting client credentials.SSOprompts for an existing API client ID + secret and saves them directly.
See also
For SSO users, reference our SSO Considerations page for assistance creating an API integration.
Note
If a previous attempt failed after the Jamf API role + client were created, a Standard re-run will fail with a
400because those objects already exist. Either delete them from Jamf and retry, or switch to SSO setup and reuse them.- Parameters:
spinner (rich.status.Status | _NoOpStatus | None) – The live Rich status (or
_NoOpStatus) whose message is updated as setup progresses. Stored onself._spinnerso helper methods can update it. Defaults to a no-op.fresh (bool) – If True, re-run setup even when already completed.
- Raises:
SetupError – If a token cannot be fetched, credentials are missing, or any other setup step fails.
- Return type:
None
- reset_setup() bool[source]¶
Resets setup completion flag, removing the
setup_completedkey/value from the property list.This effectively marks Setup completion as False and will re-trigger the setup assistant.
Warning!
The Jamf API will return a
400response if API Roles/Clients exist already in the Jamf instance specified. It is important to remove the API Role and Client objects before re-running the Setup assistant.- Returns:
Trueif the Setup section in the property list file was removed.- Return type: