generated from yanyongyu/python-poetry-template
-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
447 additions
and
260 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
MD013: false # line-length | ||
MD024: # no-duplicate-heading | ||
siblings_only: true | ||
MD033: false # no-inline-html | ||
MD046: false # code-block-style |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
<!-- markdownlint-disable MD033 MD041 --> | ||
|
||
# githubkit {: .hidden } | ||
|
||
<div align="center" markdown> | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,97 @@ | ||
# Develop a GitHub APP | ||
|
||
## Sync Example | ||
## Authenticating as an installation by repository name | ||
|
||
Authenticating as a installation by repository name: | ||
=== "Sync" | ||
|
||
```python | ||
from githubkit import GitHub, AppAuthStrategy | ||
from githubkit.versions.latest.models import Issue, Installation | ||
```python | ||
from githubkit import GitHub, AppAuthStrategy | ||
from githubkit.versions.latest.models import Installation, IssueComment | ||
|
||
github = GitHub( | ||
AppAuthStrategy("your_app_id", "your_private_key", "client_id", "client_secret") | ||
) | ||
github = GitHub( | ||
AppAuthStrategy("your_app_id", "your_private_key", "client_id", "client_secret") | ||
) | ||
|
||
resp = github.rest.apps.get_repo_installation("owner", "repo") | ||
repo_installation: Installation = resp.parsed_data | ||
resp = github.rest.apps.get_repo_installation("owner", "repo") | ||
repo_installation: Installation = resp.parsed_data | ||
|
||
installation_github = github.with_auth( | ||
github.auth.as_installation(repo_installation.id) | ||
) | ||
installation_github = github.with_auth( | ||
github.auth.as_installation(repo_installation.id) | ||
) | ||
|
||
# create a comment on an issue | ||
resp = installation_github.rest.issues.create_comment("owner", "repo", 1, body="Hello") | ||
issue: IssueComment = resp.parsed_data | ||
``` | ||
# create a comment on an issue | ||
resp = installation_github.rest.issues.create_comment("owner", "repo", 1, body="Hello") | ||
issue: IssueComment = resp.parsed_data | ||
``` | ||
|
||
Authenticating as a installation by username: | ||
=== "Async" | ||
|
||
```python | ||
from githubkit import GitHub, AppAuthStrategy | ||
from githubkit.versions.latest.models import Installation, IssueComment | ||
```python | ||
from githubkit import GitHub, AppAuthStrategy | ||
from githubkit.versions.latest.models import Installation, IssueComment | ||
|
||
github = GitHub( | ||
AppAuthStrategy("your_app_id", "your_private_key", "client_id", "client_secret") | ||
) | ||
github = GitHub( | ||
AppAuthStrategy("your_app_id", "your_private_key", "client_id", "client_secret") | ||
) | ||
|
||
resp = github.rest.apps.get_user_installation("username") | ||
user_installation: Installation = resp.parsed_data | ||
resp = await github.rest.apps.async_get_repo_installation("owner", "repo") | ||
repo_installation: Installation = resp.parsed_data | ||
|
||
installation_github = github.with_auth( | ||
github.auth.as_installation(user_installation.id) | ||
) | ||
installation_github = github.with_auth( | ||
github.auth.as_installation(repo_installation.id) | ||
) | ||
|
||
# create a comment on an issue | ||
resp = installation_github.rest.issues.create_comment("owner", "repo", 1, body="Hello") | ||
issue: IssueComment = resp.parsed_data | ||
``` | ||
# create a comment on an issue | ||
resp = await installation_github.rest.issues.async_create_comment( | ||
"owner", "repo", 1, body="Hello" | ||
) | ||
issue: IssueComment = resp.parsed_data | ||
``` | ||
|
||
## Async Example | ||
## Authenticating as an installation by username | ||
|
||
Authenticating as a installation by repository name: | ||
=== "Sync" | ||
|
||
```python | ||
from githubkit import GitHub, AppAuthStrategy | ||
from githubkit.versions.latest.models import Issue, Installation | ||
```python | ||
from githubkit import GitHub, AppAuthStrategy | ||
from githubkit.versions.latest.models import Installation, IssueComment | ||
|
||
github = GitHub( | ||
AppAuthStrategy("your_app_id", "your_private_key", "client_id", "client_secret") | ||
) | ||
github = GitHub( | ||
AppAuthStrategy("your_app_id", "your_private_key", "client_id", "client_secret") | ||
) | ||
|
||
resp = await github.rest.apps.async_get_repo_installation("owner", "repo") | ||
repo_installation: Installation = resp.parsed_data | ||
resp = github.rest.apps.get_user_installation("username") | ||
user_installation: Installation = resp.parsed_data | ||
|
||
installation_github = github.with_auth( | ||
github.auth.as_installation(repo_installation.id) | ||
) | ||
installation_github = github.with_auth( | ||
github.auth.as_installation(user_installation.id) | ||
) | ||
|
||
# create a comment on an issue | ||
resp = await installation_github.rest.issues.async_create_comment("owner", "repo", 1, body="Hello") | ||
issue: IssueComment = resp.parsed_data | ||
``` | ||
# create a comment on an issue | ||
resp = installation_github.rest.issues.create_comment("owner", "repo", 1, body="Hello") | ||
issue: IssueComment = resp.parsed_data | ||
``` | ||
|
||
Authenticating as a installation by username: | ||
=== "Async" | ||
|
||
```python | ||
from githubkit import GitHub, AppAuthStrategy | ||
from githubkit.versions.latest.models import Installation, IssueComment | ||
```python | ||
from githubkit import GitHub, AppAuthStrategy | ||
from githubkit.versions.latest.models import Installation, IssueComment | ||
|
||
github = GitHub( | ||
AppAuthStrategy("your_app_id", "your_private_key", "client_id", "client_secret") | ||
) | ||
github = GitHub( | ||
AppAuthStrategy("your_app_id", "your_private_key", "client_id", "client_secret") | ||
) | ||
|
||
resp = await github.rest.apps.async_get_user_installation("username") | ||
user_installation: Installation = resp.parsed_data | ||
resp = await github.rest.apps.async_get_user_installation("username") | ||
user_installation: Installation = resp.parsed_data | ||
|
||
installation_github = github.with_auth( | ||
github.auth.as_installation(user_installation.id) | ||
) | ||
installation_github = github.with_auth( | ||
github.auth.as_installation(user_installation.id) | ||
) | ||
|
||
# create a comment on an issue | ||
resp = await installation_github.rest.issues.async_create_comment("owner", "repo", 1, body="Hello") | ||
issue: IssueComment = resp.parsed_data | ||
``` | ||
# create a comment on an issue | ||
resp = await installation_github.rest.issues.async_create_comment( | ||
"owner", "repo", 1, body="Hello" | ||
) | ||
issue: IssueComment = resp.parsed_data | ||
``` |
This file contains 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
Oops, something went wrong.