Skip to content

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

Closed
@joshuadavidthomas

Description

@joshuadavidthomas

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!"}
        )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions