123456789_123456789_123456789_123456789_123456789_

Class: Octokit::Client

Relationships & Source Files
Namespace Children
Modules:
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
Inherits: Object
Defined in: lib/octokit/client.rb,
lib/octokit/client/actions_secrets.rb,
lib/octokit/client/actions_workflow_runs.rb,
lib/octokit/client/actions_workflows.rb,
lib/octokit/client/apps.rb,
lib/octokit/client/authorizations.rb,
lib/octokit/client/checks.rb,
lib/octokit/client/commit_branches.rb,
lib/octokit/client/commit_comments.rb,
lib/octokit/client/commit_pulls.rb,
lib/octokit/client/commits.rb,
lib/octokit/client/community_profile.rb,
lib/octokit/client/contents.rb,
lib/octokit/client/deployments.rb,
lib/octokit/client/downloads.rb,
lib/octokit/client/emojis.rb,
lib/octokit/client/events.rb,
lib/octokit/client/feeds.rb,
lib/octokit/client/gists.rb,
lib/octokit/client/gitignore.rb,
lib/octokit/client/hooks.rb,
lib/octokit/client/issues.rb,
lib/octokit/client/labels.rb,
lib/octokit/client/legacy_search.rb,
lib/octokit/client/licenses.rb,
lib/octokit/client/markdown.rb,
lib/octokit/client/marketplace.rb,
lib/octokit/client/meta.rb,
lib/octokit/client/milestones.rb,
lib/octokit/client/notifications.rb,
lib/octokit/client/oauth_applications.rb,
lib/octokit/client/objects.rb,
lib/octokit/client/organizations.rb,
lib/octokit/client/pages.rb,
lib/octokit/client/projects.rb,
lib/octokit/client/pub_sub_hubbub.rb,
lib/octokit/client/pull_requests.rb,
lib/octokit/client/rate_limit.rb,
lib/octokit/client/reactions.rb,
lib/octokit/client/refs.rb,
lib/octokit/client/releases.rb,
lib/octokit/client/repositories.rb,
lib/octokit/client/repository_invitations.rb,
lib/octokit/client/reviews.rb,
lib/octokit/client/say.rb,
lib/octokit/client/search.rb,
lib/octokit/client/service_status.rb,
lib/octokit/client/source_import.rb,
lib/octokit/client/stats.rb,
lib/octokit/client/statuses.rb,
lib/octokit/client/traffic.rb,
lib/octokit/client/users.rb

Overview

Client for the GitHub API

Constant Summary

Authentication - Included

FARADAY_BASIC_AUTH_KEYS

Connection - Included

CONVENIENCE_HEADERS

Preview - Included

PREVIEW_TYPES

ServiceStatus - Included

COMPONENTS_ROOT, STATUS_ROOT, SUMMARY_ROOT

Class Method Summary

Instance Attribute Summary

Configurable - Included

Authentication - Included

#application_authenticated?

Indicates if the client has OAuth Application client_id and secret credentials to make anonymous requests at a higher rate limit.

#basic_authenticated?

Indicates if the client was supplied Basic Auth username and password.

#bearer_authenticated?

Indicates if the client was supplied a bearer token.

#token_authenticated?

Indicates if the client was supplied an OAuth access token.

#user_authenticated?

Indicates if the client was supplied an OAuth access token or Basic Auth username and password.

Instance Method Summary

Users - Included

#add_email

Add email address to user.

#add_key

Add public key to user account.

#all_users

List all GitHub users.

#delete_user_migration_archive

Deletes a previous migration archive.

#emails

List email addresses for a user.

#exchange_code_for_token

Retrieve the access_token.

#follow

Follow a user.

#followers

Get a user's followers.

#following

Get list of users a user is following.

#follows?

Check if you are following a user.

#key

Get a public key.

#keys

Get list of public keys for user.

#remove_email

Remove email from user.

#remove_key

Remove a public key from user account.

#starred

Get list of repos starred by a user.

#starred?

Check if you are starring a repo.

#start_user_migration

Initiates the generation of a migration archive.

#subscriptions

List repositories being watched by a user.

#unfollow

Unfollow a user.

#unlock_user_repository

Unlock a user repository which has been locked by a migration.

#update_key

Update a public key.

#update_user

Update the authenticated user.

