class Octokit::Client
- Octokit::Client
- Reference
- Object
Overview
User client for interacting with the GitHub API.
The Client
class is your main entrypoint into the GitHub user API. If
you want to access the enterprise admin or enterprise management APIs,
see EnterpriseAdminClient
and EnterpriseManagementClient
respectively.
Configuration:
Configuration options for Client
are stored in Configurable
and include:
- access_token :
String
- auto_paginate :
Bool
- bearer_token :
String
- client_id :
String
- client_secret :
String
- default_media_type :
String
- connection_options :
Halite::Options
- middleware :
Array(Halite::Feature)
- per_page :
Int32
- proxy :
String
- ssl_verify_mode :
Int32
- user_agent :
String
The following items are setters only:
- api_endpoint :
String
- login :
String
- password :
String
- web_endpoint :
String
Defaults for these are stored in Default
. Most can be set using
environment variables.
Examples:
With standard auth:
@client = Octokit::Client.new("watzon", "PASSWORD")
With access token:
@client = Octokit::Client.new("watzon", access_token: "ACCESS_TOKEN")
With bearer token:
@client = Octokit::Client.new("watzon", bearer_token: "BEARER_TOKEN")
Included Modules
- Octokit::Authentication
- Octokit::Client::Authorizations
- Octokit::Client::Issues
- Octokit::Client::Markdown
- Octokit::Client::Organizations
- Octokit::Client::PubSubHubbub
- Octokit::Client::RateLimit
- Octokit::Client::Releases
- Octokit::Client::Repositories
- Octokit::Client::Say
- Octokit::Client::Search
- Octokit::Client::Statuses
- Octokit::Client::Users
- Octokit::Configurable
- Octokit::Connection
- Octokit::Preview
- Octokit::Warnable
Defined in:
octokit/client.croctokit/client/authorizations.cr
octokit/client/issues.cr
octokit/client/markdown.cr
octokit/client/organizations.cr
octokit/client/pub_sub_hubbub.cr
octokit/client/rate_limit.cr
octokit/client/releases.cr
octokit/client/repositories.cr
octokit/client/say.cr
octokit/client/search.cr
octokit/client/statuses.cr
octokit/client/users.cr
Constant Summary
-
CONVENIENCE_HEADERS =
Set {"accept", "content_type"}
Constructors
-
.new(login : String | Nil = nil, password : String | Nil = nil, access_token : String | Nil = nil, bearer_token : String | Nil = nil, client_id : String | Nil = nil, client_secret : String | Nil = nil)
Create a new Client instance.
-
.new(login : String | Nil = nil, password : String | Nil = nil, access_token : String | Nil = nil, bearer_token : String | Nil = nil, client_id : String | Nil = nil, client_secret : String | Nil = nil, &)
Create a new Client instance yielding a block.
Instance Method Summary
-
#access_token=(value : String)
Set OAuth access token for authentication
- #as_app(key = @client_id, secret = @client_secret, &)
-
#bearer_token=(value : String)
Set Bearer Token for authentication
-
#client_id=(value : String)
Set OAuth app client_id
-
#client_secret=(value : String)
Set OAuth app client_secret
- #client_without_redirects(options = {} of String => String)
- #ensure_basic_authenticated!
- #ensure_token_authenticated!
-
#inspect
Text representation of the client, masking tokens and passwords
-
#login=(value : String)
Set username for authentication
-
#password=(value : String)
Set password for authentication
Instance methods inherited from module Octokit::Client::Say
say(text = nil)
say
Instance methods inherited from module Octokit::Client::Statuses
combined_status(repo, ref)
combined_status,
create_status(repo, sha, state, **options)
create_status,
statuses(repo, sha)
statuses
Instance methods inherited from module Octokit::Client::Search
search_code(query, **options) : Paginator(Models::CodeSearchResult)
search_code,
search_commits(query, **options) : Paginator(Models::CommitsSearchResult)
search_commits,
search_issues(query, **options) : Paginator(Models::IssuesSearchResult)
search_issues,
search_repositories(query, **options) : Paginator(Models::RepositoriesSearchResult)
search_repositories,
search_users(query, **options) : Paginator(Models::UsersSearchResult)
search_users
Instance methods inherited from module Octokit::Client::Releases
create_release(repo, tag_name, **options)
create_release,
delete_release(repo, id, **options)
delete_release,
delete_release_asset(repo, id)
delete_release_asset,
latest_release(repo)
latest_release,
release(repo, id)
release,
release_asset(repo, id)
release_asset,
release_assets(repo, id, **options)
release_assets,
release_for_tag(repo, tag_name)
release_for_tag,
releases(path, **options)
releases,
update_release(repo, id, **options)
update_release,
update_release_asset(repo, id, **options)
update_release_asset,
upload_asset(repo, id, path_or_file, **options)
upload_asset
Instance methods inherited from module Octokit::Client::Organizations
organization(organization)
organization,
organizations
organizations,
organizations_for_authenticated_user
organizations_for_authenticated_user,
organizations_for_user(user)
organizations_for_user
Instance methods inherited from module Octokit::Client::Repositories
add_collaborator(repo, collaborator, **options)
add_collaborator,
add_deploy_key(repo, title, key, read_only = false)
add_deploy_key,
all_repositories(**options)
all_repositories,
branch(repo, branch)
branch,
branch_protection(repo, branch)
branch_protection,
branches(repo, get_protected = false)
branches,
check_assignee(repo, assignee)
check_assignee,
collaborator?(repo, collaborator)
collaborator?,
collaborators(repo, affiliation = :all)
collaborators,
contributors(repo, anon = false)
contributors,
create_repository(repo, organization = nil, **options)
create_repository,
delete_repository(repo)
delete_repository,
delete_subscription(repo, **options)
delete_subscription,
deploy_key(repo, id)
deploy_key,
deploy_keys(repo)
deploy_keys,
edit_repository(repo : String | Repository, **options)
edit_repository,
fork(repo)
fork,
forks(repo, sort = "newest")
forks,
languages(repo)
languages,
permission_level(repo, collaborator)
permission_level,
protect_branch(repo, branch, **options)
protect_branch,
remove_collaborator(repo, collaborator)
remove_collaborator,
remove_deploy_key(repo, id)
remove_deploy_key,
replace_all_topics(repo, names)
replace_all_topics,
repositories(user = nil, **options)
repositories,
repository(path)
repository,
repository?(repo)
repository?,
repository_assignees(repo)
repository_assignees,
repository_teams(repo)
repository_teams,
set_private(repo)
set_private,
set_public(repo)
set_public,
star(repo)
star,
stargazers(repo)
stargazers,
subscribers(repo)
subscribers,
subscription(repo)
subscription,
tags(repo)
tags,
topics(repo)
topics,
transfer_repository(repo, new_owner, team_ids : Array(Int32))
transfer_repository,
unprotect_branch(repo, branch)
unprotect_branch,
unstar(repo)
unstar,
unwatch(repo)
unwatch,
update_subscription(repo, **options)
update_subscription,
watch(repo)
watch
Instance methods inherited from module Octokit::Client::RateLimit
rate_limit
rate_limit,
rate_limit!
rate_limit!
Instance methods inherited from module Octokit::Client::Users
add_email(email)
add_email,
add_key(title, key)
add_key,
all_users
all_users,
emails(**options)
emails,
exchange_code_for_token(code, app_id = client_id, app_secret = client_secret)
exchange_code_for_token,
follow(user)
follow,
followers(user, **options)
followers,
following(user, **options)
following,
follows?(user, target = nil)
follows?,
key(key_id)
key,
keys(user = nil)
keys,
public_emails(**options)
public_emails,
remove_email(email)
remove_email,
remove_key(id)
remove_key,
starred(user = login, **options)
starred,
starred?(repo)
starred?,
subscriptions(user = login, **options)
subscriptions,
toggle_email_visibility(options)
toggle_email_visibility,
unfollow(user)
unfollow,
update_user(**options)
update_user,
user(user = nil)
user,
validate_credentials(options = nil)
validate_credentials
Instance methods inherited from module Octokit::Client::PubSubHubbub
subscribe(topic, callback, secret = nil)
subscribe,
subscribe_service_hook(repo, service_name, service_arguments = {} of String => String, secret = nil)
subscribe_service_hook,
unsubscribe(topic, callback)
unsubscribe,
unsubscribe_service_hook(repo, service_name)
unsubscribe_service_hook
Instance methods inherited from module Octokit::Client::Markdown
markdown(text, mode = :markdown, context = nil)
markdown
Instance methods inherited from module Octokit::Client::Issues
add_assignees(repo, number : Int32, assignees : Array(String | User))
add_assignees,
add_comment(repo, number : Int32, comment : String)
add_comment,
close_issue(repo, number : Int32, **options)
close_issue,
create_issue(repo, title, body, **options)
create_issue,
delete_comment(repo, number : Int32)
delete_comment,
issue(repo, number : Int32)
issue,
issue_comment(repo, number : Int32)
issue_comment,
issue_comments(repo, number : Int32)
issue_comments,
issue_timeline(repo, number : Int32)
issue_timeline,
issues_comments(repo, number : Int32, **options)
issues_comments,
list_assignees(repo)
list_assignees,
list_issues(repo = nil, **options)
list_issues,
lock_issue(repo, number : Int32, **options)
lock_issue,
org_issues(org, **options)
org_issues,
remove_assignees(repo, number : Int32, assignees : Array(String | User))
remove_assignees,
reopen_issue(repo, number : Int32, **options)
reopen_issue,
unlock_issue(repo, number : Int32, **options)
unlock_issue,
update_comment(repo, number : Int32, comment : String)
update_comment,
update_issue(repo, number : Int32, **options)
update_issue,
user_issues(**options)
user_issues
Instance methods inherited from module Octokit::Client::Authorizations
authorizations(number : Int32) : Authorizationauthorizations(**options) : Connection::Paginator(Authorization) authorizations, authorize_url(app_id = client_id, **options) : String authorize_url, check_application_authorization(token, key = client_id) : Authorization check_application_authorization, create_authorization(*, client_id = nil, client_secret = nil, scopes = [] of String, note = nil, note_url = nil, idempotent = nil, fingerprint = nil) : Authorization create_authorization, delete_authorization(number : Int32) : Bool delete_authorization, reset_application_authorization(token, key = client_id) : Authorization reset_application_authorization, revoke_application_authorization(token, key = client_id) : Authorization revoke_application_authorization, scopes(token = @access_token, headers = nil) : Array(String) scopes, update_authorization(number : Int32, **options) : Authorization update_authorization
Instance methods inherited from module Octokit::Warnable
octokit_warn(message)
octokit_warn
Instance methods inherited from module Octokit::Preview
api_media_type(type)
api_media_type,
warn_preview(type)
warn_preview
Instance methods inherited from module Octokit::Connection
agent
agent,
delete(url, options = nil)
delete,
get(url, options = nil)
get,
head(url, options = nil)
head,
last_response
last_response,
paginate(klass : T.class, url : String, *, start_page = nil, per_page = nil, auto_paginate = @auto_paginate, options = nil) : Paginator(T) forall Tpaginate(klass : T.class, url : String, *, start_page = nil, per_page = nil, auto_paginate = @auto_paginate, options = nil, &) paginate, patch(url, options = nil) patch, post(url, options = nil) post, put(url, options = nil) put, root root
Instance methods inherited from module Octokit::Authentication
application_authenticated?
application_authenticated?,
basic_authenticated?
basic_authenticated?,
bearer_authenticated?
bearer_authenticated?,
token_authenticated?
token_authenticated?,
user_authenticated?
user_authenticated?
Instance methods inherited from module Octokit::Configurable
access_token
access_token,
access_token=(token)
access_token=,
add_middleware(middleware : Halite::Feature)
add_middleware,
api_endpoint
api_endpoint,
api_endpoint=(val)
api_endpoint=,
auto_paginate
auto_paginate,
auto_paginate=(val)
auto_paginate=,
bearer_token
bearer_token,
bearer_token=(token)
bearer_token=,
client_id
client_id,
client_id=(val)
client_id=,
client_secret
client_secret,
client_secret=(val)
client_secret=,
configure(&)
configure,
connection_options
connection_options,
connection_options=(val)
connection_options=,
default_media_type
default_media_type,
default_media_type=(val)
default_media_type=,
logger
logger,
logger=(val)
logger=,
login
login,
login=(val)
login=,
management_console_endpoint
management_console_endpoint,
management_console_endpoint=(val)
management_console_endpoint=,
middleware
middleware,
middleware=(val)
middleware=,
password=(val)
password=,
per_page
per_page,
per_page=(val)
per_page=,
proxy
proxy,
proxy=(val)
proxy=,
reset!
reset!,
ssl_verify_mode
ssl_verify_mode,
ssl_verify_mode=(mode)
ssl_verify_mode=,
user_agent
user_agent,
user_agent=(val)
user_agent=,
web_endpoint
web_endpoint,
web_endpoint=(val)
web_endpoint=
Instance methods inherited from module Octokit::Authentication
application_authenticated?
application_authenticated?,
basic_authenticated?
basic_authenticated?,
bearer_authenticated?
bearer_authenticated?,
token_authenticated?
token_authenticated?,
user_authenticated?
user_authenticated?
Constructor Detail
Create a new Client instance.
Example:
cli = Octokit::Client.new("watzon", "MY_PASSWORD")
pp cli.user # Show information about the logged in user
Create a new Client instance yielding a block.
Example:
Octokit::Client.new("watzon", "MY_PASSWORD") do |cli|
pp cli.user # Show information about the logged in user
end