This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Octokit
|
||||
class EnterpriseAdminClient
|
||||
# Methods for the Enterprise Admin Stats API
|
||||
#
|
||||
# @see https://developer.github.com/v3/enterprise-admin/admin_stats/
|
||||
module AdminStats
|
||||
# Get all available stats
|
||||
#
|
||||
# @return [Sawyer::Resource] All available stats
|
||||
# @example Get all available stats
|
||||
# @client.admin_stats
|
||||
def admin_stats
|
||||
get_admin_stats 'all'
|
||||
end
|
||||
|
||||
# Get only repository-related stats
|
||||
#
|
||||
# @return [Sawyer::Resource] Only repository-related stats
|
||||
# @example Get only repository-related stats
|
||||
# @client.admin_repository_stats
|
||||
def admin_repository_stats
|
||||
get_admin_stats 'repos'
|
||||
end
|
||||
|
||||
# Get only hooks-related stats
|
||||
#
|
||||
# @return [Sawyer::Resource] Only hooks-related stats
|
||||
# @example Get only hooks-related stats
|
||||
# @client.admin_hooks_stats
|
||||
def admin_hooks_stats
|
||||
get_admin_stats 'hooks'
|
||||
end
|
||||
|
||||
# Get only pages-related stats
|
||||
#
|
||||
# @return [Sawyer::Resource] Only pages-related stats
|
||||
# @example Get only pages-related stats
|
||||
# @client.admin_pages_stats
|
||||
def admin_pages_stats
|
||||
get_admin_stats 'pages'
|
||||
end
|
||||
|
||||
# Get only organization-related stats
|
||||
#
|
||||
# @return [Sawyer::Resource] Only organization-related stats
|
||||
# @example Get only organization-related stats
|
||||
# @client.admin_organization_stats
|
||||
def admin_organization_stats
|
||||
get_admin_stats 'orgs'
|
||||
end
|
||||
|
||||
# Get only user-related stats
|
||||
#
|
||||
# @return [Sawyer::Resource] Only user-related stats
|
||||
# @example Get only user-related stats
|
||||
# @client.admin_users_stats
|
||||
def admin_users_stats
|
||||
get_admin_stats 'users'
|
||||
end
|
||||
|
||||
# Get only pull request-related stats
|
||||
#
|
||||
# @return [Sawyer::Resource] Only pull request-related stats
|
||||
# @example Get only pull request-related stats
|
||||
# @client.admin_pull_requests_stats
|
||||
def admin_pull_requests_stats
|
||||
get_admin_stats 'pulls'
|
||||
end
|
||||
|
||||
# Get only issue-related stats
|
||||
#
|
||||
# @return [Sawyer::Resource] Only issue-related stats
|
||||
# @example Get only issue-related stats
|
||||
# @client.admin_issues_stats
|
||||
def admin_issues_stats
|
||||
get_admin_stats 'issues'
|
||||
end
|
||||
|
||||
# Get only milestone-related stats
|
||||
#
|
||||
# @return [Sawyer::Resource] Only milestone-related stats
|
||||
# @example Get only milestone-related stats
|
||||
# @client.admin_milestones_stats
|
||||
def admin_milestones_stats
|
||||
get_admin_stats 'milestones'
|
||||
end
|
||||
|
||||
# Get only gist-related stats
|
||||
#
|
||||
# @return [Sawyer::Resource] Only only gist-related stats
|
||||
# @example Get only gist-related stats
|
||||
# @client.admin_gits_stats
|
||||
def admin_gists_stats
|
||||
get_admin_stats 'gists'
|
||||
end
|
||||
|
||||
# Get only comment-related stats
|
||||
#
|
||||
# @return [Sawyer::Resource] Only comment-related stats
|
||||
# @example Get only comment-related stats
|
||||
# @client.admin_comments_stats
|
||||
def admin_comments_stats
|
||||
get_admin_stats 'comments'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# @private Get enterprise stats
|
||||
#
|
||||
# @param metric [String] The metrics you are looking for
|
||||
# @return [Sawyer::Resource] Magical unicorn stats
|
||||
def get_admin_stats(metric)
|
||||
get "enterprise/stats/#{metric}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,17 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Octokit
|
||||
class EnterpriseAdminClient
|
||||
# Methods for the Enterprise License API
|
||||
#
|
||||
# @see https://developer.github.com/v3/enterprise-admin/license/
|
||||
module License
|
||||
# Get information about the Enterprise license
|
||||
#
|
||||
# @return [Sawyer::Resource] The license information
|
||||
def license_info
|
||||
get 'enterprise/settings/license'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,26 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Octokit
|
||||
class EnterpriseAdminClient
|
||||
# Methods for the Enterprise Orgs API
|
||||
#
|
||||
# @see https://developer.github.com/v3/enterprise-admin/orgs/
|
||||
module Orgs
|
||||
# Create a new organization on the instance.
|
||||
#
|
||||
# @param login [String] The organization's username.
|
||||
# @param admin [String] The login of the user who will manage this organization.
|
||||
# @param options [Hash] A set of options.
|
||||
# @option options [String] :profile_name The organization's display name.
|
||||
# @return [nil]
|
||||
# @see https://developer.github.com/v3/enterprise-admin/orgs/#create-an-organization
|
||||
# @example
|
||||
# @admin_client.create_organization('SuchAGreatOrg', 'gjtorikian')
|
||||
def create_organization(login, admin, options = {})
|
||||
options[:login] = login
|
||||
options[:admin] = admin
|
||||
post 'admin/organizations', options
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,82 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Octokit
|
||||
class EnterpriseAdminClient
|
||||
# Methods for the Enterprise Search Indexing API
|
||||
#
|
||||
# @see https://developer.github.com/v3/enterprise-admin/search_indexing/
|
||||
module SearchIndexing
|
||||
# Queue a User or Organization to be indexed
|
||||
#
|
||||
# @param user [String] A GitHub Enterprise user or organization
|
||||
# @return [Sawyer:Resource] Result of the queuing containing `:message`
|
||||
def index_user(user)
|
||||
queue_index user
|
||||
end
|
||||
alias index_organization index_user
|
||||
|
||||
# Queue a Repository to be indexed
|
||||
#
|
||||
# @param repo [String, Hash, Repository] A GitHub repository
|
||||
# @return [Sawyer:Resource] Result of the queuing containing `:message`
|
||||
def index_repository(repo)
|
||||
queue_index Repository.new repo
|
||||
end
|
||||
|
||||
# Queue a repository's Issues to be indexed
|
||||
#
|
||||
# @param repo [String, Hash, Repository] A GitHub repository
|
||||
# @return [Sawyer:Resource] Result of the queuing containing `:message`
|
||||
def index_repository_issues(repo)
|
||||
queue_index "#{Repository.new repo}/issues"
|
||||
end
|
||||
|
||||
# Queue a repository's code to be indexed
|
||||
#
|
||||
# @param repo [String, Hash, Repository] A GitHub repository
|
||||
# @return [Sawyer:Resource] Result of the queuing containing `:message`
|
||||
def index_repository_code(repo)
|
||||
queue_index "#{Repository.new repo}/code"
|
||||
end
|
||||
|
||||
# Queue a user's or organization's repositories to be indexed
|
||||
#
|
||||
# @param user [String] A GitHub Enterprise user or organization
|
||||
# @return [Sawyer:Resource] Result of the queuing containing `:message`
|
||||
def index_users_repositories(user)
|
||||
queue_index "#{user}/*"
|
||||
end
|
||||
alias index_organizations_repositories index_users_repositories
|
||||
|
||||
# Queue an index of all the issues across all of a user's or
|
||||
# organization's repositories
|
||||
#
|
||||
# @param user [String] A GitHub Enterprise user or organization
|
||||
# @return [Sawyer:Resource] Result of the queuing containing `:message`
|
||||
def index_users_repositories_issues(user)
|
||||
queue_index "#{user}/*/issues"
|
||||
end
|
||||
alias index_organizations_repositories_issues index_users_repositories_issues
|
||||
|
||||
# Queue an index of all the code contained in all of a user's or
|
||||
# organization's repositories
|
||||
#
|
||||
# @param user [String] A GitHub Enterprise user or organization
|
||||
# @return [Sawyer:Resource] Result of the queuing containing `:message`
|
||||
def index_users_repositories_code(user)
|
||||
queue_index "#{user}/*/code"
|
||||
end
|
||||
alias index_organizations_repositories_code index_users_repositories_code
|
||||
|
||||
private
|
||||
|
||||
# @private Queue a target for indexing
|
||||
#
|
||||
# @param target [String] Target to index
|
||||
# @return [Sawyer:Resource] Result of the queuing containing `:message`
|
||||
def queue_index(target)
|
||||
post 'staff/indexing_jobs', target: target
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,129 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Octokit
|
||||
class EnterpriseAdminClient
|
||||
# Methods for the Enterprise User Administration API
|
||||
#
|
||||
# @see https://developer.github.com/enterprise/v3/enterprise-admin/users/
|
||||
module Users
|
||||
# Create a new user.
|
||||
#
|
||||
# @param login [String] The user's username.
|
||||
# @param email [String] The user's email address.
|
||||
# @see https://developer.github.com/enterprise/v3/enterprise-admin/users#create-a-new-user
|
||||
# @example
|
||||
# @admin_client.create_user('foobar', 'notreal@foo.bar')
|
||||
def create_user(login, email, options = {})
|
||||
options[:login] = login
|
||||
options[:email] = email
|
||||
post 'admin/users', options
|
||||
end
|
||||
|
||||
# Promote an ordinary user to a site administrator
|
||||
#
|
||||
# @param user [String] Username of the user to promote.
|
||||
# @return [Boolean] True if promote was successful, false otherwise.
|
||||
# @see https://developer.github.com/enterprise/v3/enterprise-admin/users/#promote-an-ordinary-user-to-a-site-administrator
|
||||
# @example
|
||||
# @admin_client.promote('holman')
|
||||
def promote(user, options = {})
|
||||
boolean_from_response :put, "users/#{user}/site_admin", options
|
||||
end
|
||||
|
||||
# Demote a site administrator to an ordinary user
|
||||
#
|
||||
# @param user [String] Username of the user to demote.
|
||||
# @return [Boolean] True if demote was successful, false otherwise.
|
||||
# @see https://developer.github.com/enterprise/v3/enterprise-admin/users/#demote-a-site-administrator-to-an-ordinary-user
|
||||
# @example
|
||||
# @admin_client.demote('holman')
|
||||
def demote(user, options = {})
|
||||
boolean_from_response :delete, "users/#{user}/site_admin", options
|
||||
end
|
||||
|
||||
# Rename a user.
|
||||
#
|
||||
# @param old_login [String] The user's old username.
|
||||
# @param new_login [String] The user's new username.
|
||||
# @see https://developer.github.com/enterprise/v3/enterprise-admin/users/#rename-an-existing-user
|
||||
# @example
|
||||
# @admin_client.rename_user('foobar', 'foofoobar')
|
||||
def rename_user(old_login, new_login, options = {})
|
||||
options[:login] = new_login
|
||||
patch "admin/users/#{old_login}", options
|
||||
end
|
||||
|
||||
# Deletes a user.
|
||||
#
|
||||
# @param username [String] The username to delete.
|
||||
# @see https://developer.github.com/enterprise/v3/enterprise-admin/users/#delete-a-user
|
||||
# @example
|
||||
# @admin_client.delete_key(1)
|
||||
def delete_user(username, options = {})
|
||||
boolean_from_response :delete, "admin/users/#{username}", options
|
||||
end
|
||||
|
||||
# Suspend a user.
|
||||
#
|
||||
# @param user [String] Username of the user to suspend.
|
||||
# @return [Boolean] True if suspend was successful, false otherwise.
|
||||
# @see https://developer.github.com/enterprise/v3/enterprise-admin/users/#suspend-a-user
|
||||
# @example
|
||||
# @admin_client.suspend('holman')
|
||||
def suspend(user, options = {})
|
||||
boolean_from_response :put, "users/#{user}/suspended", options
|
||||
end
|
||||
|
||||
# Unsuspend a user.
|
||||
#
|
||||
# @param user [String] Username of the user to unsuspend.
|
||||
# @return [Boolean] True if unsuspend was successful, false otherwise.
|
||||
# @see https://developer.github.com/enterprise/v3/enterprise-admin/users/#unsuspend-a-user
|
||||
# @example
|
||||
# @admin_client.unsuspend('holman')
|
||||
def unsuspend(user, options = {})
|
||||
boolean_from_response :delete, "users/#{user}/suspended", options
|
||||
end
|
||||
|
||||
# Creates an impersonation OAuth token.
|
||||
#
|
||||
# @param login [String] The user to create a token for.
|
||||
# @param options [Array<String>] :scopes The scopes to apply.
|
||||
# @see https://developer.github.com/enterprise/v3/enterprise-admin/users/#create-an-impersonation-oauth-token
|
||||
# @example
|
||||
# @admin_client.create_impersonation_token('foobar', {:scopes => ['repo:write']})
|
||||
def create_impersonation_token(login, options = {})
|
||||
post "admin/users/#{login}/authorizations", options
|
||||
end
|
||||
|
||||
# Deletes an impersonation OAuth token.
|
||||
#
|
||||
# @param login [String] The user whose token should be deleted.
|
||||
# @see https://developer.github.com/enterprise/v3/enterprise-admin/users/#delete-an-impersonation-oauth-token
|
||||
# @example
|
||||
# @admin_client.delete_impersonation_token('foobar')
|
||||
def delete_impersonation_token(login, options = {})
|
||||
boolean_from_response :delete, "admin/users/#{login}/authorizations", options
|
||||
end
|
||||
|
||||
# Lists all the public SSH keys.
|
||||
#
|
||||
# @see https://developer.github.com/enterprise/v3/enterprise-admin/users/#list-all-public-keys
|
||||
# @example
|
||||
# @admin_client.list_all_keys
|
||||
def list_all_keys(options = {})
|
||||
get 'admin/keys', options
|
||||
end
|
||||
|
||||
# Deletes a public SSH keys.
|
||||
#
|
||||
# @param id [Number] The ID of the key to delete.
|
||||
# @see https://developer.github.com/enterprise/v3/enterprise-admin/users/#delete-a-public-key
|
||||
# @example
|
||||
# @admin_client.delete_key(1)
|
||||
def delete_key(id, options = {})
|
||||
boolean_from_response :delete, "admin/keys/#{id}", options
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user