### GhApi CLI: Get Git Reference Example Source: https://ghapi.fast.ai/cli Demonstrates how to use the `ghapi` command-line tool to retrieve a Git reference. It shows how to specify the owner, repository, and reference name as arguments. The example assumes it's being run in a Jupyter Notebook environment due to the '!' prefix. ```Bash ! ghapi git.get_ref fastai ghapi-test --ref heads/master ``` -------------------------------- ### Get Repository Installation Source: https://ghapi.fast.ai/fullapi Retrieves the installation for a specific repository using 'owner' and 'repo' parameters. ```Python from ghapi.all import * app.get_repo_installation(owner, repo) ``` -------------------------------- ### GitHub Apps: Get User Installation Source: https://ghapi.fast.ai/fullapi Retrieves the installation for a given username for the authenticated app. Requires username. ```python from ghapi.all import * # Get a user installation for the authenticated app # Requires username # Example: # print(apps.get_user_installation(username='octocat')) ``` -------------------------------- ### GitHub Apps: List Installations Source: https://ghapi.fast.ai/fullapi Lists all installations accessible to the authenticated user's access token. Requires pagination parameters. ```python from ghapi.all import * # List app installations accessible to the user access token # Requires per_page and page parameters # Example: # print(apps.list_installations_for_authenticated_user(per_page=100, page=1)) ``` -------------------------------- ### Install ghapi using pip Source: https://ghapi.fast.ai/index Installs the ghapi library using pip, a package installer for Python. This command fetches and installs the latest version of ghapi and its dependencies. ```Shell pip install ghapi ``` -------------------------------- ### Start Repository Import Source: https://ghapi.fast.ai/fullapi Starts a new repository import. Requires owner, repository name, and VCS URL. Optional parameters for VCS type and credentials. ```rest POST /repos/{owner}/{repo}/import ``` -------------------------------- ### Get GhApi CLI Help for an Operation Source: https://ghapi.fast.ai/index Demonstrates how to get help information for a specific GhApi command-line operation, including its parameters and a link to the official GitHub API documentation. ```Bash ghapi git.get_ref --help ``` -------------------------------- ### Create Installation Access Token Source: https://ghapi.fast.ai/fullapi Creates an installation access token for a GitHub App. Requires 'installation_id' and optionally 'repositories', 'repository_ids', and 'permissions'. ```Python from ghapi.all import * app.create_installation_access_token(installation_id, repositories, repository_ids, permissions) ``` -------------------------------- ### GitHub Apps: List Installation Repositories Source: https://ghapi.fast.ai/fullapi Lists repositories accessible to the authenticated user's access token for a specific installation. Requires installation_id and pagination parameters. ```python from ghapi.all import * # List repositories accessible to the user access token for a given installation # Requires installation_id, per_page, and page parameters # Example: # print(apps.list_installation_repos_for_authenticated_user(installation_id=123, per_page=100, page=1)) ``` -------------------------------- ### List Repos Accessible to Installation Source: https://ghapi.fast.ai/fullapi Lists repositories accessible to a GitHub App installation. Supports pagination with 'per_page' and 'page' parameters. ```Python from ghapi.all import * app.list_repos_accessible_to_installation(per_page, page) ``` -------------------------------- ### Install ghapi using conda Source: https://ghapi.fast.ai/index Installs the ghapi library using conda, a package and environment management system. This command installs ghapi from the fastai channel. ```Shell conda install -c fastai ghapi ``` -------------------------------- ### GhApi CLI: Get Git Reference Help Source: https://ghapi.fast.ai/cli Shows how to get help for the `git.get_ref` operation using the `ghapi` command-line tool. This command lists all parameters accepted by the `git.get_ref` function and provides a link to the official GitHub documentation. ```Bash ! ghapi git.get_ref --help ``` -------------------------------- ### Start User Migration Source: https://ghapi.fast.ai/fullapi Starts a new migration for the authenticated user. Allows configuration of repository inclusion, locking, and exclusion of specific data types. ```rest POST /user/migrations ``` -------------------------------- ### Get Organization Installation Source: https://ghapi.fast.ai/fullapi Retrieves the installation for a specific organization using the 'org' parameter. ```Python from ghapi.all import * app.get_org_installation(org) ``` -------------------------------- ### Get Git Reference Source: https://ghapi.fast.ai/index Provides an example of how to call a specific API endpoint, 'git.get_ref', to retrieve information about a Git reference. It shows the method signature and an example of its usage. ```Python api.git.get_ref(owner='fastai', repo='fastcore', ref='heads/master') ``` -------------------------------- ### List App Installations Source: https://ghapi.fast.ai/fullapi Lists installations for the authenticated GitHub App. Supports pagination and filtering with 'per_page', 'page', 'since', and 'outdated' parameters. ```Python from ghapi.all import * app.list_installations(per_page, page, since, outdated) ``` -------------------------------- ### Start Organization Migration Source: https://ghapi.fast.ai/fullapi Starts a new migration for an organization. Allows configuration of repository inclusion, locking, and exclusion of specific data types. Requires organization name and repository details. ```rest POST /orgs/{org}/migrations ``` -------------------------------- ### Get Specific App Installation Source: https://ghapi.fast.ai/fullapi Retrieves a specific installation for the authenticated GitHub App using its 'installation_id'. ```Python from ghapi.all import * app.get_installation(installation_id) ``` -------------------------------- ### GitHub Codespaces: Start Codespace Source: https://ghapi.fast.ai/fullapi Starts a stopped codespace for the authenticated user. Requires the codespace name. ```python from ghapi.all import gh_api # Start a codespace for the authenticated user codespace_name = "your_codespace_name" gh_api("codespaces.start_for_authenticated_user", codespace_name=codespace_name) print("Codespace started successfully.") ``` -------------------------------- ### GitHub Apps: Add Repository to Installation Source: https://ghapi.fast.ai/fullapi Adds a specified repository to an app installation. Requires installation_id and repository_id. ```python from ghapi.all import * # Add a repository to an app installation # Requires installation_id and repository_id # Example: # print(apps.add_repo_to_installation_for_authenticated_user(installation_id=123, repository_id=456)) ``` -------------------------------- ### List App Installations for GitHub Organization Source: https://ghapi.fast.ai/fullapi Lists all GitHub App installations associated with a specific organization. Supports pagination. ```python gh.orgs.list_app_installations(org='my-organization', per_page=10, page=1) ``` -------------------------------- ### Get or Create GitHub OAuth Authorization for App and Fingerprint Source: https://ghapi.fast.ai/fullapi Retrieves an existing authorization for a specific app and fingerprint, or creates a new one. Requires client ID, fingerprint, client secret, and scopes. Useful for managing multiple installations of the same app. ```Python from ghapi.all import GhApi api = GhApi() # Get or create authorization for app and fingerprint app_fingerprint_auth = api.oauth_authorizations.get_or_create_authorization_for_app_and_fingerprint( client_id='YOUR_CLIENT_ID', fingerprint='YOUR_FINGERPRINT', client_secret='YOUR_CLIENT_SECRET', scopes=['repo'] ) print(f"App fingerprint authorization: {app_fingerprint_auth}") ``` -------------------------------- ### Get or Create GitHub OAuth Authorization for App Source: https://ghapi.fast.ai/fullapi Retrieves an existing authorization for a specific app or creates a new one if it doesn't exist. Requires client ID, client secret, and desired scopes. Useful for app installations. ```Python from ghapi.all import GhApi api = GhApi() # Get or create authorization for a specific app app_auth = api.oauth_authorizations.get_or_create_authorization_for_app( client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET', scopes=['repo'] ) print(f"App authorization: {app_auth}") ``` -------------------------------- ### Unsuspend App Installation Source: https://ghapi.fast.ai/fullapi Unsuspends a GitHub App installation using its 'installation_id'. ```Python from ghapi.all import * app.unsuspend_installation(installation_id) ``` -------------------------------- ### Initialize GhApi Source: https://ghapi.fast.ai/core Demonstrates how to create an instance of the GhApi class. This is the first step before making any API calls. It can be initialized with optional parameters like owner, repo, token, and host. ```Python api = GhApi() ``` -------------------------------- ### Get App by Slug Source: https://ghapi.fast.ai/fullapi Retrieves a GitHub App using its 'app_slug'. ```Python from ghapi.all import * app.get_by_slug(app_slug) ``` -------------------------------- ### GhApi CLI: Create Release Help Source: https://ghapi.fast.ai/cli Demonstrates how to access the help information for the `create_release` command in the GhApi CLI. This displays the function signature and its parameters, including default values. ```Bash ! ghapi create_release --help ``` -------------------------------- ### Get Subscription Plan for Account Source: https://ghapi.fast.ai/fullapi Retrieves the subscription plan for a given 'account_id'. ```Python from ghapi.all import * app.get_subscription_plan_for_account(account_id) ``` -------------------------------- ### GitHub API: Get All Repository Topics Source: https://ghapi.fast.ai/fullapi Retrieves all topics associated with a repository. Supports pagination. ```Python gh.repos.get_all_topics(owner, repo, page, per_page) ``` -------------------------------- ### Initialize GhApi with Defaults Source: https://ghapi.fast.ai/core Illustrates initializing GhApi with default `owner`, `repo`, and `token` parameters. These defaults are automatically applied to subsequent API calls. ```python api = GhApi(owner='fastai', repo='ghapi-test', token=token) ``` -------------------------------- ### Call GitHub API Endpoint: Get Reference Source: https://ghapi.fast.ai/core Shows an example of calling the `get_ref` endpoint to retrieve a Git reference, specifically the 'heads/master' branch. It then asserts that the object type is 'commit'. ```Python ref = api.git.get_ref('heads/master') test_eq(ref.object.type, 'commit') ``` -------------------------------- ### Get SCIM Provisioning Information for Enterprise User Source: https://ghapi.fast.ai/fullapi Retrieves SCIM provisioning information for a specific enterprise user. Requires enterprise context and the user's SCIM ID. ```python from ghapi.all import enterprise_admin # Example usage: # enterprise_admin.get_provisioning_information_for_enterprise_user(enterprise, scim_user_id) ``` -------------------------------- ### Initialize GhApi with Token and Repository Source: https://ghapi.fast.ai/index Demonstrates initializing the GhApi object with authentication token and specifying the owner and repository for API requests. ```Python api = GhApi(owner='fastai', repo='fastcore', token=github_token) ``` -------------------------------- ### Create and Verify Branch Source: https://ghapi.fast.ai/core Demonstrates creating a new branch using `create_branch_empty` and then verifying its existence using `list_branches`. ```Python ref = api.create_branch_empty("testme") test_eq(len(api.list_branches('testme')), 1) ``` -------------------------------- ### Suspend App Installation Source: https://ghapi.fast.ai/fullapi Suspends a GitHub App installation using its 'installation_id'. ```Python from ghapi.all import * app.suspend_installation(installation_id) ``` -------------------------------- ### Delete App Installation Source: https://ghapi.fast.ai/fullapi Deletes a specific installation for the authenticated GitHub App using its 'installation_id'. ```Python from ghapi.all import * app.delete_installation(installation_id) ``` -------------------------------- ### Initialize GhApi Object Source: https://ghapi.fast.ai/index Demonstrates how to create an instance of the GhApi object to interact with the GitHub API. This is the first step for any API interaction. ```Python from ghapi.all import GhApi api = GhApi() ``` -------------------------------- ### GitHub Projects: Create User Project Source: https://ghapi.fast.ai/fullapi Creates a new project for the authenticated user. Requires a project name and an optional body description. ```python ghapi_fast_ai.projects.create_for_authenticated_user(name, body) ``` -------------------------------- ### GitHub Apps: Remove Repository from Installation Source: https://ghapi.fast.ai/fullapi Removes a specified repository from an app installation. Requires installation_id and repository_id. ```python from ghapi.all import * # Remove a repository from an app installation # Requires installation_id and repository_id # Example: # print(apps.remove_repo_from_installation_for_authenticated_user(installation_id=123, repository_id=456)) ``` -------------------------------- ### Revoke Installation Access Token Source: https://ghapi.fast.ai/fullapi Revokes the access token for a GitHub App installation. This function does not require any parameters. ```Python from ghapi.all import * app.revoke_installation_access_token() ``` -------------------------------- ### Get Emojis Source: https://ghapi.fast.ai/fullapi Retrieves a list of all available emojis supported by GitHub. This is a simple GET request with no parameters required. ```Python gh.emojis.get() ``` -------------------------------- ### Prebuild Workflow Step Source: https://ghapi.fast.ai/actions Defines a prebuild job within a GitHub Actions workflow. This job checks out code, sets up Python, installs ghapi, and runs a prebuild script, capturing the output of the steps. ```bash runs-on: ubuntu-latest outputs: out: ${{ toJson(steps) }} steps: - uses: actions/checkout@v1 - uses: actions/setup-python@v2 with: {python-version: '3.8'} - name: Create release id: step1 env: CONTEXT_GITHUB: ${{ toJson(github) }} run: | pip install -q ghapi python .github/scripts/prebuild.py ``` -------------------------------- ### Get SCIM Provisioning Information for Enterprise Group Source: https://ghapi.fast.ai/fullapi Retrieves SCIM provisioning information for a specific enterprise group. Requires enterprise context and the group's SCIM ID. ```python from ghapi.all import enterprise_admin # Example usage: # enterprise_admin.get_provisioning_information_for_enterprise_group(enterprise, scim_group_id) ``` -------------------------------- ### Create GitHub Release with Files Source: https://ghapi.fast.ai/core Wraps the `GhApi.repos.create_release` method to simplify the creation of a GitHub release and the uploading of associated files. It handles the multi-stage process of release creation and asset attachment. ```Python from ghapi.core import GhApi from fastcore.utils import test_eq from time import sleep api = GhApi() rel = api.create_release('0.0.1', files=['README.md']) test_eq(rel.name, 'v0.0.1') sleep(0.2) rels = api.repos.list_releases() test_eq(len(rels), 1) assets = api.repos.list_release_assets(rels[0].id) test_eq(assets[0].name, 'README.md') ``` -------------------------------- ### GitHub Actions Workflow Template Output Source: https://ghapi.fast.ai/actions Example of how to capture and access step outputs in a GitHub Actions workflow using the `toJson` function and accessing it as a dictionary. ```bash outputs: out: ${{ toJson(steps) }} ``` -------------------------------- ### Create a Label Source: https://ghapi.fast.ai/fullapi Creates a new label in a repository. Requires owner, repository name, label name, and color. Optionally accepts a description. ```bash curl -X POST -H "Authorization: token YOUR_TOKEN" -d '{"name": "new-label", "color": "000000", "description": "A new label"}' https://api.github.com/repos/OWNER/REPO/labels ``` ```python import requests payload = { "name": "new-label", "color": "000000", "description": "A new label" } response = requests.post('https://api.github.com/repos/OWNER/REPO/labels', json=payload, headers={'Authorization': 'token YOUR_TOKEN'}) ``` -------------------------------- ### List and Verify GitHub Webhooks Source: https://ghapi.fast.ai/core Shows how to list existing webhooks for a repository and verify their properties. This is often done after creating or modifying webhooks to confirm the changes. ```Python hooks = api.repos.list_webhooks() test_eq(len(hooks), 0) ``` -------------------------------- ### List Provisioned Identities for Enterprise Source: https://ghapi.fast.ai/fullapi Lists all SCIM provisioned identities for an enterprise. Supports pagination with startIndex and count, and filtering. ```python from ghapi.all import enterprise_admin # Example usage: # enterprise_admin.list_provisioned_identities_enterprise(enterprise, startIndex, count, filter) ``` -------------------------------- ### Create GitHub App from Manifest Source: https://ghapi.fast.ai/fullapi Creates a GitHub App using a provided manifest code. This function requires a 'code' parameter representing the manifest. ```Python from ghapi.all import * app.create_from_manifest(code) ``` -------------------------------- ### Create Gist (GitHub API) Source: https://ghapi.fast.ai/fullapi Creates a new gist for the authenticated user. Requires 'description', 'files', and 'public' parameters. ```bash curl -L -X POST 'https://api.github.com/gists' \ -H 'Accept: application/vnd.github+json' \ -d '{ "description": "Example gist", "public": true, "files": { "file1.txt": { "content": "Hello world" } } }' ``` ```javascript const response = await fetch('https://api.github.com/gists', { method: 'POST', headers: { 'Accept': 'application/vnd.github+json' }, body: JSON.stringify({ description: 'Example gist', public: true, files: { 'file1.txt': { content: 'Hello world' } } }) }); const data = await response.json(); ``` ```python import requests response = requests.post('https://api.github.com/gists', json={ 'description': 'Example gist', 'public': True, 'files': { 'file1.txt': { 'content': 'Hello world' } } }) data = response.json() ``` -------------------------------- ### List Subscription Plans Source: https://ghapi.fast.ai/fullapi Lists available subscription plans. Supports pagination with 'per_page' and 'page' parameters. ```Python from ghapi.all import * app.list_plans(per_page, page) ``` -------------------------------- ### Create a GitHub Gist with Multiple Files Source: https://ghapi.fast.ai/core Demonstrates how to create a GitHub Gist with multiple files by directly calling the GitHub API. This method allows for more complex Gist structures than the convenience method. ```Python from ghapi.core import GhApi api = GhApi() api.gists.create("some description", files={"f1.txt": {"content": "my content"}, ...}) ``` -------------------------------- ### Access Git Endpoints Source: https://ghapi.fast.ai/index Illustrates how to access specific groups of API endpoints, using the 'git' group as an example. This allows exploration of Git-related operations. ```Python api.git ``` -------------------------------- ### Use GhApi CLI to Get Git Reference Source: https://ghapi.fast.ai/index Illustrates how to use the GhApi command-line interface to retrieve a Git reference. It shows how to pass positional and named arguments, including the '--ref' option. ```Bash ghapi git.get_ref fastai ghapi-test --ref heads/master ``` -------------------------------- ### Get Feeds Source: https://ghapi.fast.ai/fullapi Retrieves the feeds for the authenticated user. ```python gh.activity.get_feeds() ``` -------------------------------- ### Get Thread Source: https://ghapi.fast.ai/fullapi Retrieves a specific discussion thread by its ID. ```python gh.activity.get_thread(thread_id=12345) ``` -------------------------------- ### GitHub Projects: Create Repository Project Source: https://ghapi.fast.ai/fullapi Creates a new project for a repository. Requires repository owner, name, and project name, with an optional body description. ```python ghapi_fast_ai.projects.create_for_repo(owner, repo, name, body) ``` -------------------------------- ### Provision and Invite Enterprise User Source: https://ghapi.fast.ai/fullapi Provisions a new SCIM enterprise user and sends an invitation. Requires enterprise context, schemas, username, name, emails, and associated groups. ```python from ghapi.all import enterprise_admin # Example usage: # enterprise_admin.provision_and_invite_enterprise_user(enterprise, schemas, userName, name, emails, groups) ``` -------------------------------- ### List GhApi Operation Groups Source: https://ghapi.fast.ai/core Displays how to print the GhApi object to list all available operation groups, each with a link to its documentation. ```python api ``` -------------------------------- ### GitHub Projects: Get Project Source: https://ghapi.fast.ai/fullapi Retrieves details of a specific project using its ID. ```python ghapi_fast_ai.projects.get(project_id) ``` -------------------------------- ### Get Repository Subscription Source: https://ghapi.fast.ai/fullapi Retrieves the subscription status for a specific repository for the authenticated user. ```python gh.activity.get_repo_subscription(owner='octocat', repo='Spoon-Knife') ``` -------------------------------- ### Create File in GitHub Source: https://ghapi.fast.ai/core Creates a new file in a GitHub repository with specified content, message, committer, and author. It then verifies the file's content. ```Python person = dict(name="Monalisa Octocat", email="octocat@github.com") res = api.create_file( path='foo', message="Create foo", content="foobar", committer=person, author=person ) test_eq('foobar', api.get_content('foo').decode()) ``` -------------------------------- ### Get Thread Subscription Source: https://ghapi.fast.ai/fullapi Retrieves the subscription status for a specific thread for the authenticated user. ```python gh.activity.get_thread_subscription_for_authenticated_user(thread_id=12345) ``` -------------------------------- ### Load Sample GitHub Events Source: https://ghapi.fast.ai/event Loads a set of sample GitHub events. This function handles downloading the sample data if it's not already available locally. ```python load_sample_events() ``` -------------------------------- ### Create a GitHub Gist with a Single File Source: https://ghapi.fast.ai/core Creates a GitHub Gist containing a single file with specified content and description. It returns the Gist object, including its HTML URL and file content. ```Python from ghapi.core import GhApi api = GhApi() gist = api.create_gist("some description", "some content") gist.html_url, gist.files['gist.txt'].content ``` -------------------------------- ### Get Import Status Source: https://ghapi.fast.ai/fullapi Retrieves the status of a repository import. Requires owner and repository name. ```rest GET /repos/{owner}/{repo}/import ``` -------------------------------- ### Get Gist (GitHub API) Source: https://ghapi.fast.ai/fullapi Retrieves a specific gist using its unique 'gist_id'. ```bash curl -L -X GET 'https://api.github.com/gists/{gist_id}' ``` ```javascript const response = await fetch('https://api.github.com/gists/{gist_id}'); const data = await response.json(); ``` ```python import requests response = requests.get('https://api.github.com/gists/{gist_id}') data = response.json() ``` -------------------------------- ### Set SCIM Information for Provisioned Enterprise User Source: https://ghapi.fast.ai/fullapi Sets SCIM information for a provisioned enterprise user. Requires enterprise context, user SCIM ID, schemas, username, name, emails, and groups. ```python from ghapi.all import enterprise_admin # Example usage: # enterprise_admin.set_information_for_provisioned_enterprise_user(enterprise, scim_user_id, schemas, userName, name, emails, groups) ``` -------------------------------- ### Get User Public Key Source: https://ghapi.fast.ai/fullapi Retrieves the public key for encrypting secrets for the authenticated user. ```python gh.codespaces.get_public_key_for_authenticated_user() ``` -------------------------------- ### Create Codespace for Authenticated User Source: https://ghapi.fast.ai/fullapi Creates a codespace for the authenticated user. Requires repository ID, reference, location, and optionally machine type, devcontainer path, and other configurations. ```python gh.codespaces.create_for_authenticated_user(repository_id, ref, location, client_ip, machine, devcontainer_path, multi_repo_permissions_opt_out, working_directory, idle_timeout_minutes, display_name, retention_period_minutes) ``` -------------------------------- ### GitHub API: Create Repository Using Template Source: https://ghapi.fast.ai/fullapi Creates a new repository using an existing repository as a template. Requires template owner, template repo, new owner, name, and other optional parameters. ```Python gh.repos.create_using_template(template_owner, template_repo, owner, name, description, include_all_branches, private) ``` -------------------------------- ### Get Subscription Plan for Account (Stubbed) Source: https://ghapi.fast.ai/fullapi Retrieves a stubbed subscription plan for a given 'account_id'. ```Python from ghapi.all import * app.get_subscription_plan_for_account_stubbed(account_id) ``` -------------------------------- ### Get Authenticated App Source: https://ghapi.fast.ai/fullapi Retrieves information about the authenticated GitHub App. This function does not require any parameters. ```Python from ghapi.all import * app.get_authenticated() ``` -------------------------------- ### Follow User GitHub API Source: https://ghapi.fast.ai/fullapi Starts following a specified user. Requires the username of the user to follow. ```python gh.users.follow(username='github_username') ``` -------------------------------- ### GitHub API: List Deploy Keys Source: https://ghapi.fast.ai/fullapi Lists the deploy keys for a GitHub repository. Parameters include owner, repository name, and optional pagination parameters. ```Python gh.repos.list_deploy_keys(owner='', repo='', per_page='', page='') ``` -------------------------------- ### GitHub API: Create GitHub Pages Site Source: https://ghapi.fast.ai/fullapi Creates a GitHub Pages site for a repository. Requires owner and repository name. ```Python gh.repos.create_pages_site(owner='', repo='') ``` -------------------------------- ### Get Repository Details Source: https://ghapi.fast.ai/fullapi Retrieves information about a specific repository. Requires the owner and repository name as input. ```Python gh.repos.get(owner='repo_owner', repo='repo_name') ``` -------------------------------- ### GitHub API: Create Repository for Authenticated User Source: https://ghapi.fast.ai/fullapi Creates a new repository for the authenticated user. Requires a repository name and supports many optional configuration parameters. ```Python gh.repos.create_for_authenticated_user(name, description, homepage, private, has_issues, has_projects, has_wiki, team_id, auto_init, gitignore_template, license_template, allow_squash_merge, allow_merge_commit, allow_rebase_merge, allow_auto_merge, delete_branch_on_merge, has_downloads, is_template) ``` -------------------------------- ### Get Pull Request Source: https://ghapi.fast.ai/fullapi Retrieves a specific pull request by its number. Requires owner, repo, and pull_number. ```Python ghapi.pulls.get(owner, repo, pull_number=123) ``` -------------------------------- ### List Devcontainer Configurations in Repository Source: https://ghapi.fast.ai/fullapi Lists available devcontainer configurations within a repository for the authenticated user. Requires repository owner, repository name, and pagination parameters. ```python gh.codespaces.list_devcontainers_in_repository_for_authenticated_user(owner, repo, per_page, page) ``` -------------------------------- ### GitHub Projects: Get Project Column Source: https://ghapi.fast.ai/fullapi Retrieves details of a specific project column using its ID. ```python ghapi_fast_ai.projects.get_column(column_id) ``` -------------------------------- ### GitHub Projects: Get Project Card Source: https://ghapi.fast.ai/fullapi Retrieves details of a specific project card using its ID. ```python ghapi_fast_ai.projects.get_card(card_id) ``` -------------------------------- ### Get Commit (GitHub API) Source: https://ghapi.fast.ai/fullapi Retrieves a commit from a repository. Requires 'owner', 'repo', and 'commit_sha'. ```bash curl -L -X GET 'https://api.github.com/repos/{owner}/{repo}/git/commits/{commit_sha}' ``` ```javascript const response = await fetch('https://api.github.com/repos/{owner}/{repo}/git/commits/{commit_sha}'); const data = await response.json(); ``` ```python import requests response = requests.get('https://api.github.com/repos/{owner}/{repo}/git/commits/{commit_sha}') data = response.json() ``` -------------------------------- ### Call GitHub API Endpoint: Create Webhook Source: https://ghapi.fast.ai/core Shows how to call the `create_webhook` endpoint for GitHub repositories. It includes passing configuration details like URL and events, and then verifies the creation by listing webhooks. ```Python url = 'https://example.com' cfg = dict(url=url, content_type='json', secret='XXX') hook = api.repos.create_webhook(config=cfg, events=['ping']) test_eq(hook.config.url, url) ``` -------------------------------- ### Get Git Reference with Pre-configured API Source: https://ghapi.fast.ai/index Shows how to call the 'git.get_ref' endpoint when the GhApi object has already been configured with owner, repo, and token. Only the 'ref' parameter is needed. ```Python api.git.get_ref('heads/master') ``` -------------------------------- ### Get User Secret Source: https://ghapi.fast.ai/fullapi Retrieves a specific secret configured for the authenticated user. Requires the secret name. ```python gh.codespaces.get_secret_for_authenticated_user(secret_name) ``` -------------------------------- ### Get Workflow Source: https://ghapi.fast.ai/fullapi Retrieves details for a specific workflow. Requires owner, repository name, and the workflow ID. ```Python from ghapi.core import * # Example usage: # get_workflow(owner='your_owner', repo='your_repo', workflow_id='ci.yml') ``` -------------------------------- ### Create Organization Repository Source: https://ghapi.fast.ai/fullapi Creates a new repository within an organization. Accepts various parameters to configure the repository, such as name, description, visibility, and template options. Requires organization name and repository name. ```Python gh.repos.create_in_org(org='your_org_name', name='new_repo_name', description='A new repository') ``` -------------------------------- ### Get Authenticated User GitHub API Source: https://ghapi.fast.ai/fullapi Retrieves information about the currently authenticated user. This function does not require any parameters. ```python gh.users.get_authenticated() ``` -------------------------------- ### Create Reaction for Release Source: https://ghapi.fast.ai/fullapi Creates a reaction for a specific release. Requires repository owner, repository name, release ID, and the desired reaction content. ```Python gh.reactions.create_for_release(owner, repo, release_id, content) ``` -------------------------------- ### GitHub API: Get Top Referrers Source: https://ghapi.fast.ai/fullapi Retrieves the top referrers for a repository. Requires owner and repository name. ```Python gh.repos.get_top_referrers(owner, repo) ``` -------------------------------- ### Get Repository README Source: https://ghapi.fast.ai/fullapi Endpoints for retrieving the README file of a repository, either at the root or within a specific directory. ```Python from ghapi.core import GhApi api = GhApi() # Get a repository README # api.repos.get_readme(owner, repo, ref) # Get a repository README for a directory # api.repos.get_readme_in_directory(owner, repo, dir, ref) ``` -------------------------------- ### Get Review Comment Source: https://ghapi.fast.ai/fullapi Retrieves a specific review comment for a pull request. Requires owner, repo, and the comment_id. ```Python ghapi.pulls.get_review_comment(owner, repo, comment_id=456) ``` -------------------------------- ### List Runner Applications and Create Tokens (Enterprise) Source: https://ghapi.fast.ai/fullapi These functions are used to retrieve available runner applications for an enterprise and to create necessary tokens for runner registration and removal. ```Python ghapi.actions.enterprise_admin.list_runner_applications_for_enterprise(enterprise) ``` ```Python ghapi.actions.enterprise_admin.create_registration_token_for_enterprise(enterprise) ``` ```Python ghapi.actions.enterprise_admin.create_remove_token_for_enterprise(enterprise) ``` -------------------------------- ### Create Codespace in Repository for Authenticated User Source: https://ghapi.fast.ai/fullapi Creates a codespace in a specified repository for the authenticated user. Requires repository details, reference, location, and optionally machine type, devcontainer path, and other configurations. ```python gh.codespaces.create_with_repo_for_authenticated_user(owner, repo, ref, location, client_ip, machine, devcontainer_path, multi_repo_permissions_opt_out, working_directory, idle_timeout_minutes, display_name, retention_period_minutes) ``` -------------------------------- ### GitHub Projects: Get User Permission for Project Source: https://ghapi.fast.ai/fullapi Retrieves the permission level of a specific user for a given project. ```python ghapi_fast_ai.projects.get_permission_for_user(project_id, username) ``` -------------------------------- ### GitHub API: Create or Update Environment Source: https://ghapi.fast.ai/fullapi Creates or updates a GitHub repository environment. This operation requires owner, repository name, and environment name as parameters. Optional parameters include wait timer, reviewers, and deployment branch policy. ```Python gh.repos.create_or_update_environment(owner='', repo='', environment_name='', wait_timer='', reviewers='', deployment_branch_policy='') ``` -------------------------------- ### Get Tag (GitHub API) Source: https://ghapi.fast.ai/fullapi Retrieves a tag object from a repository. Requires 'owner', 'repo', and 'tag_sha'. ```bash curl -L -X GET 'https://api.github.com/repos/{owner}/{repo}/git/tags/{tag_sha}' ``` ```javascript const response = await fetch('https://api.github.com/repos/{owner}/{repo}/git/tags/{tag_sha}'); const data = await response.json(); ``` ```python import requests response = requests.get('https://api.github.com/repos/{owner}/{repo}/git/tags/{tag_sha}') data = response.json() ``` -------------------------------- ### Create Registration Token for a Repository Source: https://ghapi.fast.ai/fullapi Creates a registration token for a repository, which is used to register new self-hosted runners. Requires repository owner and name. ```Python from ghapi.core import GhApi api = GhApi() api.actions.create_registration_token_for_repo(owner='', repo='') ``` -------------------------------- ### Get Blob (GitHub API) Source: https://ghapi.fast.ai/fullapi Retrieves a blob object from a repository. Requires 'owner', 'repo', and 'file_sha'. ```bash curl -L -X GET 'https://api.github.com/repos/{owner}/{repo}/git/blobs/{file_sha}' ``` ```javascript const response = await fetch('https://api.github.com/repos/{owner}/{repo}/git/blobs/{file_sha}'); const data = await response.json(); ``` ```python import requests response = requests.get('https://api.github.com/repos/{owner}/{repo}/git/blobs/{file_sha}') data = response.json() ``` -------------------------------- ### List Reactions for Release Source: https://ghapi.fast.ai/fullapi Lists reactions for a specific release. Requires repository owner, repository name, and release ID. Supports filtering by reaction content and pagination. ```Python gh.reactions.list_for_release(owner, repo, release_id, content, per_page, page) ``` -------------------------------- ### Get Gist Revision (GitHub API) Source: https://ghapi.fast.ai/fullapi Retrieves a specific revision of a gist. Requires 'gist_id' and 'sha'. ```bash curl -L -X GET 'https://api.github.com/gists/{gist_id}/{sha}' ``` ```javascript const response = await fetch('https://api.github.com/gists/{gist_id}/{sha}'); const data = await response.json(); ``` ```python import requests response = requests.get('https://api.github.com/gists/{gist_id}/{sha}') data = response.json() ``` -------------------------------- ### Manage GitHub Repository Environments Source: https://ghapi.fast.ai/fullapi Provides functionality to list all environments configured for a repository and retrieve details of a specific environment. Requires repository owner, name, and environment name. ```Python from ghapi.core import GhApi api = GhApi() # Get all environments environments = api.repos.get_all_environments(owner='', repo='') # Get a specific environment environment = api.repos.get_environment(owner='', repo='', environment_name='') ``` -------------------------------- ### Get Gist Comment (GitHub API) Source: https://ghapi.fast.ai/fullapi Retrieves a specific comment for a gist using 'gist_id' and 'comment_id'. ```bash curl -L -X GET 'https://api.github.com/gists/{gist_id}/comments/{comment_id}' ``` ```javascript const response = await fetch('https://api.github.com/gists/{gist_id}/comments/{comment_id}'); const data = await response.json(); ``` ```python import requests response = requests.get('https://api.github.com/gists/{gist_id}/comments/{comment_id}') data = response.json() ``` -------------------------------- ### Get Specific App Webhook Delivery Source: https://ghapi.fast.ai/fullapi Retrieves a specific webhook delivery for a GitHub App using its 'delivery_id'. ```Python from ghapi.all import * app.get_webhook_delivery(delivery_id) ``` -------------------------------- ### GitHub Projects: Create Organization Project Source: https://ghapi.fast.ai/fullapi Creates a new project for an organization. Requires organization name and project name, with an optional body description. ```python ghapi_fast_ai.projects.create_for_org(org, name, body) ``` -------------------------------- ### Manage GitHub Repository Deployments Source: https://ghapi.fast.ai/fullapi Facilitates listing, creating, retrieving, and deleting deployments for a repository. It also covers managing deployment statuses, requiring deployment IDs and specific states. ```Python from ghapi.core import GhApi api = GhApi() # List deployments deployments = api.repos.list_deployments(owner='', repo='', ref='') # Create a deployment api.repos.create_deployment(owner='', repo='', ref='') # Get a deployment deployment = api.repos.get_deployment(owner='', repo='', deployment_id=) # Delete a deployment api.repos.delete_deployment(owner='', repo='', deployment_id=) # List deployment statuses d_statuses = api.repos.list_deployment_statuses(owner='', repo='', deployment_id=) # Create a deployment status api.repos.create_deployment_status(owner='', repo='', deployment_id=, state='success') # Get a deployment status d_status = api.repos.get_deployment_status(owner='', repo='', deployment_id=, status_id=) ``` -------------------------------- ### Get App Webhook Configuration Source: https://ghapi.fast.ai/fullapi Fetches the webhook configuration for a specific GitHub App. This function does not require any parameters. ```Python from ghapi.all import * app.get_webhook_config_for_app() ``` -------------------------------- ### Get Repository Secret Source: https://ghapi.fast.ai/fullapi Retrieves a specific secret from a repository. Requires owner, repository name, and the secret name. ```Python from ghapi.core import * # Example usage: # get_repo_secret(owner='your_owner', repo='your_repo', secret_name='MY_SECRET') ``` -------------------------------- ### Review Pending Deployments for Run Source: https://ghapi.fast.ai/fullapi Reviews pending deployments for a workflow run, allowing approval or rejection. Requires owner, repository name, run ID, environment IDs, state, and an optional comment. ```Python from ghapi.core import * # Example usage: # review_pending_deployments_for_run(owner='your_owner', repo='your_repo', run_id=123, environment_ids=[1, 2], state='approved', comment='Looks good!') ``` -------------------------------- ### Get User by Username GitHub API Source: https://ghapi.fast.ai/fullapi Retrieves information about a specific GitHub user using their username. Requires the username. ```python gh.users.get_by_username(username='github_username') ``` -------------------------------- ### Enable GitHub Pages with GhApi Source: https://ghapi.fast.ai/core Enables or updates GitHub Pages for a repository to point to a specified branch and path. The path must be either '/docs' or '/'. If no branch is specified, it defaults to the repository's default branch. ```python res = api.enable_pages(branch='new-branch', path='/') test_eq(res.source.branch, 'new-branch') test_eq(res.source.path, '/') api.repos.delete_pages_site() api.delete_branch('new-branch') ``` -------------------------------- ### Get Repository Permissions for User Source: https://ghapi.fast.ai/fullapi Retrieves the permission level of a user for a specific repository. Requires owner, repo, and username. ```Python gh.repos.get_collaborator_permission_level(owner, repo, username) ``` -------------------------------- ### List GitHub API Endpoints in a Group Source: https://ghapi.fast.ai/core Demonstrates how to view all available endpoints within a specific API group (e.g., 'git') and provides links to their respective documentation. This helps in exploring the API's capabilities. ```Python api.git ``` -------------------------------- ### Get Users with Access to Protected Branch Source: https://ghapi.fast.ai/fullapi Lists users that have access to a protected branch. Requires owner, repo, and branch. ```Python gh.repos.get_users_with_access_to_protected_branch(owner, repo, branch) ``` -------------------------------- ### Access GhApi Endpoint by Index Source: https://ghapi.fast.ai/core Illustrates accessing and calling a GitHub API endpoint using dictionary-style indexing. This simplifies the process by automatically handling parameter types (route, query, post data). ```Python api['/repos/{owner}/{repo}/git/ref/{ref}'](owner='fastai', repo='ghapi-test', ref='heads/master') ``` -------------------------------- ### Get Teams with Access to Protected Branch Source: https://ghapi.fast.ai/fullapi Lists teams that have access to a protected branch. Requires owner, repo, and branch. ```Python gh.repos.get_teams_with_access_to_protected_branch(owner, repo, branch) ``` -------------------------------- ### Get Access Restrictions Source: https://ghapi.fast.ai/fullapi Retrieves the access restrictions for a protected branch in a GitHub repository. Requires owner, repo, and branch. ```Python gh.repos.get_access_restrictions(owner, repo, branch) ``` -------------------------------- ### GitHub API: List Repository Invitations for Authenticated User Source: https://ghapi.fast.ai/fullapi Lists repository invitations for the authenticated user. Supports pagination. ```Python gh.repos.list_invitations_for_authenticated_user(per_page, page) ``` -------------------------------- ### Get Rate Limit Status Source: https://ghapi.fast.ai/fullapi Retrieves the rate limit status for the authenticated user on GitHub. This endpoint does not require any parameters. ```python gh.rate_limit.get() ``` -------------------------------- ### List Repositories in User Migration Source: https://ghapi.fast.ai/fullapi Lists repositories included in a user migration. Supports pagination. Requires migration ID. ```rest GET /user/migrations/{migration_id}/repositories ``` -------------------------------- ### Get Review for Pull Request Source: https://ghapi.fast.ai/fullapi Retrieves a specific review for a pull request. Requires owner, repo, pull_number, and review_id. ```Python ghapi.pulls.get_review(owner, repo, pull_number=123, review_id=789) ``` -------------------------------- ### Get Organization Migration Status Source: https://ghapi.fast.ai/fullapi Retrieves the status of a specific organization migration. Requires organization name and migration ID. ```rest GET /orgs/{org}/migrations/{migration_id} ``` -------------------------------- ### GitHub API: Create Deploy Key Source: https://ghapi.fast.ai/fullapi Creates a new deploy key for a GitHub repository. Requires owner, repository name, key title, the public key string, and read-only status. ```Python gh.repos.create_deploy_key(owner='', repo='', title='', key='<key>', read_only='<read_only>') ``` -------------------------------- ### Get an Issue Source: https://ghapi.fast.ai/fullapi Retrieves details for a specific issue in a repository. Requires owner, repository name, and the issue number. ```bash curl -H "Authorization: token YOUR_TOKEN" https://api.github.com/repos/OWNER/REPO/issues/ISSUE_NUMBER ``` ```python import requests response = requests.get('https://api.github.com/repos/OWNER/REPO/issues/ISSUE_NUMBER', headers={'Authorization': 'token YOUR_TOKEN'}) ```