octokit 4.2.0 → 9.2.0

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 (97) hide show
  1. checksums.yaml +5 -5
  2. data/CONTRIBUTING.md +14 -13
  3. data/LICENSE.md +1 -1
  4. data/README.md +275 -127
  5. data/Rakefile +20 -14
  6. data/lib/ext/sawyer/relation.rb +12 -0
  7. data/lib/octokit/arguments.rb +3 -3
  8. data/lib/octokit/authentication.rb +20 -14
  9. data/lib/octokit/client/actions_artifacts.rb +71 -0
  10. data/lib/octokit/client/actions_secrets.rb +161 -0
  11. data/lib/octokit/client/actions_workflow_jobs.rb +65 -0
  12. data/lib/octokit/client/actions_workflow_runs.rb +125 -0
  13. data/lib/octokit/client/actions_workflows.rb +68 -0
  14. data/lib/octokit/client/apps.rb +259 -0
  15. data/lib/octokit/client/checks.rb +200 -0
  16. data/lib/octokit/client/code_scanning.rb +190 -0
  17. data/lib/octokit/client/codespaces_secrets.rb +108 -0
  18. data/lib/octokit/client/commit_branches.rb +20 -0
  19. data/lib/octokit/client/commit_comments.rb +8 -8
  20. data/lib/octokit/client/commit_pulls.rb +20 -0
  21. data/lib/octokit/client/commits.rb +32 -35
  22. data/lib/octokit/client/community_profile.rb +21 -0
  23. data/lib/octokit/client/contents.rb +24 -21
  24. data/lib/octokit/client/dependabot_secrets.rb +108 -0
  25. data/lib/octokit/client/deployments.rb +29 -7
  26. data/lib/octokit/client/downloads.rb +5 -6
  27. data/lib/octokit/client/emojis.rb +3 -3
  28. data/lib/octokit/client/environments.rb +58 -0
  29. data/lib/octokit/client/events.rb +4 -4
  30. data/lib/octokit/client/feeds.rb +4 -5
  31. data/lib/octokit/client/gists.rb +36 -8
  32. data/lib/octokit/client/gitignore.rb +3 -3
  33. data/lib/octokit/client/hooks.rb +34 -30
  34. data/lib/octokit/client/issues.rb +97 -14
  35. data/lib/octokit/client/labels.rb +17 -17
  36. data/lib/octokit/client/legacy_search.rb +3 -3
  37. data/lib/octokit/client/licenses.rb +5 -8
  38. data/lib/octokit/client/markdown.rb +3 -3
  39. data/lib/octokit/client/marketplace.rb +56 -0
  40. data/lib/octokit/client/meta.rb +4 -5
  41. data/lib/octokit/client/milestones.rb +14 -14
  42. data/lib/octokit/client/notifications.rb +7 -11
  43. data/lib/octokit/client/oauth_applications.rb +116 -0
  44. data/lib/octokit/client/objects.rb +14 -14
  45. data/lib/octokit/client/organizations.rb +256 -73
  46. data/lib/octokit/client/pages.rb +26 -3
  47. data/lib/octokit/client/projects.rb +294 -0
  48. data/lib/octokit/client/pull_requests.rb +74 -51
  49. data/lib/octokit/client/rate_limit.rb +11 -13
  50. data/lib/octokit/client/reactions.rb +204 -0
  51. data/lib/octokit/client/refs.rb +34 -20
  52. data/lib/octokit/client/releases.rb +16 -13
  53. data/lib/octokit/client/repositories.rb +276 -60
  54. data/lib/octokit/client/repository_invitations.rb +96 -0
  55. data/lib/octokit/client/reviews.rb +227 -0
  56. data/lib/octokit/client/say.rb +4 -5
  57. data/lib/octokit/client/search.rb +46 -17
  58. data/lib/octokit/client/service_status.rb +19 -9
  59. data/lib/octokit/client/source_import.rb +156 -0
  60. data/lib/octokit/client/stats.rb +39 -17
  61. data/lib/octokit/client/statuses.rb +6 -6
  62. data/lib/octokit/client/tokens.rb +31 -0
  63. data/lib/octokit/client/traffic.rb +64 -0
  64. data/lib/octokit/client/users.rb +133 -25
  65. data/lib/octokit/client.rb +85 -19
  66. data/lib/octokit/configurable.rb +60 -32
  67. data/lib/octokit/connection.rb +45 -21
  68. data/lib/octokit/default.rb +82 -35
  69. data/lib/octokit/enterprise_admin_client/admin_stats.rb +14 -15
  70. data/lib/octokit/enterprise_admin_client/license.rb +4 -5
  71. data/lib/octokit/enterprise_admin_client/orgs.rb +7 -6
  72. data/lib/octokit/enterprise_admin_client/search_indexing.rb +8 -9
  73. data/lib/octokit/enterprise_admin_client/users.rb +19 -18
  74. data/lib/octokit/enterprise_admin_client.rb +11 -3
  75. data/lib/octokit/enterprise_management_console_client/management_console.rb +52 -34
  76. data/lib/octokit/enterprise_management_console_client.rb +9 -3
  77. data/lib/octokit/error.rb +144 -26
  78. data/lib/octokit/gist.rb +4 -5
  79. data/lib/octokit/manage_ghes_client/manage_ghes.rb +178 -0
  80. data/lib/octokit/manage_ghes_client.rb +64 -0
  81. data/lib/octokit/middleware/follow_redirects.rb +18 -14
  82. data/lib/octokit/organization.rb +3 -1
  83. data/lib/octokit/rate_limit.rb +11 -9
  84. data/lib/octokit/repo_arguments.rb +3 -4
  85. data/lib/octokit/repository.rb +35 -23
  86. data/lib/octokit/response/base_middleware.rb +10 -0
  87. data/lib/octokit/response/feed_parser.rb +5 -9
  88. data/lib/octokit/response/raise_error.rb +4 -6
  89. data/lib/octokit/user.rb +4 -2
  90. data/lib/octokit/version.rb +3 -1
  91. data/lib/octokit/warnable.rb +4 -5
  92. data/lib/octokit.rb +30 -8
  93. data/octokit.gemspec +12 -10
  94. metadata +47 -24
  95. data/lib/octokit/client/authorizations.rb +0 -256
  96. data/lib/octokit/client/pub_sub_hubbub.rb +0 -111
  97. data/lib/octokit/preview.rb +0 -28
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the Notifications API
5
6
  #
