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

Allow for passing an instance of the Installation model to API client #29

Closed
joshuadavidthomas opened this issue Nov 20, 2024 · 0 comments · Fixed by #30
Closed

Allow for passing an instance of the Installation model to API client #29

joshuadavidthomas opened this issue Nov 20, 2024 · 0 comments · Fixed by #30

Comments

@joshuadavidthomas
Copy link
Owner

joshuadavidthomas commented Nov 20, 2024

As opposed to requiring the installation ID, if you have a valid Installation you should be able to use it for authentication. It's a small thing, but I like the API of this.

Proposed:

async def create_comment(repo_full_name: str):
    installation = await Installation.objects.aget(repositories__full_name=repo_full_name)
    
    async with AsyncGitHubAPI(installation=installation) as gh:
        await gh.post(
            f"/repos/{repo_full_name}/issues/1/comments",
            data={"body": "Hello!"}
        )

Current:

async def create_comment(repo_full_name: str):
    installation = await Installation.objects.aget(repositories__full_name=repo_full_name)
    
    async with AsyncGitHubAPI(installation_id=installation.installation_id) as gh:
        await gh.post(
            f"/repos/{repo_full_name}/issues/1/comments",
            data={"body": "Hello!"}
        )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant