gitabu 0.1.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 (104) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/.rubocop.yml +33 -0
  4. data/CHANGELOG.md +3 -0
  5. data/Gemfile +10 -0
  6. data/Gemfile.lock +65 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +42 -0
  9. data/Rakefile +12 -0
  10. data/gitabu.gemspec +41 -0
  11. data/lib/gitabu/api/v3/actions.rb +3724 -0
  12. data/lib/gitabu/api/v3/activity.rb +835 -0
  13. data/lib/gitabu/api/v3/apps.rb +961 -0
  14. data/lib/gitabu/api/v3/billing.rb +217 -0
  15. data/lib/gitabu/api/v3/branches.rb +1098 -0
  16. data/lib/gitabu/api/v3/checks.rb +384 -0
  17. data/lib/gitabu/api/v3/code_scanning.rb +315 -0
  18. data/lib/gitabu/api/v3/codes_of_conduct.rb +92 -0
  19. data/lib/gitabu/api/v3/codespaces.rb +650 -0
  20. data/lib/gitabu/api/v3/collaborators.rb +341 -0
  21. data/lib/gitabu/api/v3/commits.rb +428 -0
  22. data/lib/gitabu/api/v3/dependabot.rb +419 -0
  23. data/lib/gitabu/api/v3/deploy_keys.rb +152 -0
  24. data/lib/gitabu/api/v3/deployments.rb +356 -0
  25. data/lib/gitabu/api/v3/emojis.rb +67 -0
  26. data/lib/gitabu/api/v3/enterprise_admin.rb +495 -0
  27. data/lib/gitabu/api/v3/gists.rb +552 -0
  28. data/lib/gitabu/api/v3/git.rb +409 -0
  29. data/lib/gitabu/api/v3/gitignore.rb +92 -0
  30. data/lib/gitabu/api/v3/interactions.rb +275 -0
  31. data/lib/gitabu/api/v3/issues.rb +1119 -0
  32. data/lib/gitabu/api/v3/licenses.rb +118 -0
  33. data/lib/gitabu/api/v3/markdown.rb +94 -0
  34. data/lib/gitabu/api/v3/meta.rb +142 -0
  35. data/lib/gitabu/api/v3/metrics.rb +302 -0
  36. data/lib/gitabu/api/v3/migrations.rb +631 -0
  37. data/lib/gitabu/api/v3/orgs.rb +1291 -0
  38. data/lib/gitabu/api/v3/packages.rb +686 -0
  39. data/lib/gitabu/api/v3/pages.rb +282 -0
  40. data/lib/gitabu/api/v3/projects.rb +693 -0
  41. data/lib/gitabu/api/v3/pulls.rb +816 -0
  42. data/lib/gitabu/api/v3/rate_limit.rb +67 -0
  43. data/lib/gitabu/api/v3/reactions.rb +734 -0
  44. data/lib/gitabu/api/v3/releases.rb +411 -0
  45. data/lib/gitabu/api/v3/repos.rb +1136 -0
  46. data/lib/gitabu/api/v3/scim.rb +214 -0
  47. data/lib/gitabu/api/v3/search.rb +217 -0
  48. data/lib/gitabu/api/v3/secret_scanning.rb +201 -0
  49. data/lib/gitabu/api/v3/teams.rb +1963 -0
  50. data/lib/gitabu/api/v3/users.rb +851 -0
  51. data/lib/gitabu/api/v3/webhooks.rb +379 -0
  52. data/lib/gitabu/builder.rb +37 -0
  53. data/lib/gitabu/client.rb +8 -0
  54. data/lib/gitabu/generator.rb +75 -0
  55. data/lib/gitabu/http_client.rb +96 -0
  56. data/lib/gitabu/items.rb +110 -0
  57. data/lib/gitabu/public/api/v3/actions.json +5779 -0
  58. data/lib/gitabu/public/api/v3/activity.json +1248 -0
  59. data/lib/gitabu/public/api/v3/apps.json +1174 -0
  60. data/lib/gitabu/public/api/v3/billing.json +183 -0
  61. data/lib/gitabu/public/api/v3/branches.json +1886 -0
  62. data/lib/gitabu/public/api/v3/checks.json +856 -0
  63. data/lib/gitabu/public/api/v3/code_scanning.json +666 -0
  64. data/lib/gitabu/public/api/v3/codes_of_conduct.json +41 -0
  65. data/lib/gitabu/public/api/v3/codespaces.json +884 -0
  66. data/lib/gitabu/public/api/v3/collaborators.json +464 -0
  67. data/lib/gitabu/public/api/v3/commits.json +830 -0
  68. data/lib/gitabu/public/api/v3/dependabot.json +596 -0
  69. data/lib/gitabu/public/api/v3/deploy_keys.json +195 -0
  70. data/lib/gitabu/public/api/v3/deployments.json +698 -0
  71. data/lib/gitabu/public/api/v3/emojis.json +18 -0
  72. data/lib/gitabu/public/api/v3/enterprise_admin.json +881 -0
  73. data/lib/gitabu/public/api/v3/gists.json +689 -0
  74. data/lib/gitabu/public/api/v3/git.json +735 -0
  75. data/lib/gitabu/public/api/v3/gitignore.json +41 -0
  76. data/lib/gitabu/public/api/v3/interactions.json +265 -0
  77. data/lib/gitabu/public/api/v3/issues.json +2359 -0
  78. data/lib/gitabu/public/api/v3/licenses.json +100 -0
  79. data/lib/gitabu/public/api/v3/markdown.json +59 -0
  80. data/lib/gitabu/public/api/v3/meta.json +69 -0
  81. data/lib/gitabu/public/api/v3/metrics.json +342 -0
  82. data/lib/gitabu/public/api/v3/migrations.json +960 -0
  83. data/lib/gitabu/public/api/v3/orgs.json +1989 -0
  84. data/lib/gitabu/public/api/v3/packages.json +1078 -0
  85. data/lib/gitabu/public/api/v3/pages.json +373 -0
  86. data/lib/gitabu/public/api/v3/projects.json +966 -0
  87. data/lib/gitabu/public/api/v3/pulls.json +1768 -0
  88. data/lib/gitabu/public/api/v3/rate_limit.json +18 -0
  89. data/lib/gitabu/public/api/v3/reactions.json +1425 -0
  90. data/lib/gitabu/public/api/v3/releases.json +753 -0
  91. data/lib/gitabu/public/api/v3/repos.json +2314 -0
  92. data/lib/gitabu/public/api/v3/scim.json +412 -0
  93. data/lib/gitabu/public/api/v3/search.json +408 -0
  94. data/lib/gitabu/public/api/v3/secret_scanning.json +385 -0
  95. data/lib/gitabu/public/api/v3/teams.json +3126 -0
  96. data/lib/gitabu/public/api/v3/users.json +956 -0
  97. data/lib/gitabu/public/api/v3/webhooks.json +667 -0
  98. data/lib/gitabu/run.rb +237 -0
  99. data/lib/gitabu/scraper.rb +86 -0
  100. data/lib/gitabu/templates/template.rb.erb +70 -0
  101. data/lib/gitabu/version.rb +6 -0
  102. data/lib/gitabu.rb +57 -0
  103. data/sig/gitabu.rbs +4 -0
  104. metadata +177 -0