6
7
  # @see https://developer.github.com/v3/activity/notifications/
7
8
  module Notifications
8
-
9
9
  # List your notifications
10
10
  #
11
11
  # @param options [Hash] Optional parameters
@@ -24,7 +24,7 @@ module Octokit
24
24
  # @example Get all notifications since a certain time.
25
25
  # @client.notifications({all: true, since: '2012-10-09T23:39:01Z'})
26
26
  def notifications(options = {})
27
- paginate "notifications", options
27
+ paginate 'notifications', options
28
28
  end
29
29
 
30
30
  # List your notifications in a repository
@@ -48,7 +48,7 @@ module Octokit
48
48
  def repository_notifications(repo, options = {})
49
49
  paginate "#{Repository.path repo}/notifications", options
50
50
  end
51
- alias :repo_notifications :repository_notifications
51
+ alias repo_notifications repository_notifications
52
52
 
53
53
  # Mark notifications as read
54
54
  #
@@ -66,7 +66,7 @@ module Octokit
66
66
  # @example
67
67
  # @client.mark_notifications_as_read
68
68
  def mark_notifications_as_read(options = {})
69
- request :put, "notifications", options
69
+ request :put, 'notifications', options
70
70
 
71
71
  last_response.status == 205
72
72
  end
@@ -91,7 +91,7 @@ module Octokit
91
91
 
