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,409 @@
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 Git result
17
+ class GitResult
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 GitErrorResult
28
+ attr_accessor :result, :message
29
+
30
+ def initialize(result:, message:)
31
+ @result = result
32
+ @message = message
33
+ end
34
+ end
35
+
36
+ # Git endpoints.
37
+ class Git
38
+ def self.create_a_blob(owner: nil, repo: nil, content: nil, encoding: nil, options: nil)
39
+ new.create_a_blob(owner, repo, content, encoding, options)
40
+ end
41
+
42
+ def self.get_a_blob(owner: nil, repo: nil, file_sha: nil, options: nil)
43
+ new.get_a_blob(owner, repo, file_sha, options)
44
+ end
45
+
46
+ def self.create_a_commit(owner: nil, repo: nil, message: nil, tree: nil, parents: nil, author: nil, committer: nil, signature: nil, options: nil)
47
+ new.create_a_commit(owner, repo, message, tree, parents, author, committer, signature, options)
48
+ end
49
+
50
+ def self.get_a_commit(owner: nil, repo: nil, commit_sha: nil, options: nil)
51
+ new.get_a_commit(owner, repo, commit_sha, options)
52
+ end
53
+
54
+ def self.list_matching_references(owner: nil, repo: nil, ref: nil, options: nil)
55
+ new.list_matching_references(owner, repo, ref, options)
56
+ end
57
+
58
+ def self.get_a_reference(owner: nil, repo: nil, ref: nil, options: nil)
59
+ new.get_a_reference(owner, repo, ref, options)
60
+ end
61
+
62
+ def self.create_a_reference(owner: nil, repo: nil, ref: nil, sha: nil, key: nil, options: nil)
63
+ new.create_a_reference(owner, repo, ref, sha, key, options)
64
+ end
65
+
66
+ def self.update_a_reference(owner: nil, repo: nil, ref: nil, sha: nil, force: nil, options: nil)
67
+ new.update_a_reference(owner, repo, ref, sha, force, options)
68
+ end
69
+
70
+ def self.delete_a_reference(owner: nil, repo: nil, ref: nil, options: nil)
71
+ new.delete_a_reference(owner, repo, ref, options)
72
+ end
73
+
74
+ def self.create_a_tag_object(owner: nil, repo: nil, tag: nil, message: nil, object: nil, type: nil, tagger: nil, options: nil)
75
+ new.create_a_tag_object(owner, repo, tag, message, object, type, tagger, options)
76
+ end
77
+
78
+ def self.get_a_tag(owner: nil, repo: nil, tag_sha: nil, options: nil)
79
+ new.get_a_tag(owner, repo, tag_sha, options)
80
+ end
81
+
82
+ def self.create_a_tree(owner: nil, repo: nil, tree: nil, base_tree: nil, options: nil)
83
+ new.create_a_tree(owner, repo, tree, base_tree, options)
84
+ end
85
+
86
+ def self.get_a_tree(owner: nil, repo: nil, tree_sha: nil, options: nil)
87
+ new.get_a_tree(owner, repo, tree_sha, options)
88
+ end
89
+
90
+ private
91
+
92
+ # create a blob
93
+ #
94
+ # @param owner [String]
95
+ # @param repo [String]
96
+ # @param content [String] Required. The new blob's content.
97
+ # @param encoding [String] The encoding used for content. Currently, "utf-8" and "base64" are supported.Default: utf-8
98
+ #
99
+ # @return GitResult, GitErrorResult
100
+ def create_a_blob(owner, repo, content, encoding, _options)
101
+ auth = nil
102
+ body = { content: content, encoding: encoding }
103
+ headers = { accept: 'application/vnd.github.v3+json' }
104
+ params = nil
105
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/git/blobs"
106
+
107
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :post, params: params, uri: uri)
108
+
109
+ if http_call.successful?
110
+ GitResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
111
+ else
112
+ GitErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
113
+ end
114
+ end
115
+
116
+ # get a blob
117
+ #
118
+ # @param owner [String]
119
+ # @param repo [String]
120
+ # @param file_sha [String]
121
+ #
122
+ # @return GitResult, GitErrorResult
123
+ def get_a_blob(owner, repo, file_sha, _options)
124
+ auth = nil
125
+ body = nil
126
+ headers = { accept: 'application/vnd.github.v3+json' }
127
+ params = nil
128
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/git/blobs/#{file_sha}"
129
+
130
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
131
+
132
+ if http_call.successful?
133
+ GitResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
134
+ else
135
+ GitErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
136
+ end
137
+ end
138
+
139
+ # create a commit
140
+ #
141
+ # @param owner [String]
142
+ # @param repo [String]
143
+ # @param message [String] Required. The commit message
144
+ # @param tree [String] Required. The SHA of the tree object this commit points to
145
+ # @param parents [Array of strings] The SHAs of the commits that were the parents of this commit. If omitted or empty, the commit will be written as a root commit. For a single parent, an array of one SHA should be provided; for a merge commit, an array of more than one should be provided.
146
+ # @param author [Object] Information about the author of the commit. By default, the author will be the authenticated user and the current date. See the author and committer object below for details.
147
+ # @param committer [Object] Information about the person who is making the commit. By default, committer will use the information set in author. See the author and committer object below for details.
148
+ # @param signature [String] The PGP signature of the commit. GitHub adds the signature to the gpgsig header of the created commit. For a commit signature to be verifiable by Git or GitHub, it must be an ASCII-armored detached PGP signature over the string commit as it would be written to the object database. To pass a signature parameter, you need to first manually create a valid PGP signature, which can be complicated. You may find it easier to use the command line to create signed commits.
149
+ #
150
+ # @return GitResult, GitErrorResult
151
+ def create_a_commit(owner, repo, message, tree, parents, author, committer, signature, _options)
152
+ auth = nil
153
+ body = { message: message, tree: tree, parents: parents, author: author, committer: committer, signature: signature }
154
+ headers = { accept: 'application/vnd.github.v3+json' }
155
+ params = nil
156
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/git/commits"
157
+
158
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :post, params: params, uri: uri)
159
+
160
+ if http_call.successful?
161
+ GitResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
162
+ else
163
+ GitErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
164
+ end
165
+ end
166
+
167
+ # get a commit
168
+ #
169
+ # @param owner [String]
170
+ # @param repo [String]
171
+ # @param commit_sha [String] commit_sha parameter
172
+ #
173
+ # @return GitResult, GitErrorResult
174
+ def get_a_commit(owner, repo, commit_sha, _options)
175
+ auth = nil
176
+ body = nil
177
+ headers = { accept: 'application/vnd.github.v3+json' }
178
+ params = nil
179
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/git/commits/#{commit_sha}"
180
+
181
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
182
+
183
+ if http_call.successful?
184
+ GitResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
185
+ else
186
+ GitErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
187
+ end
188
+ end
189
+
190
+ # list matching references
191
+ #
192
+ # @param owner [String]
193
+ # @param repo [String]
194
+ # @param ref [String] ref parameter
195
+ #
196
+ # @return GitResult, GitErrorResult
197
+ def list_matching_references(owner, repo, ref, options)
198
+ auth = nil
199
+ body = nil
200
+ headers = { accept: 'application/vnd.github.v3+json' }
201
+ params = { per_page: options[:per_page], page: options[:page] }
202
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/git/matching-refs/#{ref}"
203
+
204
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
205
+
206
+ if http_call.successful?
207
+ GitResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
208
+ else
209
+ GitErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
210
+ end
211
+ end
212
+
213
+ # get a reference
214
+ #
215
+ # @param owner [String]
216
+ # @param repo [String]
217
+ # @param ref [String] ref parameter
218
+ #
219
+ # @return GitResult, GitErrorResult
220
+ def get_a_reference(owner, repo, ref, _options)
221
+ auth = nil
222
+ body = nil
223
+ headers = { accept: 'application/vnd.github.v3+json' }
224
+ params = nil
225
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/git/ref/#{ref}"
226
+
227
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
228
+
229
+ if http_call.successful?
230
+ GitResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
231
+ else
232
+ GitErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
233
+ end
234
+ end
235
+
236
+ # create a reference
237
+ #
238
+ # @param owner [String]
239
+ # @param repo [String]
240
+ # @param ref [String] Required. The name of the fully qualified reference (ie: refs/heads/master). If it doesn't start with 'refs' and have at least two slashes, it will be rejected.
241
+ # @param sha [String] Required. The SHA1 value for this reference.
242
+ # @param key [String]
243
+ #
244
+ # @return GitResult, GitErrorResult
245
+ def create_a_reference(owner, repo, ref, sha, key, _options)
246
+ auth = nil
247
+ body = { ref: ref, sha: sha, key: key }
248
+ headers = { accept: 'application/vnd.github.v3+json' }
249
+ params = nil
250
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/git/refs"
251
+
252
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :post, params: params, uri: uri)
253
+
254
+ if http_call.successful?
255
+ GitResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
256
+ else
257
+ GitErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
258
+ end
259
+ end
260
+
261
+ # update a reference
262
+ #
263
+ # @param owner [String]
264
+ # @param repo [String]
265
+ # @param ref [String] ref parameter
266
+ # @param sha [String] Required. The SHA1 value to set this reference to
267
+ # @param force [Boolean] Indicates whether to force the update or to make sure the update is a fast-forward update. Leaving this out or setting it to false will make sure you're not overwriting work.
268
+ #
269
+ # @return GitResult, GitErrorResult
270
+ def update_a_reference(owner, repo, ref, sha, force, _options)
271
+ auth = nil
272
+ body = { sha: sha, force: force }
273
+ headers = { accept: 'application/vnd.github.v3+json' }
274
+ params = nil
275
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/git/refs/#{ref}"
276
+
277
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :patch, params: params, uri: uri)
278
+
279
+ if http_call.successful?
280
+ GitResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
281
+ else
282
+ GitErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
283
+ end
284
+ end
285
+
286
+ # delete a reference
287
+ #
288
+ # @param owner [String]
289
+ # @param repo [String]
290
+ # @param ref [String] ref parameter
291
+ #
292
+ # @return GitResult, GitErrorResult
293
+ def delete_a_reference(owner, repo, ref, _options)
294
+ auth = nil
295
+ body = nil
296
+ headers = { accept: 'application/vnd.github.v3+json' }
297
+ params = nil
298
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/git/refs/#{ref}"
299
+
300
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :delete, params: params, uri: uri)
301
+
302
+ if http_call.successful?
303
+ GitResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
304
+ else
305
+ GitErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
306
+ end
307
+ end
308
+
309
+ # create a tag object
310
+ #
311
+ # @param owner [String]
312
+ # @param repo [String]
313
+ # @param tag [String] Required. The tag's name. This is typically a version (e.g., "v0.0.1").
314
+ # @param message [String] Required. The tag message.
315
+ # @param object [String] Required. The SHA of the git object this is tagging.
316
+ # @param type [String] Required. The type of the object we're tagging. Normally this is a commit but it can also be a tree or a blob.
317
+ # @param tagger [Object] An object with information about the individual creating the tag.
318
+ #
319
+ # @return GitResult, GitErrorResult
320
+ def create_a_tag_object(owner, repo, tag, message, object, type, tagger, _options)
321
+ auth = nil
322
+ body = { tag: tag, message: message, object: object, type: type, tagger: tagger }
323
+ headers = { accept: 'application/vnd.github.v3+json' }
324
+ params = nil
325
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/git/tags"
326
+
327
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :post, params: params, uri: uri)
328
+
329
+ if http_call.successful?
330
+ GitResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
331
+ else
332
+ GitErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
333
+ end
334
+ end
335
+
336
+ # get a tag
337
+ #
338
+ # @param owner [String]
339
+ # @param repo [String]
340
+ # @param tag_sha [String]
341
+ #
342
+ # @return GitResult, GitErrorResult
343
+ def get_a_tag(owner, repo, tag_sha, _options)
344
+ auth = nil
345
+ body = nil
346
+ headers = { accept: 'application/vnd.github.v3+json' }
347
+ params = nil
348
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/git/tags/#{tag_sha}"
349
+
350
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
351
+
352
+ if http_call.successful?
353
+ GitResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
354
+ else
355
+ GitErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
356
+ end
357
+ end
358
+
359
+ # create a tree
360
+ #
361
+ # @param owner [String]
362
+ # @param repo [String]
363
+ # @param tree [Array of objects] Required. Objects (of path, mode, type, and sha) specifying a tree structure.
364
+ # @param base_tree [String] The SHA1 of an existing Git tree object which will be used as the base for the new tree. If provided, a new Git tree object will be created from entries in the Git tree object pointed to by base_tree and entries defined in the tree parameter. Entries defined in the tree parameter will overwrite items from base_tree with the same path. If you're creating new changes on a branch, then normally you'd set base_tree to the SHA1 of the Git tree object of the current latest commit on the branch you're working on.
365
+ # If not provided, GitHub will create a new Git tree object from only the entries defined in the tree parameter. If you create a new commit pointing to such a tree, then all files which were a part of the parent commit's tree and were not defined in the tree parameter will be listed as deleted by the new commit.
366
+ #
367
+ # @return GitResult, GitErrorResult
368
+ def create_a_tree(owner, repo, tree, base_tree, _options)
369
+ auth = nil
370
+ body = { tree: tree, base_tree: base_tree }
371
+ headers = { accept: 'application/vnd.github.v3+json' }
372
+ params = nil
373
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/git/trees"
374
+
375
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :post, params: params, uri: uri)
376
+
377
+ if http_call.successful?
378
+ GitResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
379
+ else
380
+ GitErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
381
+ end
382
+ end
383
+
384
+ # get a tree
385
+ #
386
+ # @param owner [String]
387
+ # @param repo [String]
388
+ # @param tree_sha [String]
389
+ #
390
+ # @return GitResult, GitErrorResult
391
+ def get_a_tree(owner, repo, tree_sha, options)
392
+ auth = nil
393
+ body = nil
394
+ headers = { accept: 'application/vnd.github.v3+json' }
395
+ params = { recursive: options[:recursive] }
396
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/git/trees/#{tree_sha}"
397
+
398
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
399
+
400
+ if http_call.successful?
401
+ GitResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
402
+ else
403
+ GitErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
404
+ end
405
+ end
406
+ end
407
+ end
408
+ end
409
+ end
@@ -0,0 +1,92 @@
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 Gitignore result
17
+ class GitignoreResult
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 GitignoreErrorResult
28
+ attr_accessor :result, :message
29
+
30
+ def initialize(result:, message:)
31
+ @result = result
32
+ @message = message
33
+ end
34
+ end
35
+
36
+ # Gitignore endpoints.
37
+ class Gitignore
38
+ def self.get_all_gitignore_templates(options: nil)
39
+ new.get_all_gitignore_templates(options)
40
+ end
41
+
42
+ def self.get_a_gitignore_template(name: nil, options: nil)
43
+ new.get_a_gitignore_template(name, options)
44
+ end
45
+
46
+ private
47
+
48
+ # get all gitignore templates
49
+ #
50
+ # @params options [Hash]
51
+ #
52
+ # @return GitignoreResult, GitignoreErrorResult
53
+ def get_all_gitignore_templates(_options)
54
+ auth = nil
55
+ body = nil
56
+ headers = { accept: 'application/vnd.github.v3+json' }
57
+ params = nil
58
+ uri = "#{Gitabu::BASE_URL}/gitignore/templates"
59
+
60
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
61
+
62
+ if http_call.successful?
63
+ GitignoreResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
64
+ else
65
+ GitignoreErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
66
+ end
67
+ end
68
+
69
+ # get a gitignore template
70
+ #
71
+ # @param name [String]
72
+ #
73
+ # @return GitignoreResult, GitignoreErrorResult
74
+ def get_a_gitignore_template(name, _options)
75
+ auth = nil
76
+ body = nil
77
+ headers = { accept: 'application/vnd.github.v3+json' }
78
+ params = nil
79
+ uri = "#{Gitabu::BASE_URL}/gitignore/templates/#{name}"
80
+
81
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
82
+
83
+ if http_call.successful?
84
+ GitignoreResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
85
+ else
86
+ GitignoreErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
92
+ end