#user

Get a single user.

#user_keys

Get list of public keys for user.

#user_migration_archive_url

Fetches the URL to a migration archive.

#user_migration_repositories

List repositories for a user migration.

#user_migration_status

Fetches the status of a migration.

#user_migrations

Lists the most recent migrations.

#validate_credentials

Validate user username and password.

#watched

Traffic - Included

#clones

Get the total number of clones and breakdown per day or week for the last 14 days.

#top_paths

Get the top 10 popular contents over the last 14 days.

#top_referrers

Get the top 10 referrers over the last 14 days.

#views

Get the total number of views and breakdown per day or week for the last 14 days.

Statuses - Included

#combined_status

Get the combined status for a ref.

#create_status

Create status for a commit.

#list_statuses
#status
#statuses

List all statuses for a given commit.

Stats - Included

#code_frequency_stats

Get the number of additions and deletions per week.

#commit_activity_stats

Get the last year of commit activity data.

#contributor_stats
#contributors_stats

Get contributors list with additions, deletions, and commit counts.

#participation_stats

Get the weekly commit count for the repo owner and everyone else.

#punch_card
#punch_card_stats

Get the number of commits per hour in each day.

#get_stats

SourceImport - Included

#cancel_source_import

Stop an import for a repository.

#map_source_import_commit_author

Update an author's identity for the import.

#set_source_import_lfs_preference

Set preference for using Git LFS to import files over 100MB.

#source_import_commit_authors

List source import commit authors.

#source_import_large_files

List source import large files.

#source_import_progress

View the progress of an import.

#start_source_import

Start a source import to a GitHub repository using GitHub Importer.

#update_source_import

Update source import with authentication or project choice Restart source import if no options are passed.

ServiceStatus - Included

#github_status

Returns the current system status.

#github_status_last_message

Returns the last human communication, status, and timestamp.

#github_status_messages

Returns the most recent human communications with status and timestamp.

#github_status_summary

Returns a summary with the current status and the last status messages.

Search - Included

Say - Included

#octocat

Alias for Say#say.

#say

Return a nifty ASCII Octocat with GitHub wisdom or your own.

Reviews - Included

#create_pull_request_review

Create a pull request review.

#delete_pull_request_review

Delete a pending review.

#delete_pull_request_review_request

Delete a review request.

#dismiss_pull_request_review

Dismiss a pull request review.

#pull_request_review

Get a single review.

#pull_request_review_comments

Get comments for a single review.

#pull_request_review_requests

List review requests.

#pull_request_reviews

List reviews on a pull request.

#request_pull_request_review

Create a review request.

#submit_pull_request_review

Submit a pull request review.

#update_pull_request_review

Update a review request comment.

RepositoryInvitations - Included

Repositories - Included

#add_collab
#add_collaborator

Add collaborator to repo.

#add_deploy_key

Add deploy key to a repo.

#all_repositories

List all repositories.

#branch

Get a single branch from a repository.

#branch_protection

Get branch protection summary.

#branches

List branches.

#check_assignee

Check to see if a particular user is an assignee for a repository.

#collaborator?

Checks if a user is a collaborator for a repo.

#collaborators

List collaborators.

#collabs
#contribs
#contributors

List contributors to a repo.

#create
#create_repo
#create_repo_from_template
#create_repository

Create a repository for a user or organization.

#create_repository_from_template

Create a repository for a user or organization generated from a template repository.

#delete_repo
#delete_repository

Delete repository.

#delete_subscription

Delete a repository subscription.

#deploy_key

Get a single deploy key for a repo.

#deploy_keys

Get deploy keys on a repo.

#disable_vulnerability_alerts

Disable vulnerability alerts for a repository.

#dispatch_event

Create a repository dispatch event.

#edit
#edit_deploy_key

Edit a deploy key.

#edit_repository

Edit a repository.

#enable_vulnerability_alerts

Enable vulnerability alerts for a repository.

#fork

Fork a repository.

#forks

List forks.

#get_branch
#languages

List languages of code in the repo.

#list_deploy_keys
#list_repos
#list_repositories
#network
#permission_level

Get a user's permission level for a repo.

#protect_branch

Lock a single branch from a repository.

#remove_collab
#remove_collaborator

Remove collaborator from repo.

#remove_deploy_key