92
92
  last_response.status == 205
93
93
  end
94
- alias :mark_repo_notifications_as_read :mark_repository_notifications_as_read
94
+ alias mark_repo_notifications_as_read mark_repository_notifications_as_read
95
95
 
96
96
  # List notifications for a specific thread
97
97
  #
@@ -108,14 +108,10 @@ module Octokit
108
108
  # Mark thread as read
109
109
  #
110
110
  # @param thread_id [Integer] Id of the thread to update.
111
- # @param options [Hash] Optional parameters.
112
- # @option options [Boolean] :unread Changes the unread status of the
113
- # threads.
114
- # @option options [Boolean] :read Inverse of 'unread'.
115
111
  # @return [Boolean] True if updated, false otherwise.
116
112
  # @see https://developer.github.com/v3/activity/notifications/#mark-a-thread-as-read
117
113
  # @example
118
- # @client.mark_thread_as_ready(1, :read => false)
114
+ # @client.mark_thread_as_read(1, :read => false)
119
115
  def mark_thread_as_read(thread_id, options = {})
120
116
  request :patch, "notifications/threads/#{thread_id}", options
121
117
 
@@ -0,0 +1,116 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Octokit
4
+ class Client
5
+ # Methods for the OauthApplications API
6
+ #
7
+ # @see https://developer.github.com/v3/apps/oauth_applications
8
+ module OauthApplications
9
+ # Check if a token is valid.
10
+ #
11
+ # Applications can check if a token is valid without rate limits.
12
+ #
13
+ # @param access_token [String] 40 character GitHub OAuth access token
14
+ #
15
+ # @return [Sawyer::Resource] A single authorization for the authenticated user
16
+ # @see https://developer.github.com/v3/apps/oauth_applications/#check-a-token
17
+ #
18
+ # @example
19
+ # client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
20
+ # client.check_token('deadbeef1234567890deadbeef987654321')
21
+ def check_token(access_token, options = {})
22
+ options[:access_token] = access_token
23
+
24
+ key = options.delete(:client_id) || client_id
25
+ secret = options.delete(:client_secret) || client_secret
26
+
27
+ as_app(key, secret) do |app_client|
28
+ app_client.post "applications/#{client_id}/token", options
29
+ end
30
+ end
31
+ alias check_application_authorization check_token
32
+
33
+ # Reset a token
34
+ #
35
+ # Applications can reset a token without requiring a user to re-authorize.
36
+ #
37
+ # @param access_token [String] 40 character GitHub OAuth access token
38
+ #
39
+ # @return [Sawyer::Resource] A single authorization for the authenticated user
40
+ # @see https://developer.github.com/v3/apps/oauth_applications/#reset-a-token
41
+ #
42
+ # @example
43
+ # client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
44
+ # client.reset_token('deadbeef1234567890deadbeef987654321')
45
+ def reset_token(access_token, options = {})
46
+ options[:access_token] = access_token
47
+
48
+ key = options.delete(:client_id) || client_id
49
+ secret = options.delete(:client_secret) || client_secret
50
+
51
+ as_app(key, secret) do |app_client|
52
+ app_client.patch "applications/#{client_id}/token", options
53
+ end
54
+ end
55
+ alias reset_application_authorization reset_token
56
+
57
+ # Delete an app token
58
+ #
59
+ # Applications can revoke (delete) a token
60
+ #
61
+ # @param access_token [String] 40 character GitHub OAuth access token
62
+ #
63
+ # @return [Boolean] Result
64
+ # @see https://developer.github.com/v3/apps/oauth_applications/#delete-an-app-token
65
+ #
66
+ # @example
67
+ # client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
68
+ # client.delete_app_token('deadbeef1234567890deadbeef987654321')
69
+ def delete_app_token(access_token, options = {})
70
+ options[:access_token] = access_token
71
+
72
+ key = options.delete(:client_id) || client_id
73
+ secret = options.delete(:client_secret) || client_secret
74
+
75
+ begin
76
+ as_app(key, secret) do |app_client|
77
+ app_client.delete "applications/#{client_id}/token", options
78
+ app_client.last_response.status == 204
79
+ end
80
+ rescue Octokit::NotFound
81
+ false
82
+ end
83
+ end
84
+ alias delete_application_authorization delete_app_token
85
+ alias revoke_application_authorization delete_app_token
86
+
87
+ # Delete an app authorization
88
+ #
89
+ # OAuth application owners can revoke a grant for their OAuth application and a specific user.
90
+ #
91
+ # @param access_token [String] 40 character GitHub OAuth access token
92
+ #
93
+ # @return [Boolean] Result
94
+ # @see https://developer.github.com/v3/apps/oauth_applications/#delete-an-app-token
95
+ #
96
+ # @example
97
+ # client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
98
+ # client.delete_app_authorization('deadbeef1234567890deadbeef987654321')
99
+ def delete_app_authorization(access_token, options = {})
100
+ options[:access_token] = access_token
101
+
102
+ key = options.delete(:client_id) || client_id
103
+ secret = options.delete(:client_secret) || client_secret
104
+
105
+ begin
106
+ as_app(key, secret) do |app_client|
107
+ app_client.delete "applications/#{client_id}/grant", options
108
+ app_client.last_response.status == 204
109
+ end
110
+ rescue Octokit::NotFound
111
+ false
112
+ end
113
+ end
114
+ end
115
+ end
116
+ end
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the Git Data API
5
6
  #
