octodoggy 4.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -0
  3. data/CONTRIBUTING.md +22 -0
  4. data/LICENSE.md +20 -0
  5. data/README.md +714 -0
  6. data/Rakefile +22 -0
  7. data/lib/ext/sawyer/relation.rb +10 -0
  8. data/lib/octokit.rb +59 -0
  9. data/lib/octokit/arguments.rb +14 -0
  10. data/lib/octokit/authentication.rb +82 -0
  11. data/lib/octokit/client.rb +238 -0
  12. data/lib/octokit/client/authorizations.rb +244 -0
  13. data/lib/octokit/client/commit_comments.rb +95 -0
  14. data/lib/octokit/client/commits.rb +239 -0
  15. data/lib/octokit/client/contents.rb +162 -0
  16. data/lib/octokit/client/deployments.rb +62 -0
  17. data/lib/octokit/client/downloads.rb +50 -0
  18. data/lib/octokit/client/emojis.rb +18 -0
  19. data/lib/octokit/client/events.rb +151 -0
  20. data/lib/octokit/client/feeds.rb +33 -0
  21. data/lib/octokit/client/gists.rb +233 -0
  22. data/lib/octokit/client/gitignore.rb +43 -0
  23. data/lib/octokit/client/hooks.rb +297 -0
  24. data/lib/octokit/client/integrations.rb +77 -0
  25. data/lib/octokit/client/issues.rb +321 -0
  26. data/lib/octokit/client/labels.rb +156 -0
  27. data/lib/octokit/client/legacy_search.rb +42 -0
  28. data/lib/octokit/client/licenses.rb +45 -0
  29. data/lib/octokit/client/markdown.rb +27 -0
  30. data/lib/octokit/client/meta.rb +21 -0
  31. data/lib/octokit/client/milestones.rb +87 -0
  32. data/lib/octokit/client/notifications.rb +171 -0
  33. data/lib/octokit/client/objects.rb +141 -0
  34. data/lib/octokit/client/organizations.rb +768 -0
  35. data/lib/octokit/client/pages.rb +63 -0
  36. data/lib/octokit/client/projects.rb +314 -0
  37. data/lib/octokit/client/pub_sub_hubbub.rb +111 -0
  38. data/lib/octokit/client/pull_requests.rb +301 -0
  39. data/lib/octokit/client/rate_limit.rb +54 -0
  40. data/lib/octokit/client/reactions.rb +158 -0
  41. data/lib/octokit/client/refs.rb +118 -0
  42. data/lib/octokit/client/releases.rb +163 -0
  43. data/lib/octokit/client/repositories.rb +654 -0
  44. data/lib/octokit/client/repository_invitations.rb +103 -0
  45. data/lib/octokit/client/reviews.rb +174 -0
  46. data/lib/octokit/client/say.rb +19 -0
  47. data/lib/octokit/client/search.rb +76 -0
  48. data/lib/octokit/client/service_status.rb +38 -0
  49. data/lib/octokit/client/source_import.rb +161 -0
  50. data/lib/octokit/client/stats.rb +105 -0
  51. data/lib/octokit/client/statuses.rb +47 -0
  52. data/lib/octokit/client/traffic.rb +69 -0
  53. data/lib/octokit/client/users.rb +354 -0
  54. data/lib/octokit/configurable.rb +147 -0
  55. data/lib/octokit/connection.rb +199 -0
  56. data/lib/octokit/default.rb +166 -0
  57. data/lib/octokit/enterprise_admin_client.rb +40 -0
  58. data/lib/octokit/enterprise_admin_client/admin_stats.rb +120 -0
  59. data/lib/octokit/enterprise_admin_client/license.rb +18 -0
  60. data/lib/octokit/enterprise_admin_client/orgs.rb +27 -0
  61. data/lib/octokit/enterprise_admin_client/search_indexing.rb +83 -0
  62. data/lib/octokit/enterprise_admin_client/users.rb +128 -0
  63. data/lib/octokit/enterprise_management_console_client.rb +50 -0
  64. data/lib/octokit/enterprise_management_console_client/management_console.rb +176 -0
  65. data/lib/octokit/error.rb +286 -0
  66. data/lib/octokit/gist.rb +36 -0
  67. data/lib/octokit/middleware/follow_redirects.rb +131 -0
  68. data/lib/octokit/organization.rb +17 -0
  69. data/lib/octokit/preview.rb +38 -0
  70. data/lib/octokit/rate_limit.rb +33 -0
  71. data/lib/octokit/repo_arguments.rb +19 -0
  72. data/lib/octokit/repository.rb +93 -0
  73. data/lib/octokit/response/feed_parser.rb +21 -0
  74. data/lib/octokit/response/raise_error.rb +21 -0
  75. data/lib/octokit/user.rb +19 -0
  76. data/lib/octokit/version.rb +17 -0
  77. data/lib/octokit/warnable.rb +17 -0
  78. data/octokit.gemspec +22 -0
  79. metadata +160 -0