Remove deploy key from a repo.

#rename_branch

Rename a single branch from a repository.

#replace_all_topics

Replace all topics for a repository.

#repo
#repo_assignees
#repo_teams
#repos
#repositories

List user repositories.

#repository

Get a single repository.

#repository?

Check if a repository exists.

#repository_assignees

List users available for assigning to issues.

#repository_teams

List teams for a repo.

#set_private

Hide a public repository.

#set_public

Unhide a private repository.

#star

Star a repository.

#stargazers

List stargazers of a repo.

#subscribers

List watchers subscribing to notifications for a repo.

#subscription

Get a repository subscription.

#tags

List tags.

#teams
#topics

List all topics for a repository.

#transfer_repo
#transfer_repository

Transfer repository.

#unprotect_branch

Unlock a single branch from a repository.

#unstar

Unstar a repository.

#unwatch

Unwatch a repository.

#update
#update_deploy_key
#update_repository
#update_subscription

Update repository subscription.

#vulnerability_alerts_enabled?

Check to see if vulnerability alerts are enabled for a repository.

#watch

Watch a repository.

#watchers

List watchers of repo.

Releases - Included

#create_release

Create a release.

#delete_release

Delete a release.

#delete_release_asset

Delete a release asset.

#edit_release
#edit_release_asset
#latest_release

Get the latest release.

#list_releases
#release

Get a release.

#release_asset

Get a single release asset.

#release_assets

List release assets.

#release_for_tag

Get the release for a given tag.

#releases

List releases for a repository.

#update_release

Update a release.

#update_release_asset

Update a release asset.

#upload_asset

Upload a release asset.

#content_type_from_file

Refs - Included

#create_ref

Create a reference.

#create_reference

Alias for Refs#create_ref.

#delete_branch

Delete a single branch.

#delete_ref

Delete a single reference.

#delete_reference

Alias for Refs#delete_ref.

#list_references

Alias for Refs#refs.

#list_refs

Alias for Refs#refs.

#matching_refs

Fetch matching refs.

#ref

Fetch a given reference.

#reference

Alias for Refs#ref.

#references

Alias for Refs#refs.

#refs

List all refs for a given user and repo.

#update_branch

Update a branch.

#update_ref

Update a reference.

#update_reference

Alias for Refs#update_ref.

Reactions - Included

#commit_comment_reactions

List reactions for a commit comment.

#create_commit_comment_reaction

Create a reaction for a commit comment.

#create_issue_comment_reaction

Create reaction for an issue comment.

#create_issue_reaction

Create reaction for an issue.

#create_pull_request_review_comment_reaction

Create reaction for a pull request review comment.

#delete_reaction

Delete a reaction.

#issue_comment_reactions

List reactions for an issue comment.

#issue_reactions

List reactions for an issue.

#pull_request_review_comment_reactions

List reactions for a pull request review comment.

RateLimit - Included

#rate_limit

Get rate limit info from last response if available or make a new request to fetch rate limit.

#rate_limit!

Refresh rate limit info by making a new request.

#rate_limit_remaining

Get number of rate limted requests remaining.

#rate_limit_remaining!

Refresh rate limit info and get number of rate limted requests remaining.

#ratelimit
#ratelimit!
#ratelimit_remaining
#ratelimit_remaining!

PullRequests - Included

#close_pull_request

Close a pull request.

#create_pull_comment
#create_pull_reply
#create_pull_request

Create a pull request.

#create_pull_request_comment

Create a pull request comment.

#create_pull_request_comment_reply

Create reply to a pull request comment.

#create_pull_request_for_issue

Create a pull request from existing issue.

#create_review_reply
#create_view_comment
#delete_pull_comment
#delete_pull_request_comment

Delete pull request comment.

#delete_review_comment
#merge_pull_request

Merge a pull request.

#pull
#pull_comment
#pull_comments
#pull_commits
#pull_files
#pull_merged?

Check pull request merge status.

#pull_request

Get a pull request.

#pull_request_comment

Get a pull request comment.

#pull_request_comments

List comments on a pull request.

#pull_request_commits

List commits on a pull request.

#pull_request_files

List files on a pull request.

#pull_request_merged?
#pull_requests

List pull requests for a repository.

#pull_requests_comments