6
7
  # @see https://developer.github.com/v3/git/
7
8
  module Objects
8
-
9
9
  # Get a single tree, fetching information about its root-level objects
10
10
  #
11
11
  # Pass <tt>:recursive => true</tt> in <tt>options</tt> to fetch information about all of the tree's objects, including those in subdirectories.
@@ -38,7 +38,7 @@ module Octokit
38
38
  # tree.sha # => "cd8274d15fa3ae2ab983129fb037999f264ba9a7"
39
39
  # tree.tree.first.path # => "file.rb"
40
40
  def create_tree(repo, tree, options = {})
41
- parameters = { :tree => tree }
41
+ parameters = { tree: tree }
42
42
  post "#{Repository.path repo}/git/trees", options.merge(parameters)
43
43
  end
44
44
 
@@ -74,10 +74,10 @@ module Octokit
74
74
  # @example Create a blob containing <tt>foo bar baz</tt>, encoded using base64
75
75
  # require "base64"
76
76
  # Octokit.create_blob("octocat/Hello-World", Base64.encode64("foo bar baz"), "base64")
77
- def create_blob(repo, content, encoding="utf-8", options = {})
77
+ def create_blob(repo, content, encoding = 'utf-8', options = {})
78
78
  parameters = {
79
- :content => content,
80
- :encoding => encoding
79
+ content: content,
80
+ encoding: encoding
81
81
  }
82
82
  blob = post "#{Repository.path repo}/git/blobs", options.merge(parameters)
83
83
 
@@ -124,14 +124,14 @@ module Octokit
124
124
  # )
125
125
  def create_tag(repo, tag, message, object_sha, type, tagger_name, tagger_email, tagger_date, options = {})
126
126
  options.merge!(
127
- :tag => tag,
128
- :message => message,
129
- :object => object_sha,
130
- :type => type,
131
- :tagger => {
132
- :name => tagger_name,
133
- :email => tagger_email,
134
- :date => tagger_date
127
+ tag: tag,
128
+ message: message,
129
+ object: object_sha,
130
+ type: type,
131
+ tagger: {
132
+ name: tagger_name,
133
+ email: tagger_email,
134
+ date: tagger_date
135
135
  }
136
136
  )
137
137
  post "#{Repository.path repo}/git/tags", options