-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathGitLabService.kt
More file actions
492 lines (376 loc) · 19.8 KB
/
GitLabService.kt
File metadata and controls
492 lines (376 loc) · 19.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
package com.commit451.gitlab.api
import com.commit451.gitlab.api.response.FileUploadResponse
import com.commit451.gitlab.model.api.*
import io.reactivex.Completable
import io.reactivex.Single
import okhttp3.MultipartBody
import retrofit2.Response
import retrofit2.http.*
/**
* Defines the interface for Retrofit for the GitLabService API
* http://doc.gitlab.com/ce/api/README.html
*/
interface GitLabService {
companion object {
const val API_VERSION = "api/v4"
const val MAX_PER_PAGE = "100"
}
/* --- USERS --- */
/**
* Get currently authenticated user
*/
@GET("user")
fun getThisUser(): Single<Response<User>>
@GET("users")
fun getUsers(): Single<List<User>>
@GET
fun getUsers(@Url url: String): Single<List<User>>
@GET("users")
fun searchUsers(@Query("search") query: String): Single<Response<List<User>>>
@GET
fun searchUsers(@Url url: String, @Query("search") query: String): Single<Response<List<User>>>
@GET("users/{id}")
fun getUser(@Path("id") userId: Long): Single<User>
/* --- GROUPS --- */
@GET("groups")
fun getGroups(): Single<Response<List<Group>>>
@GET
fun getGroups(@Url url: String): Single<Response<List<Group>>>
@GET("groups/{id}")
fun getGroup(@Path("id") id: Long): Single<Group>
@GET("groups/{id}/projects?order_by=last_activity_at")
fun getGroupProjects(@Path("id") id: Long): Single<Response<List<Project>>>
@GET("groups/{id}/members")
fun getGroupMembers(@Path("id") groupId: Long): Single<Response<List<User>>>
@FormUrlEncoded
@POST("groups/{id}/members")
fun addGroupMember(@Path("id") groupId: Long,
@Field("user_id") userId: Long,
@Field("access_level") accessLevel: Int): Single<Response<User>>
@FormUrlEncoded
@PUT("groups/{id}/members/{user_id}")
fun editGroupMember(@Path("id") groupId: Long,
@Path("user_id") userId: Long,
@Field("access_level") accessLevel: Int): Single<User>
@DELETE("groups/{id}/members/{user_id}")
fun removeGroupMember(@Path("id") groupId: Long,
@Path("user_id") userId: Long): Completable
/* --- PROJECTS --- */
@GET("projects?membership=true&order_by=last_activity_at")
fun getAllProjects(): Single<Response<List<Project>>>
@GET("users/{userId}/projects?order_by=last_activity_at")
fun getMyProjects(@Path("userId") userId: String): Single<Response<List<Project>>>
@GET("projects?starred=true")
fun getStarredProjects(): Single<Response<List<Project>>>
@GET("projects/{id}")
fun getProject(@Path("id") projectId: String): Single<Project>
// see https://docs.gitlab.com/ce/api/projects.html#get-single-project
@GET("projects/{namespace}%2F{project_name}")
fun getProject(@Path("namespace") namespace: String,
@Path("project_name") projectName: String): Single<Project>
@GET
fun getProjects(@Url url: String): Single<Response<List<Project>>>
@GET("projects")
fun searchAllProjects(@Query("search") query: String): Single<Response<List<Project>>>
@GET("projects/{id}/members")
fun getProjectMembers(@Path("id") projectId: Long): Single<Response<List<User>>>
@GET
fun getProjectMembers(@Url url: String): Single<Response<List<User>>>
@FormUrlEncoded
@POST("projects/{id}/members")
fun addProjectMember(@Path("id") projectId: Long,
@Field("user_id") userId: Long,
@Field("access_level") accessLevel: Int): Single<Response<User>>
@FormUrlEncoded
@PUT("projects/{id}/members/{user_id}")
fun editProjectMember(@Path("id") projectId: Long,
@Path("user_id") userId: Long,
@Field("access_level") accessLevel: Int): Single<User>
@DELETE("projects/{id}/members/{user_id}")
fun removeProjectMember(@Path("id") projectId: Long,
@Path("user_id") userId: Long): Completable
@POST("projects/{id}/fork")
fun forkProject(@Path("id") projectId: Long): Completable
@POST("projects/{id}/star")
fun starProject(@Path("id") projectId: Long): Single<Response<Project>>
@POST("projects/{id}/unstar")
fun unstarProject(@Path("id") projectId: Long): Single<Project>
@Multipart
@POST("projects/{id}/uploads")
fun uploadFile(@Path("id") projectId: Long,
@Part file: MultipartBody.Part): Single<FileUploadResponse>
/* --- MILESTONES --- */
@GET("projects/{id}/milestones")
fun getMilestones(@Path("id") projectId: Long,
@Query("state") state: String?): Single<Response<List<Milestone>>>
@GET
fun getMilestones(@Url url: String): Single<Response<List<Milestone>>>
@GET("projects/{id}/issues")
fun getMilestonesByIid(@Path("id") projectId: Long,
@Query("iids") internalMilestoneId: String): Single<List<Milestone>>
@GET("projects/{id}/milestones/{milestone_id}/issues")
fun getMilestoneIssues(@Path("id") projectId: Long,
@Path("milestone_id") milestoneId: Long): Single<Response<List<Issue>>>
@GET
fun getMilestoneIssues(@Url url: String): Single<Response<List<Issue>>>
@FormUrlEncoded
@POST("projects/{id}/milestones")
fun createMilestone(@Path("id") projectId: Long,
@Field("title") title: String,
@Field("description") description: String,
@Field("due_date") dueDate: String?): Single<Milestone>
@FormUrlEncoded
@PUT("projects/{id}/milestones/{milestone_id}")
fun editMilestone(@Path("id") projectId: Long,
@Path("milestone_id") milestoneId: Long,
@Field("title") title: String,
@Field("description") description: String,
@Field("due_date") dueDate: String?): Single<Milestone>
@PUT("projects/{id}/milestones/{milestone_id}")
fun updateMilestoneStatus(@Path("id") projectId: Long,
@Path("milestone_id") milestoneId: Long,
@Query("state_event") @Milestone.StateEvent status: String): Single<Milestone>
/* --- MERGE REQUESTS --- */
@GET("projects/{id}/merge_requests")
fun getMergeRequests(@Path("id") projectId: Long,
@Query("state") state: String): Single<Response<List<MergeRequest>>>
@GET
fun getMergeRequests(@Url url: String,
@Query("state") state: String): Single<Response<List<MergeRequest>>>
@GET("projects/{id}/merge_requests")
fun getMergeRequestsByIid(@Path("id") projectId: Long,
@Query("iids") internalMergeRequestId: String): Single<List<MergeRequest>>
@GET("projects/{id}/merge_requests/{merge_request_id}")
fun getMergeRequest(@Path("id") projectId: Long,
@Path("merge_request_id") mergeRequestId: Long): Single<MergeRequest>
@GET("projects/{id}/merge_requests/{merge_request_id}/commits")
fun getMergeRequestCommits(@Path("id") projectId: Long,
@Path("merge_request_id") mergeRequestId: Long): Single<List<RepositoryCommit>>
@GET("projects/{id}/merge_requests/{merge_request_id}/changes")
fun getMergeRequestChanges(@Path("id") projectId: Long,
@Path("merge_request_id") mergeRequestId: Long): Single<MergeRequest>
@GET("projects/{id}/merge_requests/{merge_request_id}/notes")
fun getMergeRequestNotes(@Path("id") projectId: Long,
@Path("merge_request_id") mergeRequestId: Long): Single<Response<List<Note>>>
@GET
fun getMergeRequestNotes(@Url url: String): Single<Response<List<Note>>>
@FormUrlEncoded
@POST("projects/{id}/merge_requests/{merge_request_id}/notes")
fun addMergeRequestNote(@Path("id") projectId: Long,
@Path("merge_request_id") mergeRequestId: Long,
@Field("body") body: String): Single<Note>
@PUT("projects/{id}/merge_requests/{merge_request_id}/merge")
fun acceptMergeRequest(@Path("id") projectId: Long,
@Path("merge_request_id") mergeRequestId: Long): Single<Response<MergeRequest>>
/* --- ISSUES --- */
@GET("projects/{id}/issues")
fun getIssues(@Path("id") projectId: Long,
@Query("state") state: String): Single<Response<List<Issue>>>
@GET
fun getIssues(@Url url: String): Single<Response<List<Issue>>>
@GET("projects/{id}/issues/{issue_id}")
fun getIssue(@Path("id") projectId: Long,
@Path("issue_id") issueId: String): Single<Issue>
@FormUrlEncoded
@POST("projects/{id}/issues")
fun createIssue(@Path("id") projectId: Long,
@Field("title") title: String,
@Field("description") description: String,
@Field("assignee_id") assigneeId: Long?,
@Field("milestone_id") milestoneId: Long?,
@Field("labels") commaSeparatedLabelNames: String?,
@Field("confidential") isConfidential: Boolean): Single<Issue>
@PUT("projects/{id}/issues/{issue_iid}")
fun updateIssue(@Path("id") projectId: Long,
@Path("issue_iid") issueIid: Long,
@Query("title") title: String,
@Query("description") description: String,
@Query("assignee_id") assigneeId: Long?,
@Query("milestone_id") milestoneId: Long?,
@Query("labels") commaSeparatedLabelNames: String?,
@Query("confidential") isConfidential: Boolean): Single<Issue>
@PUT("projects/{id}/issues/{issue_iid}")
fun updateIssueStatus(@Path("id") projectId: Long,
@Path("issue_iid") issueIid: Long,
@Query("state_event") @Issue.EditState status: String): Single<Issue>
@GET("projects/{id}/issues/{issue_iid}/notes")
fun getIssueNotes(@Path("id") projectId: Long,
@Path("issue_iid") issueIid: Long): Single<Response<List<Note>>>
@GET
fun getIssueNotes(@Url url: String): Single<Response<List<Note>>>
@FormUrlEncoded
@POST("projects/{id}/issues/{issue_iid}/notes")
fun addIssueNote(@Path("id") projectId: Long,
@Path("issue_iid") issueIid: Long,
@Field("body") body: String): Single<Note>
@DELETE("projects/{id}/issues/{issue_iid}")
fun deleteIssue(@Path("id") projectId: Long,
@Path("issue_iid") issueIid: Long): Completable
/* --- REPOSITORY --- */
@GET("projects/{id}/repository/branches?order_by=last_activity_at")
fun getBranches(@Path("id") projectId: Long): Single<Response<List<Branch>>>
@GET
fun getBranches(@Url url: String): Single<Response<List<Branch>>>
@GET("projects/{id}/repository/contributors")
fun getContributors(@Path("id") projectId: String): Single<List<Contributor>>
@GET("projects/{id}/repository/tree?per_page=$MAX_PER_PAGE")
fun getTree(@Path("id") projectId: Long,
@Query("ref") ref: String?,
@Query("path") path: String?): Single<List<RepositoryTreeObject>>
@GET("projects/{id}/repository/files/{file_path}")
fun getFile(@Path("id") projectId: Long,
@Path("file_path") path: String,
@Query("ref") ref: String): Single<RepositoryFile>
@HEAD("projects/{id}/repository/files/{file_path}")
fun getFileHead(@Path("id") projectId: Long,
@Path("file_path") path: String,
@Query("ref") ref: String): Single<Response<Void>>
@GET("projects/{id}/repository/commits")
fun getCommits(@Path("id") projectId: Long,
@Query("ref_name") branchName: String,
@Query("page") page: Int): Single<List<RepositoryCommit>>
@GET("projects/{id}/repository/commits/{sha}")
fun getCommit(@Path("id") projectId: Long,
@Path("sha") commitSHA: String): Single<RepositoryCommit>
@GET("projects/{id}/repository/commits/{sha}/diff")
fun getCommitDiff(@Path("id") projectId: Long,
@Path("sha") commitSHA: String): Single<List<Diff>>
/**
* Get the current labels for a project
* @param projectId id
* *
* @return all the labels within a project
*/
@GET("projects/{id}/labels?per_page=$MAX_PER_PAGE")
fun getLabels(@Path("id") projectId: Long): Single<List<Label>>
/**
* Create a new label
* @param projectId id
* *
* @param name the name of the label
* *
* @param color the color, ex. #ff0000
* *
* @return Single
*/
@POST("projects/{id}/labels")
fun createLabel(@Path("id") projectId: Long,
@Query("name") name: String,
@Query("color") color: String?,
@Query("description") description: String?): Single<Response<Label>>
/**
* Delete the label by its name
* @param projectId id
* *
* @return all the labels within a project
*/
@DELETE("projects/{id}/labels")
fun deleteLabel(@Path("id") projectId: Long,
@Query("name") name: String): Single<Label>
/* --- BUILDS --- */
@GET("projects/{id}/jobs")
fun getBuilds(@Path("id") projectId: Long,
@Query("scope") scope: String?): Single<Response<List<Build>>>
@GET
fun getBuilds(@Url url: String,
@Query("scope") state: String?): Single<Response<List<Build>>>
@GET("projects/{id}/jobs/{build_id}")
fun getBuild(@Path("id") projectId: Long,
@Path("build_id") buildId: Long): Single<Build>
@POST("projects/{id}/jobs/{build_id}/retry")
fun retryBuild(@Path("id") projectId: Long,
@Path("build_id") buildId: Long): Single<Build>
@POST("projects/{id}/jobs/{build_id}/erase")
fun eraseBuild(@Path("id") projectId: Long,
@Path("build_id") buildId: Long): Single<Build>
@POST("projects/{id}/jobs/{build_id}/cancel")
fun cancelBuild(@Path("id") projectId: Long,
@Path("build_id") buildId: Long): Single<Build>
/* --- Pipelines --- */
@GET("projects/{id}/pipelines")
fun getPipelines(@Path("id") projectId: Long,
@Query("scope") scope: String?): Single<Response<List<Pipeline>>>
@GET
fun getPipelines(@Url url: String,
@Query("scope") state: String?): Single<Response<List<Pipeline>>>
@GET("projects/{id}/pipelines/{pipeline_id}/jobs")
fun getPipelineJobs(@Path("id") projectId: Long, @Path("pipeline_id") pipelineId: Long,
@Query("scope") scope: String?): Single<Response<List<Pipeline>>>
@GET
fun getPipelineJobs(@Url url: String,
@Query("scope") state: String?): Single<Response<List<Pipeline>>>
@GET("projects/{id}/pipelines/{pipeline_id}")
fun getPipeline(@Path("id") projectId: Long,
@Path("pipeline_id") pipelineId: Long): Single<Pipeline>
@POST("projects/{id}/pipelines/{pipeline_id}/retry")
fun retryPipeline(@Path("id") projectId: Long,
@Path("pipeline_id") pipelineId: Long): Single<Pipeline>
@POST("projects/{id}/pipelines/{pipeline_id}/cancel")
fun cancelPipeline(@Path("id") projectId: Long,
@Path("pipeline_id") pipelineId: Long): Single<Pipeline>
/* --- SNIPPETS --- */
@GET("projects/{id}/snippets")
fun getSnippets(@Path("id") projectId: Long): Single<Response<List<Snippet>>>
@GET
fun getSnippets(@Url url: String): Single<Response<List<Snippet>>>
/* --- TODOS --- */
@GET("todos")
fun getTodos(@Query("state") @Todo.State state: String): Single<Response<List<Todo>>>
@GET
fun getTodosByUrl(@Url url: String): Single<Response<List<Todo>>>
/* --- TAGS --- */
@GET("projects/{id}/repository/tags")
fun getTags(@Path("id") projectId: Long): Single<List<Tag>>
/* --- AWARD EMOJI --- */
@GET("projects/{id}/issues/{issue_id}/award_emoji")
fun getAwardEmojiForIssue(@Path("id") projectId: Long,
@Path("issue_id") issueId: String): Single<List<AwardEmoji>>
@GET("projects/{id}/merge_requests/{merge_request_id}/award_emoji")
fun getAwardEmojiForMergeRequest(@Path("id") projectId: Long,
@Path("merge_request_id") mergeRequestId: String): Single<List<AwardEmoji>>
@GET("projects/{id}/issues/{issue_id}/notes/{note_id}/award_emoji")
fun getAwardEmojiForIssueNote(@Path("id") projectId: Long,
@Path("issue_id") issueId: String,
@Path("note_id") noteId: String): Single<List<AwardEmoji>>
@GET("projects/{id}/merge_requests/{merge_request_id}/notes/{note_id}/award_emoji")
fun getAwardEmojiForMergeRequestNote(@Path("id") projectId: Long,
@Path("merge_request_id") mergeRequestId: String,
@Path("note_id") noteId: String): Single<List<AwardEmoji>>
@POST("projects/{id}/issues/{issue_id}/award_emoji")
fun postAwardEmojiForIssue(@Path("id") projectId: Long,
@Path("issue_id") issueId: String): Single<AwardEmoji>
@GET("projects/{id}/merge_requests/{merge_request_id}/award_emoji")
fun postAwardEmojiForMergeRequest(@Path("id") projectId: Long,
@Path("merge_request_id") mergeRequestId: String): Single<AwardEmoji>
@GET("projects/{id}/merge_requests/{merge_request_id}/notes/{note_id}/award_emoji")
fun postAwardEmojiForMergeRequestNote(@Path("id") projectId: Long,
@Path("merge_request_id") mergeRequestId: String,
@Path("note_id") noteId: String): Single<AwardEmoji>
@POST("projects/{id}/issues/{issue_id}/notes/{note_id}/award_emoji")
fun postAwardEmojiForIssueNote(@Path("id") projectId: Long,
@Path("issue_id") issueId: String,
@Path("note_id") noteId: String): Single<AwardEmoji>
@DELETE("projects/{id}/issues/{issue_id}/award_emoji/{award_id}")
fun deleteAwardEmojiForIssue(@Path("id") projectId: Long,
@Path("issue_id") issueId: String,
@Path("award_id") awardId: String): Single<AwardEmoji>
@DELETE("projects/{id}/merge_requests/{merge_request_id}/award_emoji/{award_id}")
fun deleteAwardEmojiForMergeRequest(@Path("id") projectId: Long,
@Path("merge_request_id") mergeRequestId: String,
@Path("award_id") awardId: String): Single<AwardEmoji>
@DELETE("projects/{id}/issues/{issue_id}/notes/{note_id}/award_emoji/{award_id}")
fun deleteAwardEmojiForIssueNote(@Path("id") projectId: Long,
@Path("issue_id") issueId: String,
@Path("note_id") noteId: String,
@Path("award_id") awardId: String): Single<AwardEmoji>
@DELETE("projects/{id}/merge_requests/{merge_request_id}/notes/{note_id}/award_emoji/{award_id}")
fun deleteAwardEmojiForMergeRequestNote(@Path("id") projectId: Long,
@Path("merge_request_id") mergeRequestId: String,
@Path("note_id") noteId: String,
@Path("award_id") awardId: String): Single<AwardEmoji>
@GET("projects/{id}/wikis")
fun getWikiPages(@Path("id") projectId: Long): Single<List<Wiki>>
/* --- MISC --- */
@GET
fun getRaw(@Url url: String): Single<String>
}