List pull request comments for a repository.

#pulls
#pulls_comments
#review_comment
#review_comments
#reviews_comments
#update_pull_comment
#update_pull_request

Update a pull request.

#update_pull_request_comment

Update pull request comment.

#update_review_comment

PubSubHubbub - Included

#subscribe

Subscribe to a pubsub topic.

#subscribe_service_hook

Subscribe to a repository through pubsub.

#unsubscribe

Unsubscribe from a pubsub topic.

#unsubscribe_service_hook

Unsubscribe repository through pubsub.

#pub_sub_hubbub_request

Projects - Included

#column_cards

List columns cards.

#create_org_project

Create organization project.

#create_organization_project
#create_project

Create a project.

#create_project_card

Create project card.

#create_project_column

Create a project column.

#delete_project

Delete a project.

#delete_project_card

Delete a project card.

#delete_project_column

Delete a project column.

#move_project_card

Move a project card.

#move_project_column

Move a project column.

#org_projects

List organization projects.

#organization_projects
#project

Get a project by id.

#project_card

Get a project card.

#project_column

Get a project column by ID.

#project_columns

List project columns.

#projects

List projects for a repository.

#update_project

Update a project.

#update_project_card

Update a project card.

#update_project_column

Update a project column.

Pages - Included

#latest_pages_build

List the latest Pages build information for a repository.

#list_pages_builds
#pages

List Pages information for a repository.

#pages_build

Get a specific Pages build by ID.

#pages_builds

List Pages builds for a repository.

#request_page_build

Request a page build for the latest revision of the default branch.

Organizations - Included

#add_team_member

Add team member.

#add_team_membership

Add or invite a user to a team.

#add_team_repo
#add_team_repository

Add team repository.

#all_organizations

List all GitHub organizations.

#all_orgs
#billing_actions

Get GitHub Actions billing for an organization.

#child_teams

List child teams.

#conceal_membership
#convert_to_outside_collaborator

Converts an organization member to an outside collaborator.

#create_team

Create team.

#delete_migration_archive

Deletes a previous migration archive.

#delete_team

Delete team.

#list_organizations
#list_orgs
#migration_archive_url

Fetches the URL to a migration archive.

#migration_status

Fetches the status of a migration.

#migrations

Lists the most recent migrations.

#org
#org_invitations
#org_member?
#org_members
#org_membership
#org_memberships
#org_public_member?
#org_public_members
#org_repos
#org_repositories
#org_teams
#organization

Get an organization.

#organization_invitations

List pending organization invitations.

#organization_member?

Check if a user is a member of an organization.

#organization_members

Get organization members.

#organization_membership

Get an organization membership.

#organization_memberships

List all organizations memberships for the authenticated user.

#organization_public_member?

Check if a user is a public member of an organization.

#organization_public_members

Get organization public members.

#organization_repositories

List organization repositories.

#organization_teams

List teams.

#organizations

Get organizations for a user.

#orgs
#outside_collaborators

List outside collaborators for an organization.

#publicize_membership

Publicize a user's membership of an organization.

#remove_org_member
#remove_org_membership
#remove_organization_member

Remove organization member.

#remove_organization_membership

Remove an organization membership.

#remove_outside_collaborator

Remove outside collaborator from an organization.

#remove_team_member

Remove team member.

#remove_team_membership

Remove team membership.

#remove_team_repo
#remove_team_repository

Remove team repository.

#start_migration

Initiates the generation of a migration archive.

#team

Get team.

#team_by_name

Get team by name and org.

#team_invitations

List pending team invitations.

#team_member?

Check if a user is a member of a team.

#team_members

List team members.

#team_membership

Check if a user has a team membership.

#team_repo?
#team_repos
#team_repositories

List team repositories.

#team_repository?

Check if a repo is managed by a specific team.

#unlock_repository

Unlock a previous migration archive.

#unpublicize_membership

Conceal a user's membership of an organization.

#update_org
#update_org_membership
#update_organization

Update an organization.

#update_organization_membership

Edit an organization membership.

#update_team

Update team.

#user_teams

List all teams for the authenticated user across all their orgs.

Objects - Included

#blob

Get a single blob, fetching its content and encoding.

#create_blob

Create a blob.

#create_tag

Create a tag.

#create_tree

Create a tree.

