-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
2.x changes #67
base: 1.x
Are you sure you want to change the base?
2.x changes #67
Conversation
I still need to update documentation and fix some linting errors caused by async -> sync code generation. Existing code should only need to change how the client is instantiated and authorized, all other resource methods should continue to behave as before. Before: from farmOS import farmOS
farm = farmOS(
hostname=FARMOS_HOSTNAME,
scope="farm_manager",
client_id="farm",
version=2,
)
farm.authorize(USERNAME, PASSWORD) After: from httpx_auth import OAuth2ResourceOwnerPasswordCredentials
from farmOS import FarmClient
auth = OAuth2ResourceOwnerPasswordCredentials(
token_url=f"{FARMOS_HOSTNAME}/oauth/token",
username=USERNAME,
password=PASSWORD,
client_id="farm",
scope="farm_manager",
)
farm = FarmClient(hostname=FARMOS_HOSTNAME, auth=auth) |
@symbioquine this async -> sync code generation is using the Curious what you think. I know we had talked about async maybe "isn't worth it" but this is a pretty easy add and includes both sync and async tests (with automation to make sure async->sync changes are committed). I do think async is overkill for most use-cases but its nice to make it available. |
This PR includes proposed (breaking) changes for a 2.x version of farmOS.py. Likely will not merge these changes here but into a new
2.x
ormain
branch.An overview:
Using the HTTPX library gives us a few things:
auth
parameterThis library has been restructured so it could be easier to create your own
FarmClient
class using a different library/transport instead of HTTPX but still leverage theResource
helper methods provided here.