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,1098 @@
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 Branches result
17
+ class BranchesResult
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 BranchesErrorResult
28
+ attr_accessor :result, :message
29
+
30
+ def initialize(result:, message:)
31
+ @result = result
32
+ @message = message
33
+ end
34
+ end
35
+
36
+ # Branches endpoints.
37
+ class Branches
38
+ def self.list_branches(owner: nil, repo: nil, options: nil)
39
+ new.list_branches(owner, repo, options)
40
+ end
41
+
42
+ def self.get_a_branch(owner: nil, repo: nil, branch: nil, options: nil)
43
+ new.get_a_branch(owner, repo, branch, options)
44
+ end
45
+
46
+ def self.rename_a_branch(owner: nil, repo: nil, branch: nil, new_name: nil, options: nil)
47
+ new.rename_a_branch(owner, repo, branch, new_name, options)
48
+ end
49
+
50
+ def self.sync_a_fork_branch_with_the_upstream_repository(owner: nil, repo: nil, branch: nil, options: nil)
51
+ new.sync_a_fork_branch_with_the_upstream_repository(owner, repo, branch, options)
52
+ end
53
+
54
+ def self.merge_a_branch(owner: nil, repo: nil, base: nil, head: nil, commit_message: nil, options: nil)
55
+ new.merge_a_branch(owner, repo, base, head, commit_message, options)
56
+ end
57
+
58
+ def self.get_branch_protection(owner: nil, repo: nil, branch: nil, options: nil)
59
+ new.get_branch_protection(owner, repo, branch, options)
60
+ end
61
+
62
+ def self.update_branch_protection(owner: nil, repo: nil, branch: nil, required_status_checks: nil, enforce_admins: nil, required_pull_request_reviews: nil, restrictions: nil, required_linear_history: nil, allow_force_pushes: nil, allow_deletions: nil, required_conversation_resolution: nil, options: nil)
63
+ new.update_branch_protection(owner, repo, branch, required_status_checks, enforce_admins, required_pull_request_reviews, restrictions, required_linear_history, allow_force_pushes, allow_deletions, required_conversation_resolution, options)
64
+ end
65
+
66
+ def self.delete_branch_protection(owner: nil, repo: nil, branch: nil, options: nil)
67
+ new.delete_branch_protection(owner, repo, branch, options)
68
+ end
69
+
70
+ def self.get_admin_branch_protection(owner: nil, repo: nil, branch: nil, options: nil)
71
+ new.get_admin_branch_protection(owner, repo, branch, options)
72
+ end
73
+
74
+ def self.set_admin_branch_protection(owner: nil, repo: nil, branch: nil, options: nil)
75
+ new.set_admin_branch_protection(owner, repo, branch, options)
76
+ end
77
+
78
+ def self.delete_admin_branch_protection(owner: nil, repo: nil, branch: nil, options: nil)
79
+ new.delete_admin_branch_protection(owner, repo, branch, options)
80
+ end
81
+
82
+ def self.get_pull_request_review_protection(owner: nil, repo: nil, branch: nil, options: nil)
83
+ new.get_pull_request_review_protection(owner, repo, branch, options)
84
+ end
85
+
86
+ def self.update_pull_request_review_protection(owner: nil, repo: nil, branch: nil, dismissal_restrictions: nil, dismiss_stale_reviews: nil, require_code_owner_reviews: nil, required_approving_review_count: nil, bypass_pull_request_allowances: nil, options: nil)
87
+ new.update_pull_request_review_protection(owner, repo, branch, dismissal_restrictions, dismiss_stale_reviews, require_code_owner_reviews, required_approving_review_count, bypass_pull_request_allowances, options)
88
+ end
89
+
90
+ def self.delete_pull_request_review_protection(owner: nil, repo: nil, branch: nil, options: nil)
91
+ new.delete_pull_request_review_protection(owner, repo, branch, options)
92
+ end
93
+
94
+ def self.get_commit_signature_protection(owner: nil, repo: nil, branch: nil, options: nil)
95
+ new.get_commit_signature_protection(owner, repo, branch, options)
96
+ end
97
+
98
+ def self.create_commit_signature_protection(owner: nil, repo: nil, branch: nil, options: nil)
99
+ new.create_commit_signature_protection(owner, repo, branch, options)
100
+ end
101
+
102
+ def self.delete_commit_signature_protection(owner: nil, repo: nil, branch: nil, options: nil)
103
+ new.delete_commit_signature_protection(owner, repo, branch, options)
104
+ end
105
+
106
+ def self.get_status_checks_protection(owner: nil, repo: nil, branch: nil, options: nil)
107
+ new.get_status_checks_protection(owner, repo, branch, options)
108
+ end
109
+
110
+ def self.update_status_check_protection(owner: nil, repo: nil, branch: nil, strict: nil, contexts: nil, checks: nil, options: nil)
111
+ new.update_status_check_protection(owner, repo, branch, strict, contexts, checks, options)
112
+ end
113
+
114
+ def self.remove_status_check_protection(owner: nil, repo: nil, branch: nil, options: nil)
115
+ new.remove_status_check_protection(owner, repo, branch, options)
116
+ end
117
+
118
+ def self.get_all_status_check_contexts(owner: nil, repo: nil, branch: nil, options: nil)
119
+ new.get_all_status_check_contexts(owner, repo, branch, options)
120
+ end
121
+
122
+ def self.add_status_check_contexts(owner: nil, repo: nil, branch: nil, contexts: nil, options: nil)
123
+ new.add_status_check_contexts(owner, repo, branch, contexts, options)
124
+ end
125
+
126
+ def self.set_status_check_contexts(owner: nil, repo: nil, branch: nil, contexts: nil, options: nil)
127
+ new.set_status_check_contexts(owner, repo, branch, contexts, options)
128
+ end
129
+
130
+ def self.remove_status_check_contexts(owner: nil, repo: nil, branch: nil, contexts: nil, options: nil)
131
+ new.remove_status_check_contexts(owner, repo, branch, contexts, options)
132
+ end
133
+
134
+ def self.get_access_restrictions(owner: nil, repo: nil, branch: nil, options: nil)
135
+ new.get_access_restrictions(owner, repo, branch, options)
136
+ end
137
+
138
+ def self.delete_access_restrictions(owner: nil, repo: nil, branch: nil, options: nil)
139
+ new.delete_access_restrictions(owner, repo, branch, options)
140
+ end
141
+
142
+ def self.get_apps_with_access_to_the_protected_branch(owner: nil, repo: nil, branch: nil, options: nil)
143
+ new.get_apps_with_access_to_the_protected_branch(owner, repo, branch, options)
144
+ end
145
+
146
+ def self.add_app_access_restrictions(owner: nil, repo: nil, branch: nil, apps: nil, options: nil)
147
+ new.add_app_access_restrictions(owner, repo, branch, apps, options)
148
+ end
149
+
150
+ def self.set_app_access_restrictions(owner: nil, repo: nil, branch: nil, apps: nil, options: nil)
151
+ new.set_app_access_restrictions(owner, repo, branch, apps, options)
152
+ end
153
+
154
+ def self.remove_app_access_restrictions(owner: nil, repo: nil, branch: nil, apps: nil, options: nil)
155
+ new.remove_app_access_restrictions(owner, repo, branch, apps, options)
156
+ end
157
+
158
+ def self.get_teams_with_access_to_the_protected_branch(owner: nil, repo: nil, branch: nil, options: nil)
159
+ new.get_teams_with_access_to_the_protected_branch(owner, repo, branch, options)
160
+ end
161
+
162
+ def self.add_team_access_restrictions(owner: nil, repo: nil, branch: nil, teams: nil, options: nil)
163
+ new.add_team_access_restrictions(owner, repo, branch, teams, options)
164
+ end
165
+
166
+ def self.set_team_access_restrictions(owner: nil, repo: nil, branch: nil, teams: nil, options: nil)
167
+ new.set_team_access_restrictions(owner, repo, branch, teams, options)
168
+ end
169
+
170
+ def self.remove_team_access_restrictions(owner: nil, repo: nil, branch: nil, teams: nil, options: nil)
171
+ new.remove_team_access_restrictions(owner, repo, branch, teams, options)
172
+ end
173
+
174
+ def self.get_users_with_access_to_the_protected_branch(owner: nil, repo: nil, branch: nil, options: nil)
175
+ new.get_users_with_access_to_the_protected_branch(owner, repo, branch, options)
176
+ end
177
+
178
+ def self.add_user_access_restrictions(owner: nil, repo: nil, branch: nil, users: nil, options: nil)
179
+ new.add_user_access_restrictions(owner, repo, branch, users, options)
180
+ end
181
+
182
+ def self.set_user_access_restrictions(owner: nil, repo: nil, branch: nil, users: nil, options: nil)
183
+ new.set_user_access_restrictions(owner, repo, branch, users, options)
184
+ end
185
+
186
+ def self.remove_user_access_restrictions(owner: nil, repo: nil, branch: nil, users: nil, options: nil)
187
+ new.remove_user_access_restrictions(owner, repo, branch, users, options)
188
+ end
189
+
190
+ private
191
+
192
+ # list branches
193
+ #
194
+ # @param owner [String]
195
+ # @param repo [String]
196
+ #
197
+ # @return BranchesResult, BranchesErrorResult
198
+ def list_branches(owner, repo, options)
199
+ auth = nil
200
+ body = nil
201
+ headers = { accept: 'application/vnd.github.v3+json' }
202
+ params = { protected: options[:protected], per_page: options[:per_page], page: options[:page] }
203
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches"
204
+
205
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
206
+
207
+ if http_call.successful?
208
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
209
+ else
210
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
211
+ end
212
+ end
213
+
214
+ # get a branch
215
+ #
216
+ # @param owner [String]
217
+ # @param repo [String]
218
+ # @param branch [String] The name of the branch.
219
+ #
220
+ # @return BranchesResult, BranchesErrorResult
221
+ def get_a_branch(owner, repo, branch, _options)
222
+ auth = nil
223
+ body = nil
224
+ headers = { accept: 'application/vnd.github.v3+json' }
225
+ params = nil
226
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}"
227
+
228
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
229
+
230
+ if http_call.successful?
231
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
232
+ else
233
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
234
+ end
235
+ end
236
+
237
+ # rename a branch
238
+ #
239
+ # @param owner [String]
240
+ # @param repo [String]
241
+ # @param branch [String] The name of the branch.
242
+ # @param new_name [String] Required. The new name of the branch.
243
+ #
244
+ # @return BranchesResult, BranchesErrorResult
245
+ def rename_a_branch(owner, repo, branch, new_name, _options)
246
+ auth = nil
247
+ body = { new_name: new_name }
248
+ headers = { accept: 'application/vnd.github.v3+json' }
249
+ params = nil
250
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/rename"
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
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
256
+ else
257
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
258
+ end
259
+ end
260
+
261
+ # sync a fork branch with the upstream repository
262
+ #
263
+ # @param owner [String]
264
+ # @param repo [String]
265
+ # @param branch [String] Required. The name of the branch which should be updated to match upstream.
266
+ #
267
+ # @return BranchesResult, BranchesErrorResult
268
+ def sync_a_fork_branch_with_the_upstream_repository(owner, repo, branch, _options)
269
+ auth = nil
270
+ body = { branch: branch }
271
+ headers = { accept: 'application/vnd.github.v3+json' }
272
+ params = nil
273
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/merge-upstream"
274
+
275
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :post, params: params, uri: uri)
276
+
277
+ if http_call.successful?
278
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
279
+ else
280
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
281
+ end
282
+ end
283
+
284
+ # merge a branch
285
+ #
286
+ # @param owner [String]
287
+ # @param repo [String]
288
+ # @param base [String] Required. The name of the base branch that the head will be merged into.
289
+ # @param head [String] Required. The head to merge. This can be a branch name or a commit SHA1.
290
+ # @param commit_message [String] Commit message to use for the merge commit. If omitted, a default message will be used.
291
+ #
292
+ # @return BranchesResult, BranchesErrorResult
293
+ def merge_a_branch(owner, repo, base, head, commit_message, _options)
294
+ auth = nil
295
+ body = { base: base, head: head, commit_message: commit_message }
296
+ headers = { accept: 'application/vnd.github.v3+json' }
297
+ params = nil
298
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/merges"
299
+
300
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :post, params: params, uri: uri)
301
+
302
+ if http_call.successful?
303
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
304
+ else
305
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
306
+ end
307
+ end
308
+
309
+ # get branch protection
310
+ #
311
+ # @param owner [String]
312
+ # @param repo [String]
313
+ # @param branch [String] The name of the branch.
314
+ #
315
+ # @return BranchesResult, BranchesErrorResult
316
+ def get_branch_protection(owner, repo, branch, _options)
317
+ auth = nil
318
+ body = nil
319
+ headers = { accept: 'application/vnd.github.v3+json' }
320
+ params = nil
321
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection"
322
+
323
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
324
+
325
+ if http_call.successful?
326
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
327
+ else
328
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
329
+ end
330
+ end
331
+
332
+ # update branch protection
333
+ #
334
+ # @param owner [String]
335
+ # @param repo [String]
336
+ # @param branch [String] The name of the branch.
337
+ # @param required_status_checks [Object or null] Required. Require status checks to pass before merging. Set to null to disable.
338
+ # @param enforce_admins [Boolean or null] Required. Enforce all configured restrictions for administrators. Set to true to enforce required status checks for repository administrators. Set to null to disable.
339
+ # @param required_pull_request_reviews [Object or null] Required. Require at least one approving review on a pull request, before merging. Set to null to disable.
340
+ # @param restrictions [Object or null] Required. Restrict who can push to the protected branch. User, app, and team restrictions are only available for organization-owned repositories. Set to null to disable.
341
+ # @param required_linear_history [Boolean] Enforces a linear commit Git history, which prevents anyone from pushing merge commits to a branch. Set to true to enforce a linear commit history. Set to false to disable a linear commit Git history. Your repository must allow squash merging or rebase merging before you can enable a linear commit history. Default: false. For more information, see "Requiring a linear commit history" in the GitHub Help documentation.
342
+ # @param allow_force_pushes [Boolean or null] Permits force pushes to the protected branch by anyone with write access to the repository. Set to true to allow force pushes. Set to false or null to block force pushes. Default: false. For more information, see "Enabling force pushes to a protected branch" in the GitHub Help documentation."
343
+ # @param allow_deletions [Boolean] Allows deletion of the protected branch by anyone with write access to the repository. Set to false to prevent deletion of the protected branch. Default: false. For more information, see "Enabling force pushes to a protected branch" in the GitHub Help documentation.
344
+ # @param required_conversation_resolution [Boolean] Requires all conversations on code to be resolved before a pull request can be merged into a branch that matches this rule. Set to false to disable. Default: false.
345
+ #
346
+ # @return BranchesResult, BranchesErrorResult
347
+ def update_branch_protection(owner, repo, branch, required_status_checks, enforce_admins, required_pull_request_reviews, restrictions, required_linear_history, allow_force_pushes, allow_deletions, required_conversation_resolution, _options)
348
+ auth = nil
349
+ body = { required_status_checks: required_status_checks, enforce_admins: enforce_admins, required_pull_request_reviews: required_pull_request_reviews, restrictions: restrictions, required_linear_history: required_linear_history, allow_force_pushes: allow_force_pushes, allow_deletions: allow_deletions, required_conversation_resolution: required_conversation_resolution }
350
+ headers = { accept: 'application/vnd.github.v3+json' }
351
+ params = nil
352
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection"
353
+
354
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :put, params: params, uri: uri)
355
+
356
+ if http_call.successful?
357
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
358
+ else
359
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
360
+ end
361
+ end
362
+
363
+ # delete branch protection
364
+ #
365
+ # @param owner [String]
366
+ # @param repo [String]
367
+ # @param branch [String] The name of the branch.
368
+ #
369
+ # @return BranchesResult, BranchesErrorResult
370
+ def delete_branch_protection(owner, repo, branch, _options)
371
+ auth = nil
372
+ body = nil
373
+ headers = { accept: 'application/vnd.github.v3+json' }
374
+ params = nil
375
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection"
376
+
377
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :delete, params: params, uri: uri)
378
+
379
+ if http_call.successful?
380
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
381
+ else
382
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
383
+ end
384
+ end
385
+
386
+ # get admin branch protection
387
+ #
388
+ # @param owner [String]
389
+ # @param repo [String]
390
+ # @param branch [String] The name of the branch.
391
+ #
392
+ # @return BranchesResult, BranchesErrorResult
393
+ def get_admin_branch_protection(owner, repo, branch, _options)
394
+ auth = nil
395
+ body = nil
396
+ headers = { accept: 'application/vnd.github.v3+json' }
397
+ params = nil
398
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection/enforce_admins"
399
+
400
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
401
+
402
+ if http_call.successful?
403
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
404
+ else
405
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
406
+ end
407
+ end
408
+
409
+ # set admin branch protection
410
+ #
411
+ # @param owner [String]
412
+ # @param repo [String]
413
+ # @param branch [String] The name of the branch.
414
+ #
415
+ # @return BranchesResult, BranchesErrorResult
416
+ def set_admin_branch_protection(owner, repo, branch, _options)
417
+ auth = nil
418
+ body = nil
419
+ headers = { accept: 'application/vnd.github.v3+json' }
420
+ params = nil
421
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection/enforce_admins"
422
+
423
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :post, params: params, uri: uri)
424
+
425
+ if http_call.successful?
426
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
427
+ else
428
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
429
+ end
430
+ end
431
+
432
+ # delete admin branch protection
433
+ #
434
+ # @param owner [String]
435
+ # @param repo [String]
436
+ # @param branch [String] The name of the branch.
437
+ #
438
+ # @return BranchesResult, BranchesErrorResult
439
+ def delete_admin_branch_protection(owner, repo, branch, _options)
440
+ auth = nil
441
+ body = nil
442
+ headers = { accept: 'application/vnd.github.v3+json' }
443
+ params = nil
444
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection/enforce_admins"
445
+
446
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :delete, params: params, uri: uri)
447
+
448
+ if http_call.successful?
449
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
450
+ else
451
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
452
+ end
453
+ end
454
+
455
+ # get pull request review protection
456
+ #
457
+ # @param owner [String]
458
+ # @param repo [String]
459
+ # @param branch [String] The name of the branch.
460
+ #
461
+ # @return BranchesResult, BranchesErrorResult
462
+ def get_pull_request_review_protection(owner, repo, branch, _options)
463
+ auth = nil
464
+ body = nil
465
+ headers = { accept: 'application/vnd.github.v3+json' }
466
+ params = nil
467
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection/required_pull_request_reviews"
468
+
469
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
470
+
471
+ if http_call.successful?
472
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
473
+ else
474
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
475
+ end
476
+ end
477
+
478
+ # update pull request review protection
479
+ #
480
+ # @param owner [String]
481
+ # @param repo [String]
482
+ # @param branch [String] The name of the branch.
483
+ # @param dismissal_restrictions [Object] Specify which users and teams can dismiss pull request reviews. Pass an empty dismissal_restrictions object to disable. User and team dismissal_restrictions are only available for organization-owned repositories. Omit this parameter for personal repositories.
484
+ # @param dismiss_stale_reviews [Boolean] Set to true if you want to automatically dismiss approving reviews when someone pushes a new commit.
485
+ # @param require_code_owner_reviews [Boolean] Blocks merging pull requests until code owners have reviewed.
486
+ # @param required_approving_review_count [Integer] Specifies the number of reviewers required to approve pull requests. Use a number between 1 and 6 or 0 to not require reviewers.
487
+ # @param bypass_pull_request_allowances [Object] Allow specific users or teams to bypass pull request requirements.
488
+ #
489
+ # @return BranchesResult, BranchesErrorResult
490
+ def update_pull_request_review_protection(owner, repo, branch, dismissal_restrictions, dismiss_stale_reviews, require_code_owner_reviews, required_approving_review_count, bypass_pull_request_allowances, _options)
491
+ auth = nil
492
+ body = { dismissal_restrictions: dismissal_restrictions, dismiss_stale_reviews: dismiss_stale_reviews, require_code_owner_reviews: require_code_owner_reviews, required_approving_review_count: required_approving_review_count, bypass_pull_request_allowances: bypass_pull_request_allowances }
493
+ headers = { accept: 'application/vnd.github.v3+json' }
494
+ params = nil
495
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection/required_pull_request_reviews"
496
+
497
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :patch, params: params, uri: uri)
498
+
499
+ if http_call.successful?
500
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
501
+ else
502
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
503
+ end
504
+ end
505
+
506
+ # delete pull request review protection
507
+ #
508
+ # @param owner [String]
509
+ # @param repo [String]
510
+ # @param branch [String] The name of the branch.
511
+ #
512
+ # @return BranchesResult, BranchesErrorResult
513
+ def delete_pull_request_review_protection(owner, repo, branch, _options)
514
+ auth = nil
515
+ body = nil
516
+ headers = { accept: 'application/vnd.github.v3+json' }
517
+ params = nil
518
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection/required_pull_request_reviews"
519
+
520
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :delete, params: params, uri: uri)
521
+
522
+ if http_call.successful?
523
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
524
+ else
525
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
526
+ end
527
+ end
528
+
529
+ # get commit signature protection
530
+ #
531
+ # @param owner [String]
532
+ # @param repo [String]
533
+ # @param branch [String] The name of the branch.
534
+ #
535
+ # @return BranchesResult, BranchesErrorResult
536
+ def get_commit_signature_protection(owner, repo, branch, _options)
537
+ auth = nil
538
+ body = nil
539
+ headers = { accept: 'application/vnd.github.v3+json' }
540
+ params = nil
541
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection/required_signatures"
542
+
543
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
544
+
545
+ if http_call.successful?
546
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
547
+ else
548
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
549
+ end
550
+ end
551
+
552
+ # create commit signature protection
553
+ #
554
+ # @param owner [String]
555
+ # @param repo [String]
556
+ # @param branch [String] The name of the branch.
557
+ #
558
+ # @return BranchesResult, BranchesErrorResult
559
+ def create_commit_signature_protection(owner, repo, branch, _options)
560
+ auth = nil
561
+ body = nil
562
+ headers = { accept: 'application/vnd.github.v3+json' }
563
+ params = nil
564
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection/required_signatures"
565
+
566
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :post, params: params, uri: uri)
567
+
568
+ if http_call.successful?
569
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
570
+ else
571
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
572
+ end
573
+ end
574
+
575
+ # delete commit signature protection
576
+ #
577
+ # @param owner [String]
578
+ # @param repo [String]
579
+ # @param branch [String] The name of the branch.
580
+ #
581
+ # @return BranchesResult, BranchesErrorResult
582
+ def delete_commit_signature_protection(owner, repo, branch, _options)
583
+ auth = nil
584
+ body = nil
585
+ headers = { accept: 'application/vnd.github.v3+json' }
586
+ params = nil
587
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection/required_signatures"
588
+
589
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :delete, params: params, uri: uri)
590
+
591
+ if http_call.successful?
592
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
593
+ else
594
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
595
+ end
596
+ end
597
+
598
+ # get status checks protection
599
+ #
600
+ # @param owner [String]
601
+ # @param repo [String]
602
+ # @param branch [String] The name of the branch.
603
+ #
604
+ # @return BranchesResult, BranchesErrorResult
605
+ def get_status_checks_protection(owner, repo, branch, _options)
606
+ auth = nil
607
+ body = nil
608
+ headers = { accept: 'application/vnd.github.v3+json' }
609
+ params = nil
610
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection/required_status_checks"
611
+
612
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
613
+
614
+ if http_call.successful?
615
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
616
+ else
617
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
618
+ end
619
+ end
620
+
621
+ # update status check protection
622
+ #
623
+ # @param owner [String]
624
+ # @param repo [String]
625
+ # @param branch [String] The name of the branch.
626
+ # @param strict [Boolean] Require branches to be up to date before merging.
627
+ # @param contexts [Array of strings] Deprecated: The list of status checks to require in order to merge into this branch. If any of these checks have recently been set by a particular GitHub App, they will be required to come from that app in future for the branch to merge. Use checks instead of contexts for more fine-grained control.
628
+ # @param checks [Array of objects] The list of status checks to require in order to merge into this branch.
629
+ #
630
+ # @return BranchesResult, BranchesErrorResult
631
+ def update_status_check_protection(owner, repo, branch, strict, contexts, checks, _options)
632
+ auth = nil
633
+ body = { strict: strict, contexts: contexts, checks: checks }
634
+ headers = { accept: 'application/vnd.github.v3+json' }
635
+ params = nil
636
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection/required_status_checks"
637
+
638
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :patch, params: params, uri: uri)
639
+
640
+ if http_call.successful?
641
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
642
+ else
643
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
644
+ end
645
+ end
646
+
647
+ # remove status check protection
648
+ #
649
+ # @param owner [String]
650
+ # @param repo [String]
651
+ # @param branch [String] The name of the branch.
652
+ #
653
+ # @return BranchesResult, BranchesErrorResult
654
+ def remove_status_check_protection(owner, repo, branch, _options)
655
+ auth = nil
656
+ body = nil
657
+ headers = { accept: 'application/vnd.github.v3+json' }
658
+ params = nil
659
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection/required_status_checks"
660
+
661
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :delete, params: params, uri: uri)
662
+
663
+ if http_call.successful?
664
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
665
+ else
666
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
667
+ end
668
+ end
669
+
670
+ # get all status check contexts
671
+ #
672
+ # @param owner [String]
673
+ # @param repo [String]
674
+ # @param branch [String] The name of the branch.
675
+ #
676
+ # @return BranchesResult, BranchesErrorResult
677
+ def get_all_status_check_contexts(owner, repo, branch, _options)
678
+ auth = nil
679
+ body = nil
680
+ headers = { accept: 'application/vnd.github.v3+json' }
681
+ params = nil
682
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection/required_status_checks/contexts"
683
+
684
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
685
+
686
+ if http_call.successful?
687
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
688
+ else
689
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
690
+ end
691
+ end
692
+
693
+ # add status check contexts
694
+ #
695
+ # @param owner [String]
696
+ # @param repo [String]
697
+ # @param branch [String] The name of the branch.
698
+ # @param contexts [Array of strings] Required. contexts parameter
699
+ #
700
+ # @return BranchesResult, BranchesErrorResult
701
+ def add_status_check_contexts(owner, repo, branch, contexts, _options)
702
+ auth = nil
703
+ body = { contexts: contexts }
704
+ headers = { accept: 'application/vnd.github.v3+json' }
705
+ params = nil
706
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection/required_status_checks/contexts"
707
+
708
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :post, params: params, uri: uri)
709
+
710
+ if http_call.successful?
711
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
712
+ else
713
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
714
+ end
715
+ end
716
+
717
+ # set status check contexts
718
+ #
719
+ # @param owner [String]
720
+ # @param repo [String]
721
+ # @param branch [String] The name of the branch.
722
+ # @param contexts [Array of strings] Required. contexts parameter
723
+ #
724
+ # @return BranchesResult, BranchesErrorResult
725
+ def set_status_check_contexts(owner, repo, branch, contexts, _options)
726
+ auth = nil
727
+ body = { contexts: contexts }
728
+ headers = { accept: 'application/vnd.github.v3+json' }
729
+ params = nil
730
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection/required_status_checks/contexts"
731
+
732
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :put, params: params, uri: uri)
733
+
734
+ if http_call.successful?
735
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
736
+ else
737
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
738
+ end
739
+ end
740
+
741
+ # remove status check contexts
742
+ #
743
+ # @param owner [String]
744
+ # @param repo [String]
745
+ # @param branch [String] The name of the branch.
746
+ # @param contexts [Array of strings] Required. contexts parameter
747
+ #
748
+ # @return BranchesResult, BranchesErrorResult
749
+ def remove_status_check_contexts(owner, repo, branch, contexts, _options)
750
+ auth = nil
751
+ body = { contexts: contexts }
752
+ headers = { accept: 'application/vnd.github.v3+json' }
753
+ params = nil
754
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection/required_status_checks/contexts"
755
+
756
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :delete, params: params, uri: uri)
757
+
758
+ if http_call.successful?
759
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
760
+ else
761
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
762
+ end
763
+ end
764
+
765
+ # get access restrictions
766
+ #
767
+ # @param owner [String]
768
+ # @param repo [String]
769
+ # @param branch [String] The name of the branch.
770
+ #
771
+ # @return BranchesResult, BranchesErrorResult
772
+ def get_access_restrictions(owner, repo, branch, _options)
773
+ auth = nil
774
+ body = nil
775
+ headers = { accept: 'application/vnd.github.v3+json' }
776
+ params = nil
777
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection/restrictions"
778
+
779
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
780
+
781
+ if http_call.successful?
782
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
783
+ else
784
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
785
+ end
786
+ end
787
+
788
+ # delete access restrictions
789
+ #
790
+ # @param owner [String]
791
+ # @param repo [String]
792
+ # @param branch [String] The name of the branch.
793
+ #
794
+ # @return BranchesResult, BranchesErrorResult
795
+ def delete_access_restrictions(owner, repo, branch, _options)
796
+ auth = nil
797
+ body = nil
798
+ headers = { accept: 'application/vnd.github.v3+json' }
799
+ params = nil
800
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection/restrictions"
801
+
802
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :delete, params: params, uri: uri)
803
+
804
+ if http_call.successful?
805
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
806
+ else
807
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
808
+ end
809
+ end
810
+
811
+ # get apps with access to the protected branch
812
+ #
813
+ # @param owner [String]
814
+ # @param repo [String]
815
+ # @param branch [String] The name of the branch.
816
+ #
817
+ # @return BranchesResult, BranchesErrorResult
818
+ def get_apps_with_access_to_the_protected_branch(owner, repo, branch, _options)
819
+ auth = nil
820
+ body = nil
821
+ headers = { accept: 'application/vnd.github.v3+json' }
822
+ params = nil
823
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection/restrictions/apps"
824
+
825
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
826
+
827
+ if http_call.successful?
828
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
829
+ else
830
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
831
+ end
832
+ end
833
+
834
+ # add app access restrictions
835
+ #
836
+ # @param owner [String]
837
+ # @param repo [String]
838
+ # @param branch [String] The name of the branch.
839
+ # @param apps [Array of strings] Required. apps parameter
840
+ #
841
+ # @return BranchesResult, BranchesErrorResult
842
+ def add_app_access_restrictions(owner, repo, branch, apps, _options)
843
+ auth = nil
844
+ body = { apps: apps }
845
+ headers = { accept: 'application/vnd.github.v3+json' }
846
+ params = nil
847
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection/restrictions/apps"
848
+
849
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :post, params: params, uri: uri)
850
+
851
+ if http_call.successful?
852
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
853
+ else
854
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
855
+ end
856
+ end
857
+
858
+ # set app access restrictions
859
+ #
860
+ # @param owner [String]
861
+ # @param repo [String]
862
+ # @param branch [String] The name of the branch.
863
+ # @param apps [Array of strings] Required. apps parameter
864
+ #
865
+ # @return BranchesResult, BranchesErrorResult
866
+ def set_app_access_restrictions(owner, repo, branch, apps, _options)
867
+ auth = nil
868
+ body = { apps: apps }
869
+ headers = { accept: 'application/vnd.github.v3+json' }
870
+ params = nil
871
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection/restrictions/apps"
872
+
873
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :put, params: params, uri: uri)
874
+
875
+ if http_call.successful?
876
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
877
+ else
878
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
879
+ end
880
+ end
881
+
882
+ # remove app access restrictions
883
+ #
884
+ # @param owner [String]
885
+ # @param repo [String]
886
+ # @param branch [String] The name of the branch.
887
+ # @param apps [Array of strings] Required. apps parameter
888
+ #
889
+ # @return BranchesResult, BranchesErrorResult
890
+ def remove_app_access_restrictions(owner, repo, branch, apps, _options)
891
+ auth = nil
892
+ body = { apps: apps }
893
+ headers = { accept: 'application/vnd.github.v3+json' }
894
+ params = nil
895
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection/restrictions/apps"
896
+
897
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :delete, params: params, uri: uri)
898
+
899
+ if http_call.successful?
900
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
901
+ else
902
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
903
+ end
904
+ end
905
+
906
+ # get teams with access to the protected branch
907
+ #
908
+ # @param owner [String]
909
+ # @param repo [String]
910
+ # @param branch [String] The name of the branch.
911
+ #
912
+ # @return BranchesResult, BranchesErrorResult
913
+ def get_teams_with_access_to_the_protected_branch(owner, repo, branch, _options)
914
+ auth = nil
915
+ body = nil
916
+ headers = { accept: 'application/vnd.github.v3+json' }
917
+ params = nil
918
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection/restrictions/teams"
919
+
920
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
921
+
922
+ if http_call.successful?
923
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
924
+ else
925
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
926
+ end
927
+ end
928
+
929
+ # add team access restrictions
930
+ #
931
+ # @param owner [String]
932
+ # @param repo [String]
933
+ # @param branch [String] The name of the branch.
934
+ # @param teams [Array of strings] Required. teams parameter
935
+ #
936
+ # @return BranchesResult, BranchesErrorResult
937
+ def add_team_access_restrictions(owner, repo, branch, teams, _options)
938
+ auth = nil
939
+ body = { teams: teams }
940
+ headers = { accept: 'application/vnd.github.v3+json' }
941
+ params = nil
942
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection/restrictions/teams"
943
+
944
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :post, params: params, uri: uri)
945
+
946
+ if http_call.successful?
947
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
948
+ else
949
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
950
+ end
951
+ end
952
+
953
+ # set team access restrictions
954
+ #
955
+ # @param owner [String]
956
+ # @param repo [String]
957
+ # @param branch [String] The name of the branch.
958
+ # @param teams [Array of strings] Required. teams parameter
959
+ #
960
+ # @return BranchesResult, BranchesErrorResult
961
+ def set_team_access_restrictions(owner, repo, branch, teams, _options)
962
+ auth = nil
963
+ body = { teams: teams }
964
+ headers = { accept: 'application/vnd.github.v3+json' }
965
+ params = nil
966
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection/restrictions/teams"
967
+
968
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :put, params: params, uri: uri)
969
+
970
+ if http_call.successful?
971
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
972
+ else
973
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
974
+ end
975
+ end
976
+
977
+ # remove team access restrictions
978
+ #
979
+ # @param owner [String]
980
+ # @param repo [String]
981
+ # @param branch [String] The name of the branch.
982
+ # @param teams [Array of strings] Required. teams parameter
983
+ #
984
+ # @return BranchesResult, BranchesErrorResult
985
+ def remove_team_access_restrictions(owner, repo, branch, teams, _options)
986
+ auth = nil
987
+ body = { teams: teams }
988
+ headers = { accept: 'application/vnd.github.v3+json' }
989
+ params = nil
990
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection/restrictions/teams"
991
+
992
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :delete, params: params, uri: uri)
993
+
994
+ if http_call.successful?
995
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
996
+ else
997
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
998
+ end
999
+ end
1000
+
1001
+ # get users with access to the protected branch
1002
+ #
1003
+ # @param owner [String]
1004
+ # @param repo [String]
1005
+ # @param branch [String] The name of the branch.
1006
+ #
1007
+ # @return BranchesResult, BranchesErrorResult
1008
+ def get_users_with_access_to_the_protected_branch(owner, repo, branch, _options)
1009
+ auth = nil
1010
+ body = nil
1011
+ headers = { accept: 'application/vnd.github.v3+json' }
1012
+ params = nil
1013
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection/restrictions/users"
1014
+
1015
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :get, params: params, uri: uri)
1016
+
1017
+ if http_call.successful?
1018
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
1019
+ else
1020
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
1021
+ end
1022
+ end
1023
+
1024
+ # add user access restrictions
1025
+ #
1026
+ # @param owner [String]
1027
+ # @param repo [String]
1028
+ # @param branch [String] The name of the branch.
1029
+ # @param users [Array of strings] Required. users parameter
1030
+ #
1031
+ # @return BranchesResult, BranchesErrorResult
1032
+ def add_user_access_restrictions(owner, repo, branch, users, _options)
1033
+ auth = nil
1034
+ body = { users: users }
1035
+ headers = { accept: 'application/vnd.github.v3+json' }
1036
+ params = nil
1037
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection/restrictions/users"
1038
+
1039
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :post, params: params, uri: uri)
1040
+
1041
+ if http_call.successful?
1042
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
1043
+ else
1044
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
1045
+ end
1046
+ end
1047
+
1048
+ # set user access restrictions
1049
+ #
1050
+ # @param owner [String]
1051
+ # @param repo [String]
1052
+ # @param branch [String] The name of the branch.
1053
+ # @param users [Array of strings] Required. users parameter
1054
+ #
1055
+ # @return BranchesResult, BranchesErrorResult
1056
+ def set_user_access_restrictions(owner, repo, branch, users, _options)
1057
+ auth = nil
1058
+ body = { users: users }
1059
+ headers = { accept: 'application/vnd.github.v3+json' }
1060
+ params = nil
1061
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection/restrictions/users"
1062
+
1063
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :put, params: params, uri: uri)
1064
+
1065
+ if http_call.successful?
1066
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
1067
+ else
1068
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
1069
+ end
1070
+ end
1071
+
1072
+ # remove user access restrictions
1073
+ #
1074
+ # @param owner [String]
1075
+ # @param repo [String]
1076
+ # @param branch [String] The name of the branch.
1077
+ # @param users [Array of strings] Required. users parameter
1078
+ #
1079
+ # @return BranchesResult, BranchesErrorResult
1080
+ def remove_user_access_restrictions(owner, repo, branch, users, _options)
1081
+ auth = nil
1082
+ body = { users: users }
1083
+ headers = { accept: 'application/vnd.github.v3+json' }
1084
+ params = nil
1085
+ uri = "#{Gitabu::BASE_URL}/repos/#{owner}/#{repo}/branches/#{branch}/protection/restrictions/users"
1086
+
1087
+ http_call = Gitabu::HttpClient.call(auth: auth, body: body, headers: headers, method: :delete, params: params, uri: uri)
1088
+
1089
+ if http_call.successful?
1090
+ BranchesResult.new(result: http_call, message: "Successful call to endpoint. #{http_call.result.message}")
1091
+ else
1092
+ BranchesErrorResult.new(result: http_call, message: "Failure while calling endpoint. #{http_call.result.message}")
1093
+ end
1094
+ end
1095
+ end
1096
+ end
1097
+ end
1098
+ end