#tag

Get a tag.

#tree

Get a single tree, fetching information about its root-level objects.

OauthApplications - Included

Notifications - Included

#delete_thread_subscription

Delete a thread subscription.

#mark_notifications_as_read

Mark notifications as read.

#mark_repo_notifications_as_read
#mark_repository_notifications_as_read

Mark notifications from a specific repository as read.

#mark_thread_as_read

Mark thread as read.

#notifications

List your notifications.

#repo_notifications
#repository_notifications

List your notifications in a repository.

#thread_notifications

List notifications for a specific thread.

#thread_subscription

Get thread subscription.

#update_thread_subscription

Update thread subscription.

Milestones - Included

#create_milestone

Create a milestone for a repository.

#delete_milestone

Delete a single milestone for a repository.

#edit_milestone
#list_milestones

List milestones for a repository.

#milestone

Get a single milestone for a repository.

#milestones
#update_milestone

Update a milestone for a repository.

Marketplace - Included

#list_accounts_for_plan

List all GitHub accounts on a specific plan.

#list_plans

List all plans for an app's marketplace listing.

#marketplace_purchases

Get user's Marketplace purchases.

#plan_for_account

Get the plan associated with a given GitHub account.

Markdown - Included

#markdown

Render an arbitrary Markdown document.

Meta - Included

#github_meta

Alias for Meta#meta.

#meta

Get meta information about GitHub.com, the service.

Licenses - Included

#license

List an individual license.

#licenses

List all licenses.

#repository_license_contents

Returns the contents of the repository’s license file, if one is detected.

LegacySearch - Included

#legacy_search_issues

Legacy search issues within a repository.

#legacy_search_repositories

Legacy repository search.

#legacy_search_users

Search for user.

Labels - Included

#add_label

Add a label to a repository.

#add_labels_to_an_issue

Add label(s) to an Issue.

#delete_label!

Delete a label from a repository.

#label

Get single label for a repository.

#labels

List available labels for a repository.

#labels_for_issue

List labels for a given issue.

#labels_for_milestone

Get labels for every issue in a milestone.

#remove_all_labels

Remove all label from an Issue.

#remove_label

Remove a label from an Issue.

#replace_all_labels

Replace all labels on an Issue.

#update_label

Update a label.

Issues - Included

#add_assignees

Add assignees to an issue.

#add_comment

Add a comment to an issue.

#close_issue

Close an issue.

#create_issue

Create an issue for a repository.

#delete_comment

Delete a single comment.

#issue

Get a single issue from a repository.

#issue_comment

Get a single comment attached to an issue.

#issue_comments

Get all comments attached to an issue.

#issue_timeline

Get the timeline for an issue.

#issues
#issues_comments

Get all comments attached to issues for the repository.

#list_assignees

Lists the available assignees for issues in a repository.

#list_issues

List issues for the authenticated user or repository.

#lock_issue

Lock an issue's conversation, limiting it to collaborators.

#open_issue
#org_issues

List all issues for a given organization for the authenticated user.

#remove_assignees

Remove assignees from an issue.

#reopen_issue

Reopen an issue.

#unlock_issue

Unlock an issue's conversation, opening it to all viewers.

#update_comment

Update a single comment on an issue.

#update_issue

Update an issue.

#user_issues

List all issues across owned and member repositories for the authenticated user.

Apps - Included

#add_repo_to_installation
#add_repository_to_app_installation

Add a single repository to an installation.

#add_repository_to_integration_installation,
#app

Get the authenticated App.

#create_app_installation_access_token

Create a new installation token.

#create_installation_access_token
#create_integration_installation_access_token,
#delete_installation

Delete an installation and uninstall a GitHub App.

#find_app_installations

Find all installations that belong to an App.

#find_installation_repositories_for_user

List repositories accessible to the user for an installation.

#find_installations
#find_integration_installations,
#find_organization_installation

Enables an app to find the organization's installation information.

#find_repository_installation

Enables an app to find the repository's installation information.

#find_user_installation

Enables an app to find the user's installation information.

#find_user_installations

Find all installations that are accessible to the authenticated user.

#installation

Get a single installation.

#list_app_installation_repositories

List repositories that are accessible to the authenticated installation.