@@ -0,0 +1,40 @@
1
+ require 'octokit/connection'
2
+ require 'octokit/configurable'
3
+ require 'octokit/warnable'
4
+ require 'octokit/enterprise_admin_client/admin_stats'
5
+ require 'octokit/enterprise_admin_client/license'
6
+ require 'octokit/enterprise_admin_client/orgs'
7
+ require 'octokit/enterprise_admin_client/search_indexing'
8
+ require 'octokit/enterprise_admin_client/users'
9
+
10
+ module Octokit
11
+
12
+ # EnterpriseAdminClient is only meant to be used by GitHub Enterprise Admins
13
+ # and provides access the Admin only API endpoints including Admin Stats,
14
+ # Management Console, and the Search Indexing API.
15
+ #
16
+ # @see Octokit::Client Use Octokit::Client for regular API use for GitHub
17
+ # and GitHub Enterprise.
18
+ # @see https://developer.github.com/v3/enterprise/
19
+ class EnterpriseAdminClient
20
+
21
+ include Octokit::Configurable
22
+ include Octokit::Connection
23
+ include Octokit::Warnable
24
+ include Octokit::EnterpriseAdminClient::AdminStats
25
+ include Octokit::EnterpriseAdminClient::License
26
+ include Octokit::EnterpriseAdminClient::Orgs
27
+ include Octokit::EnterpriseAdminClient::SearchIndexing
28
+ include Octokit::EnterpriseAdminClient::Users
29
+
30
+ def initialize(options = {})
31
+ # Use options passed in, but fall back to module defaults
32
+ Octokit::Configurable.keys.each do |key|
33
+ instance_variable_set(:"@#{key}", options[key] || Octokit.instance_variable_get(:"@#{key}"))
34
+ end
35
+
36
+ login_from_netrc unless user_authenticated? || application_authenticated?
37
+ end
38
+
39
+ end
40
+ end
@@ -0,0 +1,120 @@
1
+ module Octokit
2
+ class EnterpriseAdminClient
3
+
4
+ # Methods for the Enterprise Admin Stats API
5
+ #
6
+ # @see https://developer.github.com/v3/enterprise/admin_stats/
7
+ module AdminStats
8
+
9
+ # Get all available stats
10
+ #
11
+ # @return [Sawyer::Resource] All available stats
12
+ # @example Get all available stats
13
+ # @client.admin_stats
14
+ def admin_stats
15
+ get_admin_stats "all"
16
+ end
17
+
18
+ # Get only repository-related stats
19
+ #
20
+ # @return [Sawyer::Resource] Only repository-related stats
21
+ # @example Get only repository-related stats
22
+ # @client.admin_repository_stats
23
+ def admin_repository_stats
24
+ get_admin_stats "repos"
25
+ end
26
+
27
+ # Get only hooks-related stats
28
+ #
29
+ # @return [Sawyer::Resource] Only hooks-related stats
30
+ # @example Get only hooks-related stats
31
+ # @client.admin_hooks_stats
32
+ def admin_hooks_stats
33
+ get_admin_stats "hooks"
34
+ end
35
+
36
+ # Get only pages-related stats
37
+ #
38
+ # @return [Sawyer::Resource] Only pages-related stats
39
+ # @example Get only pages-related stats
40
+ # @client.admin_pages_stats
41
+ def admin_pages_stats
42
+ get_admin_stats "pages"
43
+ end
44
+
45
+ # Get only organization-related stats
46
+ #
47
+ # @return [Sawyer::Resource] Only organization-related stats
48
+ # @example Get only organization-related stats
49
+ # @client.admin_organization_stats
50
+ def admin_organization_stats
51
+ get_admin_stats "orgs"
52
+ end
53
+
54
+ # Get only user-related stats
55
+ #
56
+ # @return [Sawyer::Resource] Only user-related stats
57
+ # @example Get only user-related stats
58
+ # @client.admin_users_stats
59
+ def admin_users_stats
60
+ get_admin_stats "users"
61
+ end
62
+
63
+ # Get only pull request-related stats
64
+ #
65
+ # @return [Sawyer::Resource] Only pull request-related stats
66
+ # @example Get only pull request-related stats
67
+ # @client.admin_pull_requests_stats
68
+ def admin_pull_requests_stats
69
+ get_admin_stats "pulls"
70
+ end
71
+
72
+ # Get only issue-related stats
73
+ #
74
+ # @return [Sawyer::Resource] Only issue-related stats
75
+ # @example Get only issue-related stats
76
+ # @client.admin_issues_stats
77
+ def admin_issues_stats
78
+ get_admin_stats "issues"
79
+ end
80
+
81
+ # Get only milestone-related stats
82
+ #
83
+ # @return [Sawyer::Resource] Only milestone-related stats
84
+ # @example Get only milestone-related stats
85
+ # @client.admin_milestones_stats
86
+ def admin_milestones_stats
87
+ get_admin_stats "milestones"
88
+ end
89
+
90
+ # Get only gist-related stats
91
+ #
92
+ # @return [Sawyer::Resource] Only only gist-related stats
93
+ # @example Get only gist-related stats
94
+ # @client.admin_gits_stats
95
+ def admin_gists_stats
96
+ get_admin_stats "gists"
97
+ end
98
+
99
+ # Get only comment-related stats
100
+ #
101
+ # @return [Sawyer::Resource] Only comment-related stats
102
+ # @example Get only comment-related stats
103
+ # @client.admin_comments_stats
104
+ def admin_comments_stats
105
+ get_admin_stats "comments"
106
+ end
107
+
108
+ private
109
+
110
+ # @private Get enterprise stats
111
+ #
112
+ # @param metric [String] The metrics you are looking for
113
+ # @return [Sawyer::Resource] Magical unicorn stats
114
+ def get_admin_stats(metric)
115
+ get "enterprise/stats/#{metric}"
116
+ end
117
+ end
118
+
119
+ end
120
+ end
@@ -0,0 +1,18 @@
1
+ module Octokit
2
+ class EnterpriseAdminClient
3
+
4
+ # Methods for the Enterprise License API
5
+ #
6
+ # @see https://developer.github.com/v3/enterprise/license/
7
+ module License
8
+
9
+ # Get information about the Enterprise license
10
+ #
11
+ # @return [Sawyer::Resource] The license information
12
+ def license_info
13
+ get "enterprise/settings/license"
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,27 @@
1
+ module Octokit
2
+ class EnterpriseAdminClient
3
+
4
+ # Methods for the Enterprise Orgs API
5
+ #
6
+ # @see https://developer.github.com/v3/enterprise/orgs/
7
+ module Orgs
8
+
9
+ # Create a new organization on the instance.
10
+ #
11
+ # @param login [String] The organization's username.
12
+ # @param admin [String] The login of the user who will manage this organization.
13
+ # @param options [Hash] A set of options.
14
+ # @option options [String] :profile_name The organization's display name.
15
+ # @return [nil]
16
+ # @see https://developer.github.com/v3/enterprise/orgs/#create-an-organization
17
+ # @example
18
+ # @admin_client.create_organization('SuchAGreatOrg', 'gjtorikian')
19
+ def create_organization(login, admin, options = {})
20
+ options[:login] = login
21
+ options[:admin] = admin
22
+ post "admin/organizations", options
23
+ end
24
+
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,83 @@
1
+ module Octokit
2
+ class EnterpriseAdminClient
3
+
4
+ # Methods for the Enterprise Search Indexing API
5
+ #
6
+ # @see https://developer.github.com/v3/enterprise/search_indexing/
7
+ module SearchIndexing
8
+
9
+ # Queue a User or Organization to be indexed
10
+ #
11
+ # @param user [String] A GitHub Enterprise user or organization
12
+ # @return [Sawyer:Resource] Result of the queuing containing `:message`
13
+ def index_user(user)
14
+ queue_index user
15
+ end
16
+ alias :index_organization :index_user
17
+
18
+ # Queue a Repository to be indexed
19
+ #
20
+ # @param repo [String, Hash, Repository] A GitHub repository
21
+ # @return [Sawyer:Resource] Result of the queuing containing `:message`
22
+ def index_repository(repo)
23
+ queue_index Repository.new repo
24
+ end
25
+
26
+ # Queue a repository's Issues to be indexed
27
+ #
28
+ # @param repo [String, Hash, Repository] A GitHub repository
29
+ # @return [Sawyer:Resource] Result of the queuing containing `:message`
30
+ def index_repository_issues(repo)
31
+ queue_index "#{Repository.new repo}/issues"
32
+ end
33
+
34
+ # Queue a repository's code to be indexed
35
+ #
36
+ # @param repo [String, Hash, Repository] A GitHub repository
37
+ # @return [Sawyer:Resource] Result of the queuing containing `:message`
38
+ def index_repository_code(repo)
39
+ queue_index "#{Repository.new repo}/code"
40
+ end
41
+
42
+ # Queue a user's or organization's repositories to be indexed
43
+ #
44
+ # @param user [String] A GitHub Enterprise user or organization
45
+ # @return [Sawyer:Resource] Result of the queuing containing `:message`
46
+ def index_users_repositories(user)
47
+ queue_index "#{user}/*"
48
+ end
49
+ alias :index_organizations_repositories :index_users_repositories
50
+
51
+ # Queue an index of all the issues across all of a user's or
52
+ # organization's repositories
53
+ #
54
+ # @param user [String] A GitHub Enterprise user or organization
55
+ # @return [Sawyer:Resource] Result of the queuing containing `:message`
56
+ def index_users_repositories_issues(user)
57
+ queue_index "#{user}/*/issues"
58
+ end
59
+ alias :index_organizations_repositories_issues :index_users_repositories_issues
60
+
61
+ # Queue an index of all the code contained in all of a user's or
62
+ # organization's repositories
63
+ #
64
+ # @param user [String] A GitHub Enterprise user or organization
65
+ # @return [Sawyer:Resource] Result of the queuing containing `:message`
66
+ def index_users_repositories_code(user)
67
+ queue_index "#{user}/*/code"
68
+ end
69
+ alias :index_organizations_repositories_code :index_users_repositories_code
70
+
71
+ private
72
+
73
+ # @private Queue a target for indexing
74
+ #
75
+ # @param target [String] Target to index
76
+ # @return [Sawyer:Resource] Result of the queuing containing `:message`
77
+ def queue_index(target)
78
+ post "staff/indexing_jobs", :target => target
79
+ end
80
+ end
81
+
82
+ end
83
+ end
@@ -0,0 +1,128 @@
1
+ module Octokit
2
+ class EnterpriseAdminClient
3
+
4
+ # Methods for the Enterprise User Administration API
5
+ #
6
+ # @see https://developer.github.com/v3/users/administration/
7
+ module Users
8
+ # Create a new user.
9
+ #
10
+ # @param login [String] The user's username.
11
+ # @param email [String] The user's email address.
12
+ # @see https://developer.github.com/v3/users/administration/#create-a-new-user
13
+ # @example
14
+ # @admin_client.create_user('foobar', 'notreal@foo.bar')
15
+ def create_user(login, email, options = {})
16
+ options[:login] = login
17
+ options[:email] = email
18
+ post "admin/users", options
19
+ end
20
+
21
+ # Promote an ordinary user to a site administrator
22
+ #
23
+ # @param user [String] Username of the user to promote.
24
+ # @return [Boolean] True if promote was successful, false otherwise.
25
+ # @see https://developer.github.com/v3/users/administration/#promote-an-ordinary-user-to-a-site-administrator
26
+ # @example
27
+ # @admin_client.promote('holman')
28
+ def promote(user, options = {})
29
+ boolean_from_response :put, "users/#{user}/site_admin", options
30
+ end
31
+
32
+ # Demote a site administrator to an ordinary user
33
+ #
34
+ # @param user [String] Username of the user to demote.
35
+ # @return [Boolean] True if demote was successful, false otherwise.
36
+ # @see https://developer.github.com/v3/users/administration/#demote-a-site-administrator-to-an-ordinary-user
37
+ # @example
38
+ # @admin_client.demote('holman')
39
+ def demote(user, options = {})
40
+ boolean_from_response :delete, "users/#{user}/site_admin", options
41
+ end
42
+
43
+ # Rename a user.
44
+ #
45
+ # @param old_login [String] The user's old username.
46
+ # @param new_login [String] The user's new username.
47
+ # @see https://developer.github.com/v3/users/administration/#rename-an-existing-user
48
+ # @example
49
+ # @admin_client.rename_user('foobar', 'foofoobar')
50
+ def rename_user(old_login, new_login, options = {})
51
+ options[:login] = new_login
52
+ patch "admin/users/#{old_login}", options
53
+ end
54
+
55
+ # Deletes a user.
56
+ #
57
+ # @param username [String] The username to delete.
58
+ # @see https://developer.github.com/v3/users/administration/#delete-a-user
59
+ # @example
60
+ # @admin_client.delete_key(1)
61
+ def delete_user(username, options = {})
62
+ boolean_from_response :delete, "admin/users/#{username}", options
63
+ end
64
+
65
+ # Suspend a user.
66
+ #
67
+ # @param user [String] Username of the user to suspend.
68
+ # @return [Boolean] True if suspend was successful, false otherwise.
69
+ # @see https://developer.github.com/v3/users/administration/#suspend-a-user
70
+ # @example
71
+ # @admin_client.suspend('holman')
72
+ def suspend(user, options = {})
73
+ boolean_from_response :put, "users/#{user}/suspended", options
74
+ end
75
+
76
+ # Unsuspend a user.
77
+ #
78
+ # @param user [String] Username of the user to unsuspend.
79
+ # @return [Boolean] True if unsuspend was successful, false otherwise.
80
+ # @see https://developer.github.com/v3/users/administration/#unsuspend-a-user
81
+ # @example
82
+ # @admin_client.unsuspend('holman')
83
+ def unsuspend(user, options = {})
84
+ boolean_from_response :delete, "users/#{user}/suspended", options
85
+ end
86
+
87
+ # Creates an impersonation OAuth token.
88
+ #
89
+ # @param login [String] The user to create a token for.
90
+ # @param options [Array<String>] :scopes The scopes to apply.
91
+ # @see https://developer.github.com/v3/users/administration/#create-an-impersonation-oauth-token
92
+ # @example
93
+ # @admin_client.create_impersonation_token('foobar', {:scopes => ['repo:write']})
94
+ def create_impersonation_token(login, options = {})
95
+ post "admin/users/#{login}/authorizations", options
96
+ end
97
+
98
+ # Deletes an impersonation OAuth token.
99
+ #
100
+ # @param login [String] The user whose token should be deleted.
101
+ # @see https://developer.github.com/v3/users/administration/#delete-an-impersonation-oauth-token
102
+ # @example
103
+ # @admin_client.delete_impersonation_token('foobar')
104
+ def delete_impersonation_token(login, options = {})
105
+ boolean_from_response :delete, "admin/users/#{login}/authorizations", options
106
+ end
107
+
108
+ # Lists all the public SSH keys.
109
+ #
110
+ # @see https://developer.github.com/v3/users/administration/#list-all-public-keys
111
+ # @example
112
+ # @admin_client.list_all_keys
113
+ def list_all_keys(options = {})
114
+ get "admin/keys", options
115
+ end
116
+
117
+ # Deletes a public SSH keys.
118
+ #
119
+ # @param id [Number] The ID of the key to delete.
120
+ # @see https://developer.github.com/v3/users/administration/#delete-a-public-key
121
+ # @example
122
+ # @admin_client.delete_key(1)
123
+ def delete_key(id, options = {})
124
+ boolean_from_response :delete, "admin/keys/#{id}", options
125
+ end
126
+ end
127
+ end
128
+ end
@@ -0,0 +1,50 @@
1
+ require 'octokit/configurable'
2
+ require 'octokit/connection'
3
+ require 'octokit/warnable'
4
+ require 'octokit/enterprise_management_console_client/management_console'
5
+
6
+ module Octokit
7
+
8
+ # EnterpriseManagementConsoleClient is only meant to be used by GitHub Enterprise Admins
9
+ # and provides access to the management console API endpoints.
10
+ #
11
+ # @see Octokit::Client Use Octokit::Client for regular API use for GitHub
12
+ # and GitHub Enterprise.
13
+ # @see https://developer.github.com/v3/enterprise/management_console/
14
+ class EnterpriseManagementConsoleClient
15
+
16
+ include Octokit::Configurable
17
+ include Octokit::Connection
18
+ include Octokit::Warnable
19
+ include Octokit::EnterpriseManagementConsoleClient::ManagementConsole
20
+
21
+ def initialize(options = {})
22
+ # Use options passed in, but fall back to module defaults
23
+ Octokit::Configurable.keys.each do |key|
24
+ instance_variable_set(:"@#{key}", options[key] || Octokit.instance_variable_get(:"@#{key}"))
25
+ end
26
+ end
27
+
28
+ protected
29
+
30
+ def endpoint
31
+ management_console_endpoint
32
+ end
33
+
34
+ # Set Enterprise Management Console password
35
+ #
36
+ # @param value [String] Management console admin password
37
+ def management_console_password=(value)
38
+ reset_agent
39
+ @management_console_password = value
40
+ end
41
+
42
+ # Set Enterprise Management Console endpoint
43
+ #
44
+ # @param value [String] Management console endpoint
45
+ def management_console_endpoint=(value)
46
+ reset_agent
47
+ @management_console_endpoint = value
48
+ end
49
+ end
50
+ end