diff --git a/.changelog/0.2.0.yml b/.changelog/0.2.0.yml deleted file mode 100644 index 1b07f97..0000000 --- a/.changelog/0.2.0.yml +++ /dev/null @@ -1,49 +0,0 @@ -release_date: null -changes: -- type: fix - component: general - description: support verifying `X-Hub-Signature` (with `sha1`) additionally to `X-Hub-Signature-256`, - prefering the 256 header if available - fixes: [] -- type: breaking_change - component: general - description: move `Webhook` class into `github_bot_api.webhook` module - fixes: [] -- type: breaking_change - component: general - description: rename `App` class to `GithubApp` - fixes: [] -- type: breaking_change - component: general - description: rename `Webhook.on()` and `Webhook.register()` to `Webhook.listen()` - fixes: [] -- type: breaking_change - component: general - description: update `GithubApp` methods - fixes: [] -- type: breaking_change - component: general - description: '`RefreshableTokenSupplier` is now an abstract base class for new `JwtSupplier` - and `InstallationTokenProvider`' - fixes: [] -- type: breaking_change - component: general - description: removed `Tokeninfo.issued_at`, replaced `TokenInfo.expired_at` with - `TokenInfo.exp` (which is now an int) - fixes: [] -- type: breaking_change - component: general - description: move `get_mime_components()` into `github_bot_api.utils.mime` module - fixes: [] -- type: feature - component: general - description: add `github_bot_api.utils.types` module - fixes: [] -- type: fix - component: general - description: mark package as typed with `py.typed` file - fixes: [] -- type: breaking_change - component: general - description: rename `generate_token()` to `create_jwt()` - fixes: [] diff --git a/.changelog/0.3.0.yml b/.changelog/0.3.0.yml deleted file mode 100644 index b480ab5..0000000 --- a/.changelog/0.3.0.yml +++ /dev/null @@ -1,6 +0,0 @@ -release_date: '2020-11-25' -changes: -- type: breaking_change - component: general - description: add mandatory `user_agent` field to `GithubApp` - fixes: [] diff --git a/.changelog/0.3.1.yml b/.changelog/0.3.1.yml deleted file mode 100644 index 79441c2..0000000 --- a/.changelog/0.3.1.yml +++ /dev/null @@ -1,6 +0,0 @@ -release_date: '2020-11-25' -changes: -- type: fix - component: general - description: Fix missing github import in `GithubApp.client` and `GithubApp.installation_client()` - fixes: [] diff --git a/.changelog/0.3.3.yml b/.changelog/0.3.3.yml deleted file mode 100644 index 15f541e..0000000 --- a/.changelog/0.3.3.yml +++ /dev/null @@ -1,11 +0,0 @@ -changes: -- type: fix - component: general - description: '`RefreshableTokenSupplier` now inherits from `Supplier`' - fixes: [] -- type: fix - component: general - description: 'use `utf-8` encoding when decoding GitHub event message payload (@AaronKalair, - #2)' - fixes: [] -release_date: '2021-08-20' diff --git a/.changelog/0.4.0.yml b/.changelog/0.4.0.yml deleted file mode 100644 index f93df53..0000000 --- a/.changelog/0.4.0.yml +++ /dev/null @@ -1,6 +0,0 @@ -changes: -- type: feature - component: general - description: add `GithubClientSettings` class and accept a settings parameter in - `GithubApp.installation_client()` and the new `GithubApp.app_client()` method -release_date: '2021-11-18' diff --git a/.changelog/0.5.0.yml b/.changelog/0.5.0.yml deleted file mode 100644 index b53815a..0000000 --- a/.changelog/0.5.0.yml +++ /dev/null @@ -1,7 +0,0 @@ -changes: -- type: change - component: general - description: bump PyJWT dependency to `^2.0.0` - fixes: - - '#5' -release_date: '2021-12-12' diff --git a/.changelog/0.5.1.yml b/.changelog/0.5.1.yml deleted file mode 100644 index 89ebbc2..0000000 --- a/.changelog/0.5.1.yml +++ /dev/null @@ -1,8 +0,0 @@ -changes: -- type: fix - component: general - description: fix usage of PyJWT `encode()` since >= 2.0 returns a string instead - of bytes (@testworksau) - fixes: - - '#8' -release_date: '2021-12-20' diff --git a/.changelog/0.5.2.toml b/.changelog/0.5.2.toml deleted file mode 100644 index 967e566..0000000 --- a/.changelog/0.5.2.toml +++ /dev/null @@ -1,22 +0,0 @@ -release-date = "2023-03-15" - -[[entries]] -id = "64e49be4-0450-4e23-a8ce-416d5878224a" -type = "improvement" -description = "Update dependencies, particularly cryptography" -author = "@timgates42" -pr = "https://github.com/NiklasRosenstein/python-github-bot-api/pull/12" - -[[entries]] -id = "97aac093-5e0d-46c3-b276-ab7044018afe" -type = "fix" -description = "Change `GithubClientSettings.timeout` to an `Optional[int]` as the PyGithub API expects and integer for the respective argument to the `github.Github` constructor." -author = "@BoboTiG" -pr = "https://github.com/NiklasRosenstein/python-github-bot-api/pull/10" - -[[entries]] -id = "480eb51c-bcc9-404a-8fbc-0b7ccc7cfbc2" -type = "improvement" -description = "Bump `PyGithub` dependency to `^1.58`." -author = "@BoboTIiG" -pr = "https://github.com/NiklasRosenstein/python-github-bot-api/pull/10" diff --git a/.changelog/0.6.0.toml b/.changelog/0.6.0.toml deleted file mode 100644 index 5d23ef7..0000000 --- a/.changelog/0.6.0.toml +++ /dev/null @@ -1,13 +0,0 @@ -release-date = "2024-04-04" - -[[entries]] -id = "7647ac05-5c89-4b55-a03e-58a96fea2797" -type = "hygiene" -description = "Remove dependency on `nr.functional`" -author = "@NiklasRosenstein" - -[[entries]] -id = "87fbb576-b5fe-446d-8b37-78c233c45d2a" -type = "breaking change" -description = "Remove deprecated `GithubApp.client` (use `GithubApp.app_client()` instead)" -author = "@NiklasRosenstein" diff --git a/.changelog/0.7.0.toml b/.changelog/0.7.0.toml deleted file mode 100644 index 7fab5ab..0000000 --- a/.changelog/0.7.0.toml +++ /dev/null @@ -1,13 +0,0 @@ -release-date = "2025-01-03" - -[[entries]] -id = "6da27e0d-688c-49f7-afd2-d12afe329316" -type = "breaking change" -description = "Drop Python 3.8 support." -author = "@NiklasRosenstein" - -[[entries]] -id = "a1dc4bde-24c9-452a-a4c8-87fe2ecd85fc" -type = "hygiene" -description = "Migrate project from Poetry to UV" -author = "@NiklasRosenstein" diff --git a/.changelog/0.7.1.toml b/.changelog/0.7.1.toml deleted file mode 100644 index 50a501e..0000000 --- a/.changelog/0.7.1.toml +++ /dev/null @@ -1,26 +0,0 @@ -release-date = "2026-02-16" - -[[entries]] -id = "afe1b9c3-a4d9-4f33-9587-ae430f672646" -type = "deprecation" -description = "Rename `GithubApp.get_installation_token_supplier()` to `.installation_token_supplier()` for consistency" -author = "@NiklasRosenstein" - -[[entries]] -id = "1e882ab7-ae70-44ac-a58f-de8e7829f696" -type = "fix" -description = "Hide `GithubApp.private_key` from `repr()`" -author = "@NiklasRosenstein" - -[[entries]] -id = "dd92343b-4e35-4d03-9990-82189fba8aad" -type = "feature" -description = "Add API for initiating OAuth2 Web application and Device flows" -author = "@NiklasRosenstein" - -[[entries]] -id = "d62bf2e4-15e4-4989-933f-f8ac4bb68eed" -type = "fix" -description = "Ensure `iss` claim is a string" -author = "@tun0" -pr = "https://github.com/NiklasRosenstein/python-github-bot-api/issues/26" diff --git a/.changelog/0.7.10.toml b/.changelog/0.7.10.toml deleted file mode 100644 index dec3c4a..0000000 --- a/.changelog/0.7.10.toml +++ /dev/null @@ -1,7 +0,0 @@ -release-date = "2026-06-18" - -[[entries]] -id = "194fd6f3-557d-49c0-9677-c35aa4eff014" -type = "chore" -description = "chore(deps): update dependency pyjwt to v2.13.0 [security] (#35)" -author = "@renovate[bot]" diff --git a/.changelog/0.7.2.toml b/.changelog/0.7.2.toml deleted file mode 100644 index 4fac491..0000000 --- a/.changelog/0.7.2.toml +++ /dev/null @@ -1,7 +0,0 @@ -release-date = "2026-03-15" - -[[entries]] -id = "a2dac636-647f-464d-9ff6-b0130a1a3c1a" -type = "chore" -description = "chore: automate security updates and releases (#28)" -author = "@renovate[bot]" diff --git a/.changelog/0.7.3.toml b/.changelog/0.7.3.toml deleted file mode 100644 index 6455f7e..0000000 --- a/.changelog/0.7.3.toml +++ /dev/null @@ -1,7 +0,0 @@ -release-date = "2026-03-15" - -[[entries]] -id = "43f387c0-005e-4c24-a232-1da9568fa6ff" -type = "chore" -description = "chore(deps): update dependency pymdown-extensions to v10.16.1 [security] (#25)" -author = "@renovate[bot]" diff --git a/.changelog/0.7.4.toml b/.changelog/0.7.4.toml deleted file mode 100644 index 40c955c..0000000 --- a/.changelog/0.7.4.toml +++ /dev/null @@ -1,7 +0,0 @@ -release-date = "2026-03-15" - -[[entries]] -id = "841e1fde-77ad-4d75-ae6c-503957feeaec" -type = "chore" -description = "chore(deps): update dependency pyjwt to v2.12.0 [security] (#27); chore(deps): update dependency requests to v2.32.4 [security] (#24)" -author = "@renovate[bot]" diff --git a/.changelog/0.7.5.toml b/.changelog/0.7.5.toml deleted file mode 100644 index e8c564e..0000000 --- a/.changelog/0.7.5.toml +++ /dev/null @@ -1,7 +0,0 @@ -release-date = "2026-03-15" - -[[entries]] -id = "f040de4d-62ee-4bb3-9363-cc7fac6fcebc" -type = "chore" -description = "chore(deps): update dependency black to v26 [security] (#29)" -author = "@renovate[bot]" diff --git a/.changelog/0.7.6.toml b/.changelog/0.7.6.toml deleted file mode 100644 index a96d218..0000000 --- a/.changelog/0.7.6.toml +++ /dev/null @@ -1,7 +0,0 @@ -release-date = "2026-03-26" - -[[entries]] -id = "e665ed81-e736-46bb-a89a-ecf9dba2c1ae" -type = "chore" -description = "chore(deps): update dependency requests to v2.33.0 [security] (#30)" -author = "@renovate[bot]" diff --git a/.changelog/0.7.7.toml b/.changelog/0.7.7.toml deleted file mode 100644 index 57e2277..0000000 --- a/.changelog/0.7.7.toml +++ /dev/null @@ -1,7 +0,0 @@ -release-date = "2026-04-11" - -[[entries]] -id = "c2465817-8366-4606-8893-f12596b74c75" -type = "chore" -description = "Fix tag filter pattern in release.yml: glob syntax, not regex (#31)" -author = "@renovate[bot]" diff --git a/.changelog/0.7.8.toml b/.changelog/0.7.8.toml deleted file mode 100644 index d229891..0000000 --- a/.changelog/0.7.8.toml +++ /dev/null @@ -1,7 +0,0 @@ -release-date = "2026-05-13" - -[[entries]] -id = "fb95643d-ce72-4bed-b0e0-a48105d2b832" -type = "chore" -description = "chore(deps): update dependency urllib3 to v2.7.0 [security] (#33)" -author = "@renovate[bot]" diff --git a/.changelog/0.7.9.toml b/.changelog/0.7.9.toml deleted file mode 100644 index ab70395..0000000 --- a/.changelog/0.7.9.toml +++ /dev/null @@ -1,7 +0,0 @@ -release-date = "2026-05-21" - -[[entries]] -id = "b9900daf-a9b3-4e9a-9802-ddd923824210" -type = "chore" -description = "chore(deps): update dependency pymdown-extensions to v10.21.3 [security] (#34)" -author = "@renovate[bot]" diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 82c5360..0000000 --- a/.flake8 +++ /dev/null @@ -1,10 +0,0 @@ -[flake8] -max-line-length = 120 -# Black can yield formatted code that triggers these Flake8 warnings. -ignore= - # line break before binary operator - W503, - # line break after binary operator - W504, - # multiple statements on one line (def) - E704, diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml deleted file mode 100644 index 772d5c8..0000000 --- a/.github/workflows/auto-release.yml +++ /dev/null @@ -1,137 +0,0 @@ -name: Auto Release - -# Trigger after the Python CI workflow completes successfully on develop. -# This ensures we never tag a release from a broken commit. -on: - workflow_run: - workflows: ["Python"] - types: - - completed - branches: - - develop - -jobs: - auto-release: - name: Bump version and tag release - runs-on: ubuntu-latest - # Only proceed when CI passed - if: github.event.workflow_run.conclusion == 'success' - permissions: - contents: write - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - # Use a PAT so the tag push can trigger release.yml - # (pushes with GITHUB_TOKEN do not trigger further workflows) - token: ${{ secrets.RELEASE_TOKEN || secrets.GITHUB_TOKEN }} - - - name: Read current version - id: ver - run: | - VERSION=$(grep '^version = ' pyproject.toml | cut -d'"' -f2) - echo "version=$VERSION" >> "$GITHUB_OUTPUT" - echo "Current version: $VERSION" - - - name: Check whether version is already tagged - id: tag_check - run: | - if git tag --list | grep -qx "${{ steps.ver.outputs.version }}"; then - echo "tagged=true" >> "$GITHUB_OUTPUT" - else - echo "tagged=false" >> "$GITHUB_OUTPUT" - fi - - # ── Path A: version already tagged → check for unreleased commits ────── - - - name: Count commits since last tag - id: commits - if: steps.tag_check.outputs.tagged == 'true' - run: | - LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") - if [ -z "$LATEST_TAG" ]; then - echo "count=0" >> "$GITHUB_OUTPUT" - else - COUNT=$(git log "$LATEST_TAG..HEAD" --oneline | wc -l) - echo "count=$COUNT" >> "$GITHUB_OUTPUT" - echo "Commits since $LATEST_TAG: $COUNT" - fi - - - name: Bump patch version - id: bump - if: steps.tag_check.outputs.tagged == 'true' && steps.commits.outputs.count > 0 - run: | - CUR="${{ steps.ver.outputs.version }}" - MAJOR=$(echo "$CUR" | cut -d. -f1) - MINOR=$(echo "$CUR" | cut -d. -f2) - PATCH=$(echo "$CUR" | cut -d. -f3) - NEW="$MAJOR.$MINOR.$((PATCH + 1))" - echo "new_version=$NEW" >> "$GITHUB_OUTPUT" - echo "Bumping $CUR → $NEW" - sed -i "s/^version = \"$CUR\"/version = \"$NEW\"/" pyproject.toml - sed -i "s/^__version__ = \"$CUR\"/__version__ = \"$NEW\"/" src/github_bot_api/__init__.py - - - name: Create changelog entry - if: steps.tag_check.outputs.tagged == 'true' && steps.commits.outputs.count > 0 - run: | - NEW="${{ steps.bump.outputs.new_version }}" - LATEST_TAG=$(git describe --tags --abbrev=0) - TODAY=$(date +%Y-%m-%d) - UUID=$(python3 -c "import uuid; print(uuid.uuid4())") - # Collect PR/commit subjects for the description - DESCRIPTION=$(git log "$LATEST_TAG..HEAD" --pretty=format:"%s" \ - | grep -v '^\[auto-release\]' | head -10 \ - | python3 -c " - import sys, json - lines = [l.strip() for l in sys.stdin if l.strip()] - print('; '.join(lines) if lines else 'Automated dependency updates') - ") - cat > ".changelog/$NEW.toml" << EOF - release-date = "$TODAY" - - [[entries]] - id = "$UUID" - type = "chore" - description = "$DESCRIPTION" - author = "@renovate[bot]" - EOF - echo "Created .changelog/$NEW.toml" - - - name: Commit version bump and tag - if: steps.tag_check.outputs.tagged == 'true' && steps.commits.outputs.count > 0 - run: | - NEW="${{ steps.bump.outputs.new_version }}" - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - git add pyproject.toml src/github_bot_api/__init__.py ".changelog/$NEW.toml" - git commit -m "chore: bump version to $NEW [auto-release]" - git push origin develop - git tag "$NEW" -m "Release $NEW" - git push origin "$NEW" - echo "Pushed tag $NEW — release.yml will publish to PyPI" - - # ── Path B: version bumped manually in a PR, not yet tagged ──────────── - - - name: Verify changelog exists for manual version bump - if: steps.tag_check.outputs.tagged == 'false' - id: changelog_check - run: | - VERSION="${{ steps.ver.outputs.version }}" - if [ -f ".changelog/$VERSION.toml" ]; then - echo "exists=true" >> "$GITHUB_OUTPUT" - echo "Changelog entry found for $VERSION" - else - echo "exists=false" >> "$GITHUB_OUTPUT" - echo "No changelog entry at .changelog/$VERSION.toml — skipping release" - fi - - - name: Tag manually-bumped version - if: steps.tag_check.outputs.tagged == 'false' && steps.changelog_check.outputs.exists == 'true' - run: | - VERSION="${{ steps.ver.outputs.version }}" - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - git tag "$VERSION" -m "Release $VERSION" - git push origin "$VERSION" - echo "Pushed tag $VERSION — release.yml will publish to PyPI" diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml deleted file mode 100644 index ff4e5b2..0000000 --- a/.github/workflows/python.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Python - -on: - push: - branches: [ develop ] - pull_request: - branches: [ develop ] - -jobs: - test: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - python-version: [ "3.10", "3.11", "3.12", "3.13" ] - steps: - - uses: actions/checkout@v4 - - uses: astral-sh/setup-uv@v5 - with: - version: "0.5.14" - python-version: "${{ matrix.python-version }}" - - uses: actions/setup-python@v5 - with: - python-version: "${{ matrix.python-version }}" - - run: uv sync --all-extras --dev - - run: uvx --python-preference=only-managed --from slap-cli slap test - - documentation: - runs-on: ubuntu-latest - if: github.ref == 'refs/heads/develop' - steps: - - uses: actions/checkout@v4 - - uses: astral-sh/setup-uv@v5 - with: - version: "0.5.14" - - run: uvx --from slap-cli slap changelog format --markdown --all > docs/content/changelog.md - - run: cd docs && uv run mkdocs build --site-dir _site - - uses: JamesIves/github-pages-deploy-action@v4.7.2 - with: - branch: gh-pages - folder: docs/_site - ssh-key: ${{ secrets.DEPLOY_KEY }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 413dd0a..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,155 +0,0 @@ -name: Release - -on: - push: - tags: - - '[0-9]*.[0-9]*.[0-9]*' - -permissions: - contents: write - id-token: write - -jobs: - validate: - name: Validate version - runs-on: ubuntu-latest - outputs: - version: ${{ steps.extract.outputs.version }} - steps: - - uses: actions/checkout@v4 - - - name: Extract version from tag - id: extract - run: | - TAG_NAME="${GITHUB_REF#refs/tags/}" - echo "version=$TAG_NAME" >> $GITHUB_OUTPUT - echo "Extracted version: $TAG_NAME" - - - name: Validate pyproject.toml version - run: | - VERSION="${{ steps.extract.outputs.version }}" - PYPROJECT_VERSION=$(grep '^version = ' pyproject.toml | cut -d'"' -f2) - echo "Tag version: $VERSION" - echo "pyproject.toml version: $PYPROJECT_VERSION" - if [ "$VERSION" != "$PYPROJECT_VERSION" ]; then - echo "Error: Version mismatch between tag ($VERSION) and pyproject.toml ($PYPROJECT_VERSION)" - exit 1 - fi - echo "✓ pyproject.toml version matches tag" - - - name: Validate __init__.py version - run: | - VERSION="${{ steps.extract.outputs.version }}" - INIT_VERSION=$(grep '^__version__ = ' src/github_bot_api/__init__.py | cut -d'"' -f2) - echo "Tag version: $VERSION" - echo "__init__.py version: $INIT_VERSION" - if [ "$VERSION" != "$INIT_VERSION" ]; then - echo "Error: Version mismatch between tag ($VERSION) and __init__.py ($INIT_VERSION)" - exit 1 - fi - echo "✓ __init__.py version matches tag" - - - name: Validate changelog exists - run: | - VERSION="${{ steps.extract.outputs.version }}" - CHANGELOG_FILE=".changelog/$VERSION.toml" - if [ ! -f "$CHANGELOG_FILE" ]; then - echo "Error: Changelog file $CHANGELOG_FILE does not exist" - exit 1 - fi - echo "✓ Changelog file exists: $CHANGELOG_FILE" - - build: - name: Build package - runs-on: ubuntu-latest - needs: validate - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-python@v5 - with: - python-version: "3.10" - - - name: Install build tool - run: pip install build - - - name: Build package - run: python -m build - - - name: Verify build artifacts - run: | - VERSION="${{ needs.validate.outputs.version }}" - WHEEL="dist/github_bot_api-$VERSION-py3-none-any.whl" - SDIST="dist/github_bot_api-$VERSION.tar.gz" - - if [ ! -f "$WHEEL" ]; then - echo "Error: Wheel file not found: $WHEEL" - exit 1 - fi - echo "✓ Wheel built: $WHEEL" - - if [ ! -f "$SDIST" ]; then - echo "Error: Source distribution not found: $SDIST" - exit 1 - fi - echo "✓ Source distribution built: $SDIST" - - ls -lh dist/ - - - name: Upload build artifacts - uses: actions/upload-artifact@v4 - with: - name: dist - path: dist/ - - publish: - name: Publish to PyPI - runs-on: ubuntu-latest - needs: build - environment: release - steps: - - name: Download build artifacts - uses: actions/download-artifact@v4 - with: - name: dist - path: dist/ - - - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - print-hash: true - - create-release: - name: Create GitHub Release - runs-on: ubuntu-latest - needs: [validate, publish] - steps: - - uses: actions/checkout@v4 - - - uses: astral-sh/setup-uv@v5 - with: - version: "0.5.14" - - - name: Generate changelog - id: changelog - run: | - VERSION="${{ needs.validate.outputs.version }}" - echo "Generating changelog for version $VERSION" - uvx --from slap-cli slap changelog format --markdown "$VERSION" > changelog.md - cat changelog.md - - - name: Download build artifacts - uses: actions/download-artifact@v4 - with: - name: dist - path: dist/ - - - name: Create GitHub Release - uses: softprops/action-gh-release@v2 - with: - name: Release ${{ needs.validate.outputs.version }} - body_path: changelog.md - files: | - dist/*.whl - dist/*.tar.gz - fail_on_unmatched_files: true diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 109a30e..0000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.dmypy.json -*.pyc diff --git a/404.html b/404.html new file mode 100644 index 0000000..11cfe12 --- /dev/null +++ b/404.html @@ -0,0 +1,473 @@ + + + +
+ + + + + + + + + + + + + + + github_bot_api
+
+
+ Event
+
+
+
+ dataclass
+
+
+Represents a GitHub webhook event.
+ +github_bot_api/event.py delivery_id
+
+
+
+ instance-attribute
+
+
+The delivery ID of the event.
+ name
+
+
+
+ instance-attribute
+
+
+The name of the event. Could be pull_request, for example.
payload
+
+
+
+ instance-attribute
+
+
+The event payload.
+ signature
+
+
+
+ instance-attribute
+
+
+The signature of the event. Will only be set if a Webhook-secret is configured on the
+client side (e.g. in Webhook.secret / if the webhook_secret parameter is
+passed to accept_event()).
GithubApp
+
+
+
+ dataclass
+
+
+Represents a GitHub application and all the required details.
+ +github_bot_api/app.py67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 | |
app_id
+
+
+
+ instance-attribute
+
+
+GitHub Application ID.
+ client_id
+
+
+
+ class-attribute
+ instance-attribute
+
+
+The GitHub App's OAuth client ID. This is required for OAuth2 authorization URL generation. Can be omitted +if the app does not use OAuth2.
+ client_secret
+
+
+
+ class-attribute
+ instance-attribute
+
+
+The GitHub App's OAuth client secret. This is required for OAuth2 authorization URL generation. Can be omitted +if the app does not use OAuth2. Note that this must be specified if #client_id is specified.
+ jwt
+
+
+
+ property
+
+
+Returns the JWT for your GitHub application. The JWT is the token to use with GitHub application APIs.
+ jwt_supplier
+
+
+
+ property
+
+
+Returns a new #JwtSupplier that is used for generating JWT tokens for your GitHub application.
+ private_key
+
+
+
+ class-attribute
+ instance-attribute
+
+
+RSA private key to sign the JWT with.
+ redirect_uri
+
+
+
+ class-attribute
+ instance-attribute
+
+
+The GitHub App's OAuth redirect URI. This is required for OAuth2 authorization URL generation. Can be omitted +if the app does not use OAuth2. This field is optional, but required for the web authorization flow with
+ user_agent
+
+
+
+ instance-attribute
+
+
+User agent of the application. This will be respected in #get_user_agent().
+ v3_api_url
+
+
+
+ class-attribute
+ instance-attribute
+
+
+GitHub API base URL. Defaults to the public GitHub API.
+ app_client
+
+
+app_client(
+ settings: Union[
+ GithubClientSettings, Dict[str, Any], None
+ ] = None,
+) -> Github
+Returns a PyGithub client for your GitHub application.
+Note that the client's token will expire after 10 minutes and you will have to create a new client or update the +client's token with the value returned by #jwt. It is recommended that you create a new client for each atomic +operation you perform.
+This requires you to install PyGithub>=1.58.
github_bot_api/app.py get_user_agent
+
+
+Create a user agent string for the PyGithub client, including the installation if specified.
+ +github_bot_api/app.py installation_client
+
+
+installation_client(
+ installation_id: int,
+ settings: Union[
+ GithubClientSettings, Dict[str, Any], None
+ ] = None,
+) -> Github
+Returns a PyGithub client for your GitHub application to act in the scope of the given installation_id.
+Note that the client's token will expire after 10 minutes and you will have to create a new client or update the +client's token with the value returned by #jwt. It is recommended that you create a new client for each atomic +operation you perform.
+This requires you to install PyGithub>=1.58.
github_bot_api/app.py installation_token
+
+
+A short-hand to retrieve a new installation token for the given installation_id.
+ +github_bot_api/app.py installation_token_supplier
+
+
+Create an #InstallationTokenSupplier for your GitHub application to act within the scope of the given +installation_id.
+ +github_bot_api/app.py oauth2_access_token
+
+
+oauth2_access_token(
+ *,
+ code: Optional[str] = None,
+ device_code: Optional[str] = None
+) -> Optional[OAuth2TokenInfo]
+Makes a request to GitHub to exchange an OAuth2 code for an access token.
+Important: You must provide the correct code or device_code parameter, but not both.
Documentation: https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-a-user-access-token-for-a-github-app#generating-a-user-access-token-when-a-user-installs-your-app
+Returns None if the token is not yet available (in the case of the device flow). Otherwise, returns a
+github_bot_api/app.py oauth2_device_flow
+
+
+Makes a request to GitHub to request a device code for the OAuth2 device flow.
+Prerequisites:
+client_id when constructing the #GithubApp instance.Documentation: https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-a-user-access-token-for-a-github-app#using-the-device-flow-to-generate-a-user-access-token
+ +github_bot_api/app.py oauth2_web_application_flow_url
+
+
+Returns the URL for a user to begin the OAuth2 web authorization flow.
+Preconditions:
+- You must have provided a client_id when constructing the #GithubApp instance.
Documentation: https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-a-user-access-token-for-a-github-app#using-the-web-application-flow-to-generate-a-user-access-token
+ +github_bot_api/app.py Webhook
+
+
+
+ dataclass
+
+
+Represents a GitHub webhook that listens on an HTTP endpoint for events. Event handlers can be +registered using the #@on() decorator or #register() method.
+ +github_bot_api/webhook.py dispatch
+
+
+dispatch(event: Event) -> bool
+Dispatch an event on the first handler that matches it.
+Returns #True only if the event was handled by a handler.
+ +github_bot_api/webhook.py accept_event
+
+
+accept_event(
+ headers: Mapping[str, str],
+ raw_body: bytes,
+ webhook_secret: Optional[str] = None,
+) -> Event
+Converts thee HTTP headers and the raw_body to an #Event object.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
headers |
+
+ Mapping[str, str]
+ |
+
+
+
+ The HTTP headers. Must have |
+ + required + | +
raw_body |
+
+ bytes
+ |
+
+
+
+ The raw request body for the event. This is converted into a JSON payload. + |
+ + required + | +
webhook_secret |
+
+ Optional[str]
+ |
+
+
+
+ If specified, the |
+
+ None
+ |
+
github_bot_api/event.py github_bot_api.flask
+
+
+Flask binding for handling GitHub webhook events.
+Note that you need to install the flask module separately.
from github_bot_api import Event, Webhook
+from github_bot_api.flask import create_flask_app
+
+def on_any_event(event: Event) -> bool:
+ print(event)
+ return True
+
+webhook = Webhook(secret=None)
+webhook.listen('*', on_any_event)
+
+import os; os.environ['FLASK_ENV'] = 'development'
+flask_app = create_flask_app(__name__, webhook)
+flask_app.run()
+ create_event_handler
+
+
+create_event_handler(
+ webhook: Webhook,
+) -> Callable[[], Tuple[Text, int, Dict[str, str]]]
+Creates an event handler flask view that interprets the received HTTP request as a GitHub application +event and dispatches it via #webhook.dispatch().
+ +github_bot_api/flask.py create_flask_app
+
+
+create_flask_app(
+ name: str,
+ webhook: Webhook,
+ path: str = "/event-handler",
+) -> Flask
+Creates a new #flask.Flask application with a POST event handler under the given path (defaulting
+to /event-handler). This is a useful shorthand to attach your #Webhook to an HTTP server.
github_bot_api/flask.py