@@ -0,0 +1,341 @@
1
+ # frozen_string_literal: true
2
+
3
+ # INFO ON GENERATED CODE
4
+ #
5
+ # This file is generated.
6
+ # See the contribution guide on how to improve the code.
7
+ #
8
+ # INFO ON GENERATED CODE
9
+
10
+ # Ruby gem that helps you work with Github API.
11
+ module Gitabu
12
+ # API module
13
+ module Api
14
+ # Github Version 3
15
+ module V3
16
+ # Class to display Collaborators result
17
+ class CollaboratorsResult
18
+ attr_accessor :result, :message
19
+
20
+ def initialize(result:, message:)
21
+ @result = result
22
+ @message = message
23
+ end
24
+ end
25
+
26
+ # Class to display error result
27
+ class CollaboratorsErrorResult
28
+ attr_accessor :result, :message
29
+
30
+ def initialize(result:, message:)
31
+ @result = result
32
+ @message = message
33
+ end
34
+ end
35
+
36
+ # Collaborators endpoints.
37
+ class Collaborators
38
+ def self.list_repository_collaborators(owner: nil, repo: nil, options: nil)
39
+ new.list_repository_collaborators(owner, repo, options)
40
+ end
41
+
42
+ def self.check_if_a_user_is_a_repository_collaborator(owner: nil, repo: nil, username: nil, options: nil)
43
+ new.check_if_a_user_is_a_repository_collaborator(owner, repo, username, options)
44
+ end
45
+
46
+ def self.add_a_repository_collaborator(owner: nil, repo: nil, username: nil, permission: nil, permissions: nil, options: nil)
47
+ new.add_a_repository_collaborator(owner, repo, username, permission, permissions, options)
48
+ end
49
+
50
+ def self.remove_a_repository_collaborator(owner: nil, repo: nil, username: nil, options: nil)
51
+ new.remove_a_repository_collaborator(owner, repo, username, options)
52
+ end
53
+
54
+ def self.get_repository_permissions_for_a_user(owner: nil, repo: nil, username: nil, options: nil)
55
+ new.get_repository_permissions_for_a_user(owner, repo, username, options)
56
+ end
57
+
58
+ def self.list_repository_invitations(owner: nil, repo: nil, options: nil)
59
+ new.list_repository_invitations(owner, repo, options)
60
+ end
61
+
62
+ def self.update_a_repository_invitation(owner: nil, repo: nil, invitation_id: nil, permissions: nil, options: nil)
63
+ new.update_a_repository_invitation(owner, repo, invitation_id, permissions, options)
64
+ end
65
+
66
+ def self.delete_a_repository_invitation(owner: nil, repo: nil, invitation_id: nil, options: nil)
67
+ new.delete_a_repository_invitation(owner, repo, invitation_id, options)
68
+ end
69
+
70
+ def self.list_repository_invitations_for_the_authenticated_user(options: nil)
71
+ new.list_repository_invitations_for_the_authenticated_user(options)
72
+ end
73
+
74
+ def self.accept_a_repository_invitation(invitation_id: nil, options: nil)
75
+ new.accept_a_repository_invitation(invitation_id, options)
76
+ end
77
+
78
+ def self.decline_a_repository_invitation(invitation_id: nil, options: nil)
79
+ new.decline_a_repository_invitation(invitation_id, options)
80
+ end
81
+
82
+ private
83
+
84
+ # list repository collaborators
85
+ #
86
+ # @param owner [String]
87
+ # @param repo [String]
88
+ #
89
+ # @return CollaboratorsResult, CollaboratorsErrorResult
90
+ def list_repository_collaborators(owner, repo, options)
91
+ auth = nil
92
+ body = nil
93
+ headers = { accept: 'application/vnd.github.v3+json' }
94
+ params = { affiliation: options[:affiliation], per_page: options[:per_page], page: options[:page] }
95
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/collaborators"
96
+
97
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
98
+
99
+ if http_call.successful?
100
+ CollaboratorsResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
101
+ else
102
+ CollaboratorsErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
103
+ end
104
+ end
105
+
106
+ # check if a user is a repository collaborator
107
+ #
108
+ # @param owner [String]
109
+ # @param repo [String]
110
+ # @param username [String]
111
+ #
112
+ # @return CollaboratorsResult, CollaboratorsErrorResult
113
+ def check_if_a_user_is_a_repository_collaborator(owner, repo, username, _options)
114
+ auth = nil
115
+ body = nil
116
+ headers = { accept: 'application/vnd.github.v3+json' }
117
+ params = nil
118
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/collaborators/#{username}"
119
+
120
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
121
+
122
+ if http_call.successful?
123
+ CollaboratorsResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
124
+ else
125
+ CollaboratorsErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
126
+ end
127
+ end
128
+
129
+ # add a repository collaborator
130
+ #
131
+ # @param owner [String]
132
+ # @param repo [String]
133
+ # @param username [String]
134
+ # @param permission [String] The permission to grant the collaborator. Only valid on organization-owned repositories. Can be one of:
135
+ # * pull - can pull, but not push to or administer this repository.
136
+ # * push - can pull and push, but not administer this repository.
137
+ # * admin - can pull, push and administer this repository.
138
+ # * maintain - Recommended for project managers who need to manage the repository without access to sensitive or destructive actions.
139
+ # * triage - Recommended for contributors who need to proactively manage issues and pull requests without write access.
140
+ # * custom repository role name - A custom repository role, if the owning organization has defined any.Default: push
141
+ # @param permissions [String]
142
+ #
143
+ # @return CollaboratorsResult, CollaboratorsErrorResult
144
+ def add_a_repository_collaborator(_owner, _repo, _username, permission, permissions, _options)
145
+ auth = nil
146
+ body = { permission: permission, permissions: permissions }
147
+ headers = { accept: 'application/vnd.github.v3+json' }
148
+ params = nil
149
+ uri = "#{Gitabu::BASE_URL}Cannot assign #{member} permission of #{role name}
150
+ "
151
+
152
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :put, params: params, uri: uri)
153
+
154
+ if http_call.successful?
155
+ CollaboratorsResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
156
+ else
157
+ CollaboratorsErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
158
+ end
159
+ end
160
+
161
+ # remove a repository collaborator
162
+ #
163
+ # @param owner [String]
164
+ # @param repo [String]
165
+ # @param username [String]
166
+ #
167
+ # @return CollaboratorsResult, CollaboratorsErrorResult
168
+ def remove_a_repository_collaborator(owner, repo, username, _options)
169
+ auth = nil
170
+ body = nil
171
+ headers = { accept: 'application/vnd.github.v3+json' }
172
+ params = nil
173
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/collaborators/#{username}"
174
+
175
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :delete, params: params, uri: uri)
176
+
177
+ if http_call.successful?
178
+ CollaboratorsResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
179
+ else
180
+ CollaboratorsErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
181
+ end
182
+ end
183
+
184
+ # get repository permissions for a user
185
+ #
186
+ # @param owner [String]
187
+ # @param repo [String]
188
+ # @param username [String]
189
+ #
190
+ # @return CollaboratorsResult, CollaboratorsErrorResult
191
+ def get_repository_permissions_for_a_user(owner, repo, username, _options)
192
+ auth = nil
193
+ body = nil
194
+ headers = { accept: 'application/vnd.github.v3+json' }
195
+ params = nil
196
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/collaborators/#{username}/permission"
197
+
198
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
199
+
200
+ if http_call.successful?
201
+ CollaboratorsResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
202
+ else
203
+ CollaboratorsErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
204
+ end
205
+ end
206
+
207
+ # list repository invitations
208
+ #
209
+ # @param owner [String]
210
+ # @param repo [String]
211
+ #
212
+ # @return CollaboratorsResult, CollaboratorsErrorResult
213
+ def list_repository_invitations(owner, repo, options)
214
+ auth = nil
215
+ body = nil
216
+ headers = { accept: 'application/vnd.github.v3+json' }
217
+ params = { per_page: options[:per_page], page: options[:page] }
218
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/invitations"
219
+
220
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
221
+
222
+ if http_call.successful?
223
+ CollaboratorsResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
224
+ else
225
+ CollaboratorsErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
226
+ end
227
+ end
228
+
229
+ # update a repository invitation
230
+ #
231
+ # @param owner [String]
232
+ # @param repo [String]
233
+ # @param invitation_id [Integer] invitation_id parameter
234
+ # @param permissions [String] The permissions that the associated user will have on the repository. Valid values are read, write, maintain, triage, and admin.
235
+ #
236
+ # @return CollaboratorsResult, CollaboratorsErrorResult
237
+ def update_a_repository_invitation(owner, repo, invitation_id, permissions, _options)
238
+ auth = nil
239
+ body = { permissions: permissions }
240
+ headers = { accept: 'application/vnd.github.v3+json' }
241
+ params = nil
242
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/invitations/#{invitation_id}"
243
+
244
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :patch, params: params, uri: uri)
245
+
246
+ if http_call.successful?
247
+ CollaboratorsResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
248
+ else
249
+ CollaboratorsErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
250
+ end
251
+ end
252
+
253
+ # delete a repository invitation
254
+ #
255
+ # @param owner [String]
256
+ # @param repo [String]
257
+ # @param invitation_id [Integer] invitation_id parameter
258
+ #
259
+ # @return CollaboratorsResult, CollaboratorsErrorResult
260
+ def delete_a_repository_invitation(owner, repo, invitation_id, _options)
261
+ auth = nil
262
+ body = nil
263
+ headers = { accept: 'application/vnd.github.v3+json' }
264
+ params = nil
265
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/invitations/#{invitation_id}"
266
+
267
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :delete, params: params, uri: uri)
268
+
269
+ if http_call.successful?
270
+ CollaboratorsResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
271
+ else
272
+ CollaboratorsErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
273
+ end
274
+ end
275
+
276
+ # list repository invitations for the authenticated user
277
+ #
278
+ # @params options [Hash]
279
+ #
280
+ # @return CollaboratorsResult, CollaboratorsErrorResult
281
+ def list_repository_invitations_for_the_authenticated_user(options)
282
+ auth = nil
283
+ body = nil
284
+ headers = { accept: 'application/vnd.github.v3+json' }
285
+ params = { per_page: options[:per_page], page: options[:page] }
286
+ uri = "#{Gitabu::BASE_URL}/user/repository_invitations"
287
+
288
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
289
+
290
+ if http_call.successful?
291
+ CollaboratorsResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
292
+ else
293
+ CollaboratorsErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
294
+ end
295
+ end
296
+
297
+ # accept a repository invitation
298
+ #
299
+ # @param invitation_id [Integer] invitation_id parameter
300
+ #
301
+ # @return CollaboratorsResult, CollaboratorsErrorResult
302
+ def accept_a_repository_invitation(invitation_id, _options)
303
+ auth = nil
304
+ body = nil
305
+ headers = { accept: 'application/vnd.github.v3+json' }
306
+ params = nil
307
+ uri = "#{Gitabu::BASE_URL}/user/repository_invitations/#{invitation_id}"
308
+
309
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :patch, params: params, uri: uri)
310
+
311
+ if http_call.successful?
312
+ CollaboratorsResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
313
+ else
314
+ CollaboratorsErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
315
+ end
316
+ end
317
+
318
+ # decline a repository invitation
319
+ #
320
+ # @param invitation_id [Integer] invitation_id parameter
321
+ #
322
+ # @return CollaboratorsResult, CollaboratorsErrorResult
323
+ def decline_a_repository_invitation(invitation_id, _options)
324
+ auth = nil
325
+ body = nil
326
+ headers = { accept: 'application/vnd.github.v3+json' }
327
+ params = nil
328
+ uri = "#{Gitabu::BASE_URL}/user/repository_invitations/#{invitation_id}"
329
+
330
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :delete, params: params, uri: uri)
331
+
332
+ if http_call.successful?
333
+ CollaboratorsResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
334
+ else
335
+ CollaboratorsErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
336
+ end
337
+ end
338
+ end
339
+ end
340
+ end
341
+ end