Jamf Pro Client¶
- class JamfProClient(server: str, credentials: CredentialsProvider, port: int = 443, session_config: SessionConfig | None = None)¶
The base client class for interacting with the Jamf Pro APIs.
Classic API, Pro API, and JCDS2 clients are instantiated with the base client.
If the
aws
extra dependency is not installed the JCDS2 client will not be created.- Parameters:
server (str) – The hostname of the Jamf Pro server to connect to.
credentials (CredentialsProvider) – Accepts any credentials provider object to provide the username and password for initial authentication.
port (int) – The server port to connect over (defaults to 443).
session_config (SessionConfig) – Pass a SessionConfig to configure session options.
- classic_api_request(method: str, resource_path: str, data: str | ClassicApiModel | None = None, override_headers: dict | None = None) Response ¶
Perform a request to the Classic API.
- Parameters:
method (str) – The HTTP method. Allowed values (case-insensitive) are: GET, POST, PUT, and DELETE.
resource_path (str) – The path of the API being requested that comes after
JSSResource
.data (str | ClassicApiModel) – If the request is a
POST
orPUT
, the XML string orClassicApiModel
that is being sent.override_headers (Dict[str, str]) – A dictionary of key-value pairs that will be set as headers for the request. You cannot override the
Authorization
orContent-Type
headers.
- Returns:
Requests Response object
- Return type:
requests.Response
- pro_api_request(method: str, resource_path: str, query_params: Dict[str, str] | None = None, data: dict | BaseModel | None = None, override_headers: Dict[str, str] | None = None) Response ¶
Perform a request to the Pro API.
- Parameters:
method (str) – The HTTP method. Allowed values (case-insensitive) are: GET, POST, PUT, PATCH, and DELETE.
resource_path (str) – The path of the API being requested that comes after
api
. Include the API version at the beginning of the resource path.query_params (Dict[str, str]) – Query string parameters to be included with the request URL string.
data (dict | BaseModel) – If the request is a
POST
,PUT
, orPATCH
, the dictionary orBaseModel
that is being sent.override_headers (Dict[str, str]) – A dictionary of key-value pairs that will be set as headers for the request. You cannot override the
Authorization
orContent-Type
headers.
- Returns:
Requests Response object
- Return type:
requests.Response
- concurrent_api_requests(handler: Callable, arguments: Iterable[Any], return_model: Type[BaseModel] | None = None, max_concurrency: int | None = None, return_exceptions: bool | None = None) Iterator[Any | Exception] ¶
An interface for performing concurrent API operations.
- Parameters:
handler (Callable) – The method that will be called.
arguments (Iterable[Any]) – An iterable object containing the arguments to be passed to the
handler
. If the items within the iterable are dictionaries (dict
) they will be unpacked when passed. Use this to pass multiple arguments.return_model (BaseModel) – The Pydantic model that should be instantiated from the responses. The model will only be returned if the response from the
handler
is not also a model. If it is thereturn_model
is ignored. The response MUST be a JSON body for this option to succeed.max_concurrency (int) – An override the value for
session_config.max_concurrency
. Note: this override cannot be higher thansession_config.max_concurrency
.return_exceptions (bool) – If an exception is encountered by the
handler
the iterator will continue without a yield. Setting this toTrue
will return the exception object. If not set, the value forsession_config.return_exceptions
is used.
- Returns:
An iterator that will yield the result for each operation.
- Return type:
Iterator