Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Pass a model to the Classic and Pro API request methods as the return type. #52

Open
brysontyrrell opened this issue Jul 24, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@brysontyrrell
Copy link
Collaborator

Proposal

When using the classic_api_request and pro_api_request methods on the client directly users have to take the response and cast it to an SDK model themselves.

resp = jamf_client.classic_api_request(
    method="get",
    resource_path=f"computergroups/name/{group_name}"
)
group = ClassicComputerGroup(**resp.json()["computer_group"])

Both methods should optionally accept an SDK model as an optional response type. When set, the requests response object is not returned, but the method attempts to instantiate the provided model from the data.

group = jamf_client.classic_api_request(
    method="get",
    resource_path=f"computergroups/name/{group_name}",
    return_model=ClassicComputerGroup
)
@brysontyrrell brysontyrrell added the enhancement New feature or request label Jul 24, 2024
@brysontyrrell brysontyrrell self-assigned this Jul 24, 2024
@macserv
Copy link

macserv commented Nov 4, 2024

Makes sense. Would also be nice to make use of Generic/TypeVar in a few choice places (e.g., Page, Pagination).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants