gitabu 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
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,419 @@
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 Dependabot result
17
+ class DependabotResult
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 DependabotErrorResult
28
+ attr_accessor :result, :message
29
+
30
+ def initialize(result:, message:)
31
+ @result = result
32
+ @message = message
33
+ end
34
+ end
35
+
36
+ # Dependabot endpoints.
37
+ class Dependabot
38
+ def self.list_organization_secrets(org: nil, options: nil)
39
+ new.list_organization_secrets(org, options)
40
+ end
41
+
42
+ def self.get_an_organization_public_key(org: nil, options: nil)
43
+ new.get_an_organization_public_key(org, options)
44
+ end
45
+
46
+ def self.get_an_organization_secret(org: nil, secret_name: nil, options: nil)
47
+ new.get_an_organization_secret(org, secret_name, options)
48
+ end
49
+
50
+ def self.create_or_update_an_organization_secret(org: nil, secret_name: nil, encrypted_value: nil, key_id: nil, visibility: nil, selected_repository_ids: nil, options: nil)
51
+ new.create_or_update_an_organization_secret(org, secret_name, encrypted_value, key_id, visibility, selected_repository_ids, options)
52
+ end
53
+
54
+ def self.delete_an_organization_secret(org: nil, secret_name: nil, options: nil)
55
+ new.delete_an_organization_secret(org, secret_name, options)
56
+ end
57
+
58
+ def self.list_selected_repositories_for_an_organization_secret(org: nil, secret_name: nil, options: nil)
59
+ new.list_selected_repositories_for_an_organization_secret(org, secret_name, options)
60
+ end
61
+
62
+ def self.set_selected_repositories_for_an_organization_secret(org: nil, secret_name: nil, selected_repository_ids: nil, options: nil)
63
+ new.set_selected_repositories_for_an_organization_secret(org, secret_name, selected_repository_ids, options)
64
+ end
65
+
66
+ def self.add_selected_repository_to_an_organization_secret(org: nil, secret_name: nil, repository_id: nil, options: nil)
67
+ new.add_selected_repository_to_an_organization_secret(org, secret_name, repository_id, options)
68
+ end
69
+
70
+ def self.remove_selected_repository_from_an_organization_secret(org: nil, secret_name: nil, repository_id: nil, options: nil)
71
+ new.remove_selected_repository_from_an_organization_secret(org, secret_name, repository_id, options)
72
+ end
73
+
74
+ def self.list_repository_secrets(owner: nil, repo: nil, options: nil)
75
+ new.list_repository_secrets(owner, repo, options)
76
+ end
77
+
78
+ def self.get_a_repository_public_key(owner: nil, repo: nil, options: nil)
79
+ new.get_a_repository_public_key(owner, repo, options)
80
+ end
81
+
82
+ def self.get_a_repository_secret(owner: nil, repo: nil, secret_name: nil, options: nil)
83
+ new.get_a_repository_secret(owner, repo, secret_name, options)
84
+ end
85
+
86
+ def self.create_or_update_a_repository_secret(owner: nil, repo: nil, secret_name: nil, encrypted_value: nil, key_id: nil, options: nil)
87
+ new.create_or_update_a_repository_secret(owner, repo, secret_name, encrypted_value, key_id, options)
88
+ end
89
+
90
+ def self.delete_a_repository_secret(owner: nil, repo: nil, secret_name: nil, options: nil)
91
+ new.delete_a_repository_secret(owner, repo, secret_name, options)
92
+ end
93
+
94
+ private
95
+
96
+ # list organization secrets
97
+ #
98
+ # @param org [String]
99
+ #
100
+ # @return DependabotResult, DependabotErrorResult
101
+ def list_organization_secrets(org, options)
102
+ auth = nil
103
+ body = nil
104
+ headers = { accept: 'application/vnd.github.v3+json' }
105
+ params = { per_page: options[:per_page], page: options[:page] }
106
+ uri = "#{Gitabu::BASE_URL}/orgs/#{org}/dependabot/secrets"
107
+
108
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
109
+
110
+ if http_call.successful?
111
+ DependabotResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
112
+ else
113
+ DependabotErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
114
+ end
115
+ end
116
+
117
+ # get an organization public key
118
+ #
119
+ # @param org [String]
120
+ #
121
+ # @return DependabotResult, DependabotErrorResult
122
+ def get_an_organization_public_key(org, _options)
123
+ auth = nil
124
+ body = nil
125
+ headers = { accept: 'application/vnd.github.v3+json' }
126
+ params = nil
127
+ uri = "#{Gitabu::BASE_URL}/orgs/#{org}/dependabot/secrets/public-key"
128
+
129
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
130
+
131
+ if http_call.successful?
132
+ DependabotResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
133
+ else
134
+ DependabotErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
135
+ end
136
+ end
137
+
138
+ # get an organization secret
139
+ #
140
+ # @param org [String]
141
+ # @param secret_name [String] secret_name parameter
142
+ #
143
+ # @return DependabotResult, DependabotErrorResult
144
+ def get_an_organization_secret(org, secret_name, _options)
145
+ auth = nil
146
+ body = nil
147
+ headers = { accept: 'application/vnd.github.v3+json' }
148
+ params = nil
149
+ uri = "#{Gitabu::BASE_URL}/orgs/#{org}/dependabot/secrets/#{secret_name}"
150
+
151
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
152
+
153
+ if http_call.successful?
154
+ DependabotResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
155
+ else
156
+ DependabotErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
157
+ end
158
+ end
159
+
160
+ # create or update an organization secret
161
+ #
162
+ # @param org [String]
163
+ # @param secret_name [String] secret_name parameter
164
+ # @param encrypted_value [String] Value for your secret, encrypted with LibSodium using the public key retrieved from the Get an organization public key endpoint.
165
+ # @param key_id [String] ID of the key you used to encrypt the secret.
166
+ # @param visibility [String] Required. Configures the access that repositories have to the organization secret. Can be one of:
167
+ # - all - All repositories in an organization can access the secret.
168
+ # - private - Private repositories in an organization can access the secret.
169
+ # - selected - Only specific repositories can access the secret.
170
+ # @param selected_repository_ids [Array of strings] An array of repository ids that can access the organization secret. You can only provide a list of repository ids when the visibility is set to selected. You can manage the list of selected repositories using the List selected repositories for an organization secret, Set selected repositories for an organization secret, and Remove selected repository from an organization secret endpoints.
171
+ #
172
+ # @return DependabotResult, DependabotErrorResult
173
+ def create_or_update_an_organization_secret(org, secret_name, encrypted_value, key_id, visibility, selected_repository_ids, _options)
174
+ auth = nil
175
+ body = { encrypted_value: encrypted_value, key_id: key_id, visibility: visibility, selected_repository_ids: selected_repository_ids }
176
+ headers = { accept: 'application/vnd.github.v3+json' }
177
+ params = nil
178
+ uri = "#{Gitabu::BASE_URL}/orgs/#{org}/dependabot/secrets/#{secret_name}"
179
+
180
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :put, params: params, uri: uri)
181
+
182
+ if http_call.successful?
183
+ DependabotResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
184
+ else
185
+ DependabotErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
186
+ end
187
+ end
188
+
189
+ # delete an organization secret
190
+ #
191
+ # @param org [String]
192
+ # @param secret_name [String] secret_name parameter
193
+ #
194
+ # @return DependabotResult, DependabotErrorResult
195
+ def delete_an_organization_secret(org, secret_name, _options)
196
+ auth = nil
197
+ body = nil
198
+ headers = { accept: 'application/vnd.github.v3+json' }
199
+ params = nil
200
+ uri = "#{Gitabu::BASE_URL}/orgs/#{org}/dependabot/secrets/#{secret_name}"
201
+
202
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :delete, params: params, uri: uri)
203
+
204
+ if http_call.successful?
205
+ DependabotResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
206
+ else
207
+ DependabotErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
208
+ end
209
+ end
210
+
211
+ # list selected repositories for an organization secret
212
+ #
213
+ # @param org [String]
214
+ # @param secret_name [String] secret_name parameter
215
+ #
216
+ # @return DependabotResult, DependabotErrorResult
217
+ def list_selected_repositories_for_an_organization_secret(org, secret_name, options)
218
+ auth = nil
219
+ body = nil
220
+ headers = { accept: 'application/vnd.github.v3+json' }
221
+ params = { page: options[:page], per_page: options[:per_page] }
222
+ uri = "#{Gitabu::BASE_URL}/orgs/#{org}/dependabot/secrets/#{secret_name}/repositories"
223
+
224
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
225
+
226
+ if http_call.successful?
227
+ DependabotResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
228
+ else
229
+ DependabotErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
230
+ end
231
+ end
232
+
233
+ # set selected repositories for an organization secret
234
+ #
235
+ # @param org [String]
236
+ # @param secret_name [String] secret_name parameter
237
+ # @param selected_repository_ids [Array of integers] Required. An array of repository ids that can access the organization secret. You can only provide a list of repository ids when the visibility is set to selected. You can add and remove individual repositories using the Set selected repositories for an organization secret and Remove selected repository from an organization secret endpoints.
238
+ #
239
+ # @return DependabotResult, DependabotErrorResult
240
+ def set_selected_repositories_for_an_organization_secret(org, secret_name, selected_repository_ids, _options)
241
+ auth = nil
242
+ body = { selected_repository_ids: selected_repository_ids }
243
+ headers = { accept: 'application/vnd.github.v3+json' }
244
+ params = nil
245
+ uri = "#{Gitabu::BASE_URL}/orgs/#{org}/dependabot/secrets/#{secret_name}/repositories"
246
+
247
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :put, params: params, uri: uri)
248
+
249
+ if http_call.successful?
250
+ DependabotResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
251
+ else
252
+ DependabotErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
253
+ end
254
+ end
255
+
256
+ # add selected repository to an organization secret
257
+ #
258
+ # @param org [String]
259
+ # @param secret_name [String] secret_name parameter
260
+ # @param repository_id [Integer]
261
+ #
262
+ # @return DependabotResult, DependabotErrorResult
263
+ def add_selected_repository_to_an_organization_secret(org, secret_name, repository_id, _options)
264
+ auth = nil
265
+ body = nil
266
+ headers = { accept: 'application/vnd.github.v3+json' }
267
+ params = nil
268
+ uri = "#{Gitabu::BASE_URL}/orgs/#{org}/dependabot/secrets/#{secret_name}/repositories/#{repository_id}"
269
+
270
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :put, params: params, uri: uri)
271
+
272
+ if http_call.successful?
273
+ DependabotResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
274
+ else
275
+ DependabotErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
276
+ end
277
+ end
278
+
279
+ # remove selected repository from an organization secret
280
+ #
281
+ # @param org [String]
282
+ # @param secret_name [String] secret_name parameter
283
+ # @param repository_id [Integer]
284
+ #
285
+ # @return DependabotResult, DependabotErrorResult
286
+ def remove_selected_repository_from_an_organization_secret(org, secret_name, repository_id, _options)
287
+ auth = nil
288
+ body = nil
289
+ headers = { accept: 'application/vnd.github.v3+json' }
290
+ params = nil
291
+ uri = "#{Gitabu::BASE_URL}/orgs/#{org}/dependabot/secrets/#{secret_name}/repositories/#{repository_id}"
292
+
293
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :delete, params: params, uri: uri)
294
+
295
+ if http_call.successful?
296
+ DependabotResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
297
+ else
298
+ DependabotErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
299
+ end
300
+ end
301
+
302
+ # list repository secrets
303
+ #
304
+ # @param owner [String]
305
+ # @param repo [String]
306
+ #
307
+ # @return DependabotResult, DependabotErrorResult
308
+ def list_repository_secrets(owner, repo, options)
309
+ auth = nil
310
+ body = nil
311
+ headers = { accept: 'application/vnd.github.v3+json' }
312
+ params = { per_page: options[:per_page], page: options[:page] }
313
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/dependabot/secrets"
314
+
315
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
316
+
317
+ if http_call.successful?
318
+ DependabotResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
319
+ else
320
+ DependabotErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
321
+ end
322
+ end
323
+
324
+ # get a repository public key
325
+ #
326
+ # @param owner [String]
327
+ # @param repo [String]
328
+ #
329
+ # @return DependabotResult, DependabotErrorResult
330
+ def get_a_repository_public_key(owner, repo, _options)
331
+ auth = nil
332
+ body = nil
333
+ headers = { accept: 'application/vnd.github.v3+json' }
334
+ params = nil
335
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/dependabot/secrets/public-key"
336
+
337
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
338
+
339
+ if http_call.successful?
340
+ DependabotResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
341
+ else
342
+ DependabotErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
343
+ end
344
+ end
345
+
346
+ # get a repository secret
347
+ #
348
+ # @param owner [String]
349
+ # @param repo [String]
350
+ # @param secret_name [String] secret_name parameter
351
+ #
352
+ # @return DependabotResult, DependabotErrorResult
353
+ def get_a_repository_secret(owner, repo, secret_name, _options)
354
+ auth = nil
355
+ body = nil
356
+ headers = { accept: 'application/vnd.github.v3+json' }
357
+ params = nil
358
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/dependabot/secrets/#{secret_name}"
359
+
360
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
361
+
362
+ if http_call.successful?
363
+ DependabotResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
364
+ else
365
+ DependabotErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
366
+ end
367
+ end
368
+
369
+ # create or update a repository secret
370
+ #
371
+ # @param owner [String]
372
+ # @param repo [String]
373
+ # @param secret_name [String] secret_name parameter
374
+ # @param encrypted_value [String] Value for your secret, encrypted with LibSodium using the public key retrieved from the Get a repository public key endpoint.
375
+ # @param key_id [String] ID of the key you used to encrypt the secret.
376
+ #
377
+ # @return DependabotResult, DependabotErrorResult
378
+ def create_or_update_a_repository_secret(owner, repo, secret_name, encrypted_value, key_id, _options)
379
+ auth = nil
380
+ body = { encrypted_value: encrypted_value, key_id: key_id }
381
+ headers = { accept: 'application/vnd.github.v3+json' }
382
+ params = nil
383
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/dependabot/secrets/#{secret_name}"
384
+
385
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :put, params: params, uri: uri)
386
+
387
+ if http_call.successful?
388
+ DependabotResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
389
+ else
390
+ DependabotErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
391
+ end
392
+ end
393
+
394
+ # delete a repository secret
395
+ #
396
+ # @param owner [String]
397
+ # @param repo [String]
398
+ # @param secret_name [String] secret_name parameter
399
+ #
400
+ # @return DependabotResult, DependabotErrorResult
401
+ def delete_a_repository_secret(owner, repo, secret_name, _options)
402
+ auth = nil
403
+ body = nil
404
+ headers = { accept: 'application/vnd.github.v3+json' }
405
+ params = nil
406
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/dependabot/secrets/#{secret_name}"
407
+
408
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :delete, params: params, uri: uri)
409
+
410
+ if http_call.successful?
411
+ DependabotResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
412
+ else
413
+ DependabotErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
414
+ end
415
+ end
416
+ end
417
+ end
418
+ end
419
+ end
@@ -0,0 +1,152 @@
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 Deploy_keys result
17
+ class DeployKeysResult
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 DeployKeysErrorResult
28
+ attr_accessor :result, :message
29
+
30
+ def initialize(result:, message:)
31
+ @result = result
32
+ @message = message
33
+ end
34
+ end
35
+
36
+ # Deploy keys endpoints.
37
+ class DeployKeys
38
+ def self.list_deploy_keys(owner: nil, repo: nil, options: nil)
39
+ new.list_deploy_keys(owner, repo, options)
40
+ end
41
+
42
+ def self.create_a_deploy_key(owner: nil, repo: nil, title: nil, key: nil, read_only: nil, options: nil)
43
+ new.create_a_deploy_key(owner, repo, title, key, read_only, options)
44
+ end
45
+
46
+ def self.get_a_deploy_key(owner: nil, repo: nil, key_id: nil, options: nil)
47
+ new.get_a_deploy_key(owner, repo, key_id, options)
48
+ end
49
+
50
+ def self.delete_a_deploy_key(owner: nil, repo: nil, key_id: nil, options: nil)
51
+ new.delete_a_deploy_key(owner, repo, key_id, options)
52
+ end
53
+
54
+ private
55
+
56
+ # list deploy keys
57
+ #
58
+ # @param owner [String]
59
+ # @param repo [String]
60
+ #
61
+ # @return DeployKeysResult, DeployKeysErrorResult
62
+ def list_deploy_keys(owner, repo, options)
63
+ auth = nil
64
+ body = nil
65
+ headers = { accept: 'application/vnd.github.v3+json' }
66
+ params = { per_page: options[:per_page], page: options[:page] }
67
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/keys"
68
+
69
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
70
+
71
+ if http_call.successful?
72
+ DeployKeysResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
73
+ else
74
+ DeployKeysErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
75
+ end
76
+ end
77
+
78
+ # create a deploy key
79
+ #
80
+ # @param owner [String]
81
+ # @param repo [String]
82
+ # @param title [String] A name for the key.
83
+ # @param key [String] Required. The contents of the key.
84
+ # @param read_only [Boolean] If true, the key will only be able to read repository contents. Otherwise, the key will be able to read and write.
85
+ # Deploy keys with write access can perform the same actions as an organization member with admin access, or a collaborator on a personal repository. For more information, see "Repository permission levels for an organization" and "Permission levels for a user account repository."
86
+ #
87
+ # @return DeployKeysResult, DeployKeysErrorResult
88
+ def create_a_deploy_key(owner, repo, title, key, read_only, _options)
89
+ auth = nil
90
+ body = { title: title, key: key, read_only: read_only }
91
+ headers = { accept: 'application/vnd.github.v3+json' }
92
+ params = nil
93
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/keys"
94
+
95
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :post, params: params, uri: uri)
96
+
97
+ if http_call.successful?
98
+ DeployKeysResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
99
+ else
100
+ DeployKeysErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
101
+ end
102
+ end
103
+
104
+ # get a deploy key
105
+ #
106
+ # @param owner [String]
107
+ # @param repo [String]
108
+ # @param key_id [Integer] key_id parameter
109
+ #
110
+ # @return DeployKeysResult, DeployKeysErrorResult
111
+ def get_a_deploy_key(owner, repo, key_id, _options)
112
+ auth = nil
113
+ body = nil
114
+ headers = { accept: 'application/vnd.github.v3+json' }
115
+ params = nil
116
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/keys/#{key_id}"
117
+
118
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
119
+
120
+ if http_call.successful?
121
+ DeployKeysResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
122
+ else
123
+ DeployKeysErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
124
+ end
125
+ end
126
+
127
+ # delete a deploy key
128
+ #
129
+ # @param owner [String]
130
+ # @param repo [String]
131
+ # @param key_id [Integer] key_id parameter
132
+ #
133
+ # @return DeployKeysResult, DeployKeysErrorResult
134
+ def delete_a_deploy_key(owner, repo, key_id, _options)
135
+ auth = nil
136
+ body = nil
137
+ headers = { accept: 'application/vnd.github.v3+json' }
138
+ params = nil
139
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/keys/#{key_id}"
140
+
141
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :delete, params: params, uri: uri)
142
+
143
+ if http_call.successful?
144
+ DeployKeysResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
145
+ else
146
+ DeployKeysErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
147
+ end
148
+ end
149
+ end
150
+ end
151
+ end
152
+ end