#list_installation_repos
#list_integration_installation_repositories,
#remove_repo_from_installation
#remove_repository_from_app_installation

Remove a single repository to an installation.

#remove_repository_from_integration_installation

ActionsWorkflowRuns - Included

#cancel_workflow_run

Cancels a workflow run.

#delete_workflow_run

Deletes a workflow run.

#delete_workflow_run_logs

Delets all log files of a workflow run.

#list_repository_workflow_runs
#list_workflow_runs
#repository_workflow_runs

List all workflow runs for a repository.

#rerun_workflow_run

Re-runs a workflow run.

#workflow_run

Get a workflow run.

#workflow_run_logs

Get a download url for archived log files of a workflow run.

#workflow_runs

List all runs for a repository workflow.

ActionsWorkflows - Included

#list_workflows
#workflow

Get single workflow in a repository.

#workflow_dispatch

Create a workflow dispatch event.

#workflows

Get the workflows in a repository.

Hooks - Included

#available_hooks

List all Service Hooks supported by GitHub.

#create_hook

Create a hook.

#create_org_hook

Create an org hook.

#edit_hook

Edit a hook.

#edit_org_hook

Update an org hook.

#hook

Get single hook.

#hooks

List repo hooks.

#list_org_hooks

Alias for Hooks#org_hooks.

#org_hook

Get an org hook.

#org_hooks

List org hooks.

#parse_payload

Parse payload string.

#ping_hook

Ping hook.

#ping_org_hook

Ping org hook.

#remove_hook

Delete hook.

#remove_org_hook

Remove org hook.

#test_hook

Test hook.

#update_org_hook

Gitignore - Included

#gitignore_template

Get a gitignore template.

#gitignore_templates

Listing available gitignore templates.

Gists - Included

#create_gist

Create a gist.

#create_gist_comment

Create gist comment.

#delete_gist

Delete a gist.

#delete_gist_comment

Delete gist comment.

#edit_gist

Edit a gist.

#fork_gist

Fork a gist.

#gist

Get a single gist.

#gist_comment

Get gist comment.

#gist_comments

List gist comments.

#gist_commits

List gist commits.

#gist_forks

List gist forks.

#gist_starred?

Check if a gist is starred.

#gists

List gists for a user or all public gists.

#list_gists

Alias for Gists#gists.

#public_gists

List public gists.

#star_gist

Star a gist.

#starred_gists

List the authenticated user’s starred gists.

#unstar_gist

Unstar a gist.

#update_gist_comment

Update gist comment.

Feeds - Included

#feed

Get a Feed by name.

#feeds

List Feeds.

Events - Included

#issue_event

Get information on a single Issue Event.

#issue_events

List events for an Issue.

#organization_events

List all events for an organization.

#organization_public_events

List an organization's public events.

#public_events

List all public events for GitHub.

#received_events

List events that a user has received.

#received_public_events

List public events a user has received.

#repo_issue_events
#repository_events

List events for a repository.

#repository_issue_events

Get all Issue Events for a given Repository.

#repository_network_events

List public events for a repository's network.

#user_events

List all user events.

#user_public_events

List public user events.

Emojis - Included

#emojis

List all emojis used on GitHub.

Downloads - Included

#delete_download

Delete a single download for a repository.

#download

Get single download for a repository.

#downloads

List available downloads for a repository.

#list_downloads

Deployments - Included

#create_deployment

Create a deployment for a ref.

#create_deployment_status

Create a deployment status for a Deployment.

#delete_deployment

Delete a Deployment.

#deployment

Fetch a single deployment for a repository.

#deployment_statuses

List all statuses for a Deployment.

#deployments

List all deployments for a repository.

#list_deployment_statuses
#list_deployments

Contents - Included

#add_content
#add_contents
#archive_link

This method will provide a URL to download a tarball or zipball archive for a repository.

#content
#contents

Receive a listing of a repository folder or the contents of a file.

#create_content
#create_contents

Add content to a repository.

#delete_content
#delete_contents

Delete content in a repository.

#readme

Receive the default Readme for a repository.

#remove_content
#remove_contents
#update_content
#update_contents

Update content in a repository.

CommunityProfile - Included

#community_profile

Get community profile metrics for a repository.

CommitBranches - Included

#commit_branches

List branches for a single HEAD commit.

CommitPulls - Included

#commit_pulls

List pulls for a single commit.

CommitComments - Included

#commit_comment

Get a single commit comment.

#commit_comments

List comments for a single commit.

#create_commit_comment

Create a commit comment.

#delete_commit_comment

Delete a commit comment.

#list_commit_comments

List all commit comments.

#update_commit_comment

Update a commit comment.

Commits - Included

#commit

Get a single commit.

#commits

List commits.

#commits_before

Get commits before a specified date.

#commits_between

Get commits made between two nominated dates.

#commits_on

Get commits on a specified date.

#commits_since

Get commits after a specified date.

#compare

Compare two commits.

#create_commit

Create a commit.

#git_commit

Get a detailed git commit.

#list_commits

Alias for Commits#commits.

#merge

Merge a branch or sha.

Checks - Included

#check_run

Get a single check run.

#check_run_annotations

List annotations for a check run.

#check_runs_for_check_suite

List check runs in a check suite.

#check_runs_for_ref

List check runs for a specific ref.

#check_suite

Get a single check suite.

#check_suites_for_ref

List check suites for a specific ref.

#create_check_run

Create a check run.

#create_check_suite

Create a check suite.

#list_check_runs_for_check_suite
#list_check_runs_for_ref
#list_check_suites_for_ref
#rerequest_check_suite

Rerequest check suite.

#set_check_suite_preferences

Set preferences for check suites on a repository.

#update_check_run

Update a check run.

Authorizations - Included

#authorization

Get a single authorization for the authenticated user.

#authorizations

List the authenticated user's authorizations.

#authorize_url

Get the URL to authorize a user for an application via the web flow.

#create_authorization

Create an authorization for the authenticated user.

#delete_authorization

Delete an authorization for the authenticated user.

#revoke_all_application_authorizations

Revoke all tokens for an app.

#scopes

Check scopes for a token.

#update_authorization

Update an authorization for the authenticated user.

ActionsSecrets - Included

#create_or_update_secret

Create or update secrets.

#delete_secret

Delete a secret.

#get_public_key

Get public key for secrets encryption.

#get_secret

Get a secret.

#list_secrets

List secrets.

Warnable - Included

#octokit_warn

Wrapper around Kernel#warn to print warnings unless OCTOKIT_SILENT is set to true.

Preview - Included

Connection - Included

#agent

Hypermedia agent for the GitHub API.

#delete

Make a HTTP DELETE request.

#get

Make a HTTP GET request.

#head

Make a HTTP HEAD request.

#last_response

Response for last HTTP request.

#paginate

Make one or more HTTP GET requests, optionally fetching the next page of results from URL in Link response header based on value in #auto_paginate.

#patch

Make a HTTP PATCH request.

#post

Make a HTTP POST request.

#put

Make a HTTP PUT request.

#root

Fetch the root resource for the API.

#boolean_from_response

Executes the request, checking if it was successful.

#parse_query_and_convenience_headers, #request, #reset_agent, #sawyer_options

Configurable - Included

#configure

Set configuration options using a block.

#reset!

Reset configuration options to default values.

#same_options?

Compares client options to a Hash of requested options.

#setup
#fetch_client_id_and_secret, #options

Authentication - Included

Constructor Details

.new(options = {}) ⇒ Client

[ GitHub ]

  
# File 'lib/octokit/client.rb', line 133

def initialize(options = {})
  # Use options passed in, but fall back to module defaults
  #
  # rubocop:disable Style/HashEachMethods
  #
  # This may look like a `.keys.each` which should be replaced with `#each_key`, but
  # this doesn't actually work, since `#keys` is just a method we've defined ourselves.
  # The class doesn't fulfill the whole `Enumerable` contract.
  Octokit::Configurable.keys.each do |key|
    # rubocop:enable Style/HashEachMethods
    value = options[key].nil? ? Octokit.instance_variable_get(:"@#{key}") : options[key]
    instance_variable_set(:"@#{key}", value)
  end

   unless user_authenticated? || application_authenticated?
end

Instance Attribute Details

#access_token=(value) (writeonly)

Set OAuth access token for authentication

Parameters:

  • value (String)

    40 character GitHub OAuth access token

[ GitHub ]

  
# File 'lib/octokit/client.rb', line 218

