Class: Octokit::Client
Overview
Client
for the GitHub API
Constant Summary
-
CONVENIENCE_HEADERS =
Header keys that can be passed in options hash to
#get
,#head
Set.new(%i[accept content_type])
Authentication
- Included
Connection
- Included
Preview
- Included
ServiceStatus
- Included
Class Method Summary
- .new(options = {}) ⇒ Client constructor
Instance Attribute Summary
-
#access_token=(value)
writeonly
Set OAuth access token for authentication.
-
#bearer_token=(value)
writeonly
Set Bearer Token for authentication.
-
#client_id=(value)
writeonly
Set OAuth app client_id.
-
#client_secret=(value)
writeonly
Set OAuth app client_secret.
-
#login=(value)
writeonly
Set username for authentication.
-
#password=(value)
writeonly
Set password for authentication.
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
-
#as_app(key = client_id, secret = client_secret) {|app_client| ... }
Duplicate client using client_id and client_secret as Basic Authentication credentials.
- #client_without_redirects(options = {})
-
#inspect ⇒ String
Text representation of the client, masking tokens and passwords.
-
#user_path(user, path)
private
convenience method for constructing a user specific path, if the user is logged in.
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 | Alias for Users#subscriptions. |
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 | Alias for Statuses#statuses. |
#status | Alias for Statuses#combined_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 | Alias for Stats#contributors_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 | Alias for Stats#punch_card_stats. |
#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
#search_code |
|
#search_commits |
|
#search_issues |
|
#search_repos | Alias for Search#search_repositories. |
#search_repositories |
|
#search_users |
|
#search |
Say
- Included
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
#accept_repo_invitation | |
#accept_repository_invitation | Accept a repository invitation. |
#decline_invitation | |
#decline_repository_invitation | Decline a repository invitation. |
#delete_repo_invitation | |
#delete_repository_invitation | Delete an invitation for a repository. |
#invite_user_to_repo | |
#invite_user_to_repository | Invite a user to a repository. |
#repo_invitations | Alias for RepositoryInvitations#repository_invitations. |
#repository_invitations | List all invitations for a repository. |
#update_repo_invitation | |
#update_repository_invitation | Update an invitation for a repository. |
#user_repo_invitations | |
#user_repository_invitations | List all repository invitations for the user. |
Repositories
- Included
#add_collab | Alias for Repositories#add_collaborator. |
#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? |
|
#collaborators | List collaborators. |
#collabs | Alias for Repositories#collaborators. |
#contribs | Alias for Repositories#contributors. |
#contributors | List contributors to a repo. |
#create | Alias for Repositories#create_repository. |
#create_repo | Alias for Repositories#create_repository. |
#create_repo_from_template | Alias for Repositories#create_repository_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 | Alias for Repositories#delete_repository. |
#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 | Alias for Repositories#edit_repository. |
#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 | Alias for Repositories#branch. |
#languages | List languages of code in the repo. |
#list_deploy_keys | Alias for Repositories#deploy_keys. |
#list_repos | Alias for Repositories#repositories. |
#list_repositories | Alias for Repositories#repositories. |
#network | Alias for Repositories#forks. |
#permission_level | Get a user's permission level for a repo. |
#protect_branch | Lock a single branch from a repository. |
#remove_collab | Alias for Repositories#remove_collaborator. |
#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 | Alias for Repositories#repository. |
#repo_assignees | Alias for Repositories#repository_assignees. |
#repo_teams | Alias for Repositories#repository_teams. |
#repos | Alias for Repositories#repositories. |
#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 | Alias for Repositories#repository_teams. |
#topics | List all topics for a repository. |
#transfer_repo | Alias for Repositories#transfer_repository. |
#transfer_repository | Transfer repository. |
#unprotect_branch | Unlock a single branch from a repository. |
#unstar | Unstar a repository. |
#unwatch | Unwatch a repository. |
#update | Alias for Repositories#edit_repository. |
#update_deploy_key | Alias for Repositories#edit_deploy_key. |
#update_repository | Alias for Repositories#edit_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 | Alias for Releases#update_release. |
#edit_release_asset | Alias for Releases#update_release_asset. |
#latest_release | Get the latest release. |
#list_releases | Alias for Releases#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 | Alias for RateLimit#rate_limit. |
#ratelimit! | Alias for RateLimit#rate_limit!. |
#ratelimit_remaining | Alias for RateLimit#rate_limit_remaining. |
#ratelimit_remaining! | Alias for RateLimit#rate_limit_remaining!. |
PullRequests
- Included
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 | Alias for Projects#create_org_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 | Alias for Projects#org_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 |
#list_pages_builds | Alias for Pages#pages_builds. |
#pages | List Pages information for a repository. |
#pages_build | Get a specific |
#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
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
#check_application_authorization | Alias for OauthApplications#check_token. |
#check_token | Check if a token is valid. |
#delete_app_authorization | Delete an app authorization. |
#delete_app_token | Delete an app token. |
#delete_application_authorization | Alias for OauthApplications#delete_app_token. |
#reset_application_authorization | Alias for OauthApplications#reset_token. |
#reset_token | Reset a token. |
#revoke_application_authorization | Alias for OauthApplications#delete_app_token. |
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 | Alias for Notifications#repository_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 | Alias for Milestones#update_milestone. |
#list_milestones | List milestones for a repository. |
#milestone | Get a single milestone for a repository. |
#milestones | Alias for Milestones#list_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 |
#plan_for_account | Get the plan associated with a given GitHub account. |
Markdown
- Included
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 |
|
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 | Alias for Issues#list_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 | Alias for Issues#create_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
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 | Alias for ActionsWorkflowRuns#repository_workflow_runs. |
#list_workflow_runs | Alias for ActionsWorkflowRuns#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 | Alias for ActionsWorkflows#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 | Alias for Hooks#edit_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
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 | Alias for Events#repository_issue_events. |
#repository_events | List events for a repository. |
#repository_issue_events | Get all Issue Events for a given |
#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 | Alias for Downloads#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 | Alias for Deployments#deployment_statuses. |
#list_deployments | Alias for Deployments#deployments. |
Contents
- Included
#add_content | Alias for Contents#create_contents. |
#add_contents | Alias for Contents#create_contents. |
#archive_link | This method will provide a URL to download a tarball or zipball archive for a repository. |
#content | Alias for Contents#contents. |
#contents | Receive a listing of a repository folder or the contents of a file. |
#create_content | Alias for Contents#create_contents. |
#create_contents | Add content to a repository. |
#delete_content | Alias for Contents#delete_contents. |
#delete_contents | Delete content in a repository. |
#readme | Receive the default Readme for a repository. |
#remove_content | Alias for Contents#delete_contents. |
#remove_contents | Alias for Contents#delete_contents. |
#update_content | Alias for Contents#update_contents. |
#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 | Alias for Checks#check_runs_for_check_suite. |
#list_check_runs_for_ref | Alias for Checks#check_runs_for_ref. |
#list_check_suites_for_ref | Alias for Checks#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 |
|
#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 |
#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 | Alias for Configurable#reset!. |
#fetch_client_id_and_secret, #options |
Authentication
- Included
Constructor Details
.new(options = {}) ⇒ Client
# File 'lib/octokit/client.rb', line 133
def initialize( = {}) # 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 = [key].nil? ? Octokit.instance_variable_get(:"@#{key}") : [key] instance_variable_set(:"@#{key}", value) end login_from_netrc unless user_authenticated? || application_authenticated? end
Instance Attribute Details
#access_token=(value) (writeonly)
Set OAuth access token for authentication
# 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
# 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
# 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
# File 'lib/octokit/client.rb', line 242
def client_secret=(value) reset_agent @client_secret = value end
#login=(value) (writeonly)
Set username for authentication
# File 'lib/octokit/client.rb', line 202
def login=(value) reset_agent @login = value end
#password=(value) (writeonly)
Set password for authentication
# 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.
# 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.login = 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( = {}) 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 :, 'token', @access_token elsif bearer_authenticated? http.request :, 'Bearer', @bearer_token end http.headers['accept'] = [:accept] if .key?(:accept) end conn.builder.delete(Octokit::Middleware::FollowRedirects) conn end
#inspect ⇒ String
Text representation of the client, masking tokens and passwords
# 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