Open
Conversation
Member
Author
|
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) |
Member
Author
|
@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. |
Member
Author
|
A couple updates:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.xormainbranch.An overview:
Using the HTTPX library gives us a few things:
authparameterThis library has been restructured so it could be easier to create your own
FarmClientclass using a different library/transport instead of HTTPX but still leverage theResourcehelper methods provided here.