Config Manager#
- class ConfigManager(service_name: str = 'Patcher')[source]#
Manages configuration settings, primarily focused on handling credentials stored in the macOS keychain.
This class provides methods to securely store, retrieve, and manage sensitive information such as API tokens and client credentials. It integrates with the
keyringlibrary to interface with the macOS keychain.ConfigManagerobjects are initialized with a default service name of “Patcher”, which is used as a namespace for storing and retrieving credentials in macOS keychain.- Parameters:
service_name (
str) – Service name for storing credentials in the keyring. Defaults to ‘Patcher’.
- get_credential(key: str) str[source]#
This method is useful for accessing stored credentials without hardcoding them in scripts. It ensures that sensitive data like passwords or API tokens are securely stored and retrieved.
- Parameters:
key (
str) – The key of the credential to retrieve, typically a descriptive name like ‘API_KEY’.- Returns:
The retrieved credential value.
- Return type:
- Raises:
CredentialError – If the specified credential could not be retrieved.
- set_credential(key: str, value: str) None[source]#
Stores a credential in the keyring under the specified key.
Method is used to securely store sensitive data such as Jamf URL, API Tokens, and API credentials such as client ID and client secret.
- Parameters:
- Raises:
CredentialError – If the specified credential could not be saved.
- Return type:
None
- delete_credential(key: str) bool[source]#
Deletes the provided credential in the keyring under the specified key. Primarily intended for use with the
--resetflag (Seereset()).If the specified credential could not be deleted, an error is logged.
- create_client(client: JamfClient, token: AccessToken) None[source]#
Stores a
JamfClientobject’s credentials in the keyring.This method is typically used during the setup process to save the credentials and token of a
JamfClientobject into the keyring for secure storage and later use.If any of the client credentials could not be saved, a
CredentialErroris raised via theset_credential()method.- Parameters:
client (
JamfClient) – TheJamfClientobject whose credentials will be stored.token (
AccessToken) – TheAccessTokenobject to save.
- Return type:
None