def access_token=(value)
  reset_agent
  @access_token = value
end

#bearer_token=(value) (writeonly)

Set Bearer Token for authentication

Parameters:

  • value (String)

    JWT

[ GitHub ]

  
# File 'lib/octokit/client.rb', line 226

def bearer_token=(value)
  reset_agent
  @bearer_token = value
end

#client_id=(value) (writeonly)

Set OAuth app client_id

Parameters:

  • value (String)

    20 character GitHub OAuth app client_id

[ GitHub ]

  
# File 'lib/octokit/client.rb', line 234

def client_id=(value)
  reset_agent
  @client_id = value
end

#client_secret=(value) (writeonly)

Set OAuth app client_secret

Parameters:

  • value (String)

    40 character GitHub OAuth app client_secret

[ GitHub ]

  
# File 'lib/octokit/client.rb', line 242

def client_secret=(value)
  reset_agent
  @client_secret = value
end

#login=(value) (writeonly)

Set username for authentication

Parameters:

  • value (String)

    GitHub username

[ GitHub ]

  
# File 'lib/octokit/client.rb', line 202

def login=(value)
  reset_agent
  @login = value
end

#password=(value) (writeonly)

Set password for authentication

Parameters:

  • value (String)

    GitHub password

[ GitHub ]

  
# File 'lib/octokit/client.rb', line 210

def password=(value)
  reset_agent
  @password = value
end

Instance Method Details

#as_app(key = client_id, secret = client_secret) {|app_client| ... }

Duplicate client using client_id and client_secret as Basic Authentication credentials.

Examples:

Octokit.client_id = "foo"
Octokit.client_secret = "bar"

# GET https://api.github.com/?client_id=foo&client_secret=bar
Octokit.get "/"

Octokit.client.as_app do |client|
  # GET https://foo:bar@api.github.com/
  client.get "/"
end

Yields:

  • (app_client)
[ GitHub ]

  
# File 'lib/octokit/client.rb', line 186

def as_app(key = client_id, secret = client_secret)
  if key.to_s.empty? || secret.to_s.empty?
    raise ApplicationCredentialsRequired, 'client_id and client_secret required'
  end

  app_client = dup
  app_client.client_id = app_client.client_secret = nil
  app_client.    = key
  app_client.password = secret

  yield app_client if block_given?
end

#client_without_redirects(options = {})

[ GitHub ]

  
# File 'lib/octokit/client.rb', line 247

def client_without_redirects(options = {})
  conn_opts = @connection_options
  conn_opts[:url] = @api_endpoint
  conn_opts[:builder] = @middleware.dup if @middleware
  conn_opts[:proxy] = @proxy if @proxy
  conn_opts[:ssl] = { verify_mode: @ssl_verify_mode } if @ssl_verify_mode
  conn = Faraday.new(conn_opts) do |http|
    if basic_authenticated?
      http.request(*FARADAY_BASIC_AUTH_KEYS, @login, @password)
    elsif token_authenticated?
      http.request :authorization, 'token', @access_token
    elsif bearer_authenticated?
      http.request :authorization, 'Bearer', @bearer_token
    end
    http.headers['accept'] = options[:accept] if options.key?(:accept)
  end
  conn.builder.delete(Octokit::Middleware::FollowRedirects)

  conn
end

#inspectString

Text representation of the client, masking tokens and passwords

[ GitHub ]

  
# File 'lib/octokit/client.rb', line 153

def inspect
  inspected = super

  # mask password
  inspected.gsub! @password, '*******' if @password
  if @management_console_password
    inspected.gsub! @management_console_password, '*******'
  end
  inspected.gsub! @bearer_token, '********' if @bearer_token
  # Only show last 4 of token, secret
  if @access_token
    inspected.gsub! @access_token, "#{'*' * 36}#{@access_token[36..-1]}"
  end
  if @client_secret
    inspected.gsub! @client_secret, "#{'*' * 36}#{@client_secret[36..-1]}"
  end

  inspected
end

#user_path(user, path) (private)

convenience method for constructing a user specific path, if the user is logged in

[ GitHub ]

  
# File 'lib/octokit/client/users.rb', line 434

def user_path(user, path)
  if user ==  && user_authenticated?
    "user/#{path}"
  else
    "#{User.path user}/#{path}"
  end
end