Skip to content
Snippets Groups Projects
Unverified Commit 1d8a60b5 authored by Noah Prail's avatar Noah Prail
Browse files

Initial work on API v4 upgrade!

parent 35eba923
No related branches found
No related tags found
No related merge requests found
Pipeline #
Loading
@@ -327,7 +327,7 @@ class AddIssueActivity : MorphActivity() {
Loading
@@ -327,7 +327,7 @@ class AddIssueActivity : MorphActivity() {
isConfidential)) isConfidential))
} else { } else {
observeUpdate(App.get().gitLab.updateIssue(project.id, observeUpdate(App.get().gitLab.updateIssue(project.id,
issue!!.id, issue!!.iid,
title, title,
description, description,
assigneeId, assigneeId,
Loading
Loading
Loading
@@ -119,7 +119,7 @@ class IssueActivity : BaseActivity() {
Loading
@@ -119,7 +119,7 @@ class IssueActivity : BaseActivity() {
return@OnMenuItemClickListener true return@OnMenuItemClickListener true
} }
R.id.action_delete -> { R.id.action_delete -> {
App.get().gitLab.deleteIssue(project!!.id, issue!!.id) App.get().gitLab.deleteIssue(project!!.id, issue!!.iid)
.setup(bindToLifecycle()) .setup(bindToLifecycle())
.subscribe(object : CustomSingleObserver<String>() { .subscribe(object : CustomSingleObserver<String>() {
   
Loading
@@ -194,7 +194,7 @@ class IssueActivity : BaseActivity() {
Loading
@@ -194,7 +194,7 @@ class IssueActivity : BaseActivity() {
App.get().gitLab.getProject(projectNamespace, projectName) App.get().gitLab.getProject(projectNamespace, projectName)
.flatMap { project -> .flatMap { project ->
this@IssueActivity.project = project this@IssueActivity.project = project
App.get().gitLab.getIssuesByIid(project.id, issueIid!!) App.get().gitLab.getIssuesByIid(project.id)
} }
.compose(this.bindToLifecycle<List<Issue>>()) .compose(this.bindToLifecycle<List<Issue>>())
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
Loading
@@ -263,7 +263,7 @@ class IssueActivity : BaseActivity() {
Loading
@@ -263,7 +263,7 @@ class IssueActivity : BaseActivity() {
fun loadNotes() { fun loadNotes() {
swipeRefreshLayout.isRefreshing = true swipeRefreshLayout.isRefreshing = true
loading = true loading = true
App.get().gitLab.getIssueNotes(project!!.id, issue!!.id) App.get().gitLab.getIssueNotes(project!!.id, issue!!.iid)
.compose(this.bindToLifecycle<Response<List<Note>>>()) .compose(this.bindToLifecycle<Response<List<Note>>>())
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
Loading
@@ -323,7 +323,7 @@ class IssueActivity : BaseActivity() {
Loading
@@ -323,7 +323,7 @@ class IssueActivity : BaseActivity() {
teleprinter.hideKeyboard() teleprinter.hideKeyboard()
sendMessageView.clearText() sendMessageView.clearText()
   
App.get().gitLab.addIssueNote(project!!.id, issue!!.id, message) App.get().gitLab.addIssueNote(project!!.id, issue!!.iid, message)
.setup(bindToLifecycle()) .setup(bindToLifecycle())
.subscribe(object : CustomSingleObserver<Note>() { .subscribe(object : CustomSingleObserver<Note>() {
   
Loading
@@ -345,9 +345,9 @@ class IssueActivity : BaseActivity() {
Loading
@@ -345,9 +345,9 @@ class IssueActivity : BaseActivity() {
fun closeOrOpenIssue() { fun closeOrOpenIssue() {
progress.visibility = View.VISIBLE progress.visibility = View.VISIBLE
if (issue!!.state == Issue.STATE_CLOSED) { if (issue!!.state == Issue.STATE_CLOSED) {
updateIssueStatus(App.get().gitLab.updateIssueStatus(project!!.id, issue!!.id, Issue.STATE_REOPEN)) updateIssueStatus(App.get().gitLab.updateIssueStatus(project!!.id, issue!!.iid, Issue.STATE_REOPEN))
} else { } else {
updateIssueStatus(App.get().gitLab.updateIssueStatus(project!!.id, issue!!.id, Issue.STATE_CLOSE)) updateIssueStatus(App.get().gitLab.updateIssueStatus(project!!.id, issue!!.iid, Issue.STATE_CLOSE))
} }
} }
   
Loading
Loading
Loading
@@ -15,7 +15,7 @@ import retrofit2.http.*
Loading
@@ -15,7 +15,7 @@ import retrofit2.http.*
interface GitLabService { interface GitLabService {
   
companion object { companion object {
const val API_VERSION = "api/v3" const val API_VERSION = "api/v4"
} }
   
/* --- LOGIN --- */ /* --- LOGIN --- */
Loading
@@ -80,19 +80,19 @@ interface GitLabService {
Loading
@@ -80,19 +80,19 @@ interface GitLabService {
   
/* --- PROJECTS --- */ /* --- PROJECTS --- */
   
@GET(API_VERSION + "/projects?order_by=last_activity_at&archived=false") @GET(API_VERSION + "/projects?membership=true&order_by=last_activity_at&archived=false")
fun getAllProjects(): Single<Response<List<Project>>> fun getAllProjects(): Single<Response<List<Project>>>
   
@GET(API_VERSION + "/projects/owned?order_by=last_activity_at&archived=false") @GET(API_VERSION + "/projects?owned=true&order_by=last_activity_at&archived=false")
fun getMyProjects(): Single<Response<List<Project>>> fun getMyProjects(): Single<Response<List<Project>>>
   
@GET(API_VERSION + "/projects/starred") @GET(API_VERSION + "/projects?starred=true")
fun getStarredProjects(): Single<Response<List<Project>>> fun getStarredProjects(): Single<Response<List<Project>>>
   
@GET(API_VERSION + "/projects/{id}") @GET(API_VERSION + "/projects/{id}")
fun getProject(@Path("id") projectId: String): Single<Project> fun getProject(@Path("id") projectId: String): Single<Project>
   
// see https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/projects.md#get-single-project // see https://docs.gitlab.com/ce/api/projects.html#get-single-project
@GET(API_VERSION + "/projects/{namespace}%2F{project_name}") @GET(API_VERSION + "/projects/{namespace}%2F{project_name}")
fun getProject(@Path("namespace") namespace: String, fun getProject(@Path("namespace") namespace: String,
@Path("project_name") projectName: String): Single<Project> @Path("project_name") projectName: String): Single<Project>
Loading
@@ -100,7 +100,7 @@ interface GitLabService {
Loading
@@ -100,7 +100,7 @@ interface GitLabService {
@GET @GET
fun getProjects(@Url url: String): Single<Response<List<Project>>> fun getProjects(@Url url: String): Single<Response<List<Project>>>
   
@GET(API_VERSION + "/projects/search/{query}") @GET(API_VERSION + "/projects?search={query}")
fun searchAllProjects(@Path("query") query: String): Single<Response<List<Project>>> fun searchAllProjects(@Path("query") query: String): Single<Response<List<Project>>>
   
@GET(API_VERSION + "/projects/{id}/members") @GET(API_VERSION + "/projects/{id}/members")
Loading
@@ -125,13 +125,13 @@ interface GitLabService {
Loading
@@ -125,13 +125,13 @@ interface GitLabService {
fun removeProjectMember(@Path("id") projectId: Long, fun removeProjectMember(@Path("id") projectId: Long,
@Path("user_id") userId: Long): Single<String> @Path("user_id") userId: Long): Single<String>
   
@POST(API_VERSION + "/projects/fork/{id}") @POST(API_VERSION + "/projects/{id}/fork")
fun forkProject(@Path("id") projectId: Long): Single<String> fun forkProject(@Path("id") projectId: Long): Single<String>
   
@POST(API_VERSION + "/projects/{id}/star") @POST(API_VERSION + "/projects/{id}/star")
fun starProject(@Path("id") projectId: Long): Single<Response<Project>> fun starProject(@Path("id") projectId: Long): Single<Response<Project>>
   
@DELETE(API_VERSION + "/projects/{id}/star") @POST(API_VERSION + "/projects/{id}/unstar")
fun unstarProject(@Path("id") projectId: Long): Single<Project> fun unstarProject(@Path("id") projectId: Long): Single<Project>
   
@Multipart @Multipart
Loading
@@ -148,9 +148,10 @@ interface GitLabService {
Loading
@@ -148,9 +148,10 @@ interface GitLabService {
@GET @GET
fun getMilestones(@Url url: String): Single<Response<List<Milestone>>> fun getMilestones(@Url url: String): Single<Response<List<Milestone>>>
   
@GET(API_VERSION + "/projects/{id}/issues") @GET(API_VERSION + "/projects/{id}/issues")
fun getMilestonesByIid(@Path("id") projectId: Long, fun getMilestonesByIid(@Path("id") projectId: Long,
@Query("iid") internalMilestoneId: String): Single<List<Milestone>> @Query("iids") internalMilestoneId: String): Single<List<Milestone>>
   
@GET(API_VERSION + "/projects/{id}/milestones/{milestone_id}/issues") @GET(API_VERSION + "/projects/{id}/milestones/{milestone_id}/issues")
fun getMilestoneIssues(@Path("id") projectId: Long, fun getMilestoneIssues(@Path("id") projectId: Long,
Loading
@@ -191,9 +192,9 @@ interface GitLabService {
Loading
@@ -191,9 +192,9 @@ interface GitLabService {
   
@GET(API_VERSION + "/projects/{id}/merge_requests") @GET(API_VERSION + "/projects/{id}/merge_requests")
fun getMergeRequestsByIid(@Path("id") projectId: Long, fun getMergeRequestsByIid(@Path("id") projectId: Long,
@Query("iid") internalMergeRequestId: String): Single<List<MergeRequest>> @Query("iids") internalMergeRequestId: String): Single<List<MergeRequest>>
   
@GET(API_VERSION + "/projects/{id}/merge_request/{merge_request_id}") @GET(API_VERSION + "/projects/{id}/merge_requests/{merge_request_id}")
fun getMergeRequest(@Path("id") projectId: Long, fun getMergeRequest(@Path("id") projectId: Long,
@Path("merge_request_id") mergeRequestId: Long): Single<MergeRequest> @Path("merge_request_id") mergeRequestId: Long): Single<MergeRequest>
   
Loading
@@ -236,8 +237,7 @@ interface GitLabService {
Loading
@@ -236,8 +237,7 @@ interface GitLabService {
@Path("issue_id") issueId: String): Single<Issue> @Path("issue_id") issueId: String): Single<Issue>
   
@GET(API_VERSION + "/projects/{id}/issues") @GET(API_VERSION + "/projects/{id}/issues")
fun getIssuesByIid(@Path("id") projectId: Long, fun getIssuesByIid(@Path("id") projectId: Long): Single<List<Issue>>
@Query("iid") internalIssueId: String): Single<List<Issue>>
   
@FormUrlEncoded @FormUrlEncoded
@POST(API_VERSION + "/projects/{id}/issues") @POST(API_VERSION + "/projects/{id}/issues")
Loading
@@ -249,9 +249,9 @@ interface GitLabService {
Loading
@@ -249,9 +249,9 @@ interface GitLabService {
@Field("labels") commaSeparatedLabelNames: String?, @Field("labels") commaSeparatedLabelNames: String?,
@Field("confidential") isConfidential: Boolean): Single<Issue> @Field("confidential") isConfidential: Boolean): Single<Issue>
   
@PUT(API_VERSION + "/projects/{id}/issues/{issue_id}") @PUT(API_VERSION + "/projects/{id}/issues/{issue_iid}")
fun updateIssue(@Path("id") projectId: Long, fun updateIssue(@Path("id") projectId: Long,
@Path("issue_id") issueId: Long, @Path("issue_iid") issueIid: Long,
@Query("title") title: String, @Query("title") title: String,
@Query("description") description: String, @Query("description") description: String,
@Query("assignee_id") assigneeId: Long?, @Query("assignee_id") assigneeId: Long?,
Loading
@@ -259,27 +259,27 @@ interface GitLabService {
Loading
@@ -259,27 +259,27 @@ interface GitLabService {
@Query("labels") commaSeparatedLabelNames: String?, @Query("labels") commaSeparatedLabelNames: String?,
@Query("confidential") isConfidential: Boolean): Single<Issue> @Query("confidential") isConfidential: Boolean): Single<Issue>
   
@PUT(API_VERSION + "/projects/{id}/issues/{issue_id}") @PUT(API_VERSION + "/projects/{id}/issues/{issue_iid}")
fun updateIssueStatus(@Path("id") projectId: Long, fun updateIssueStatus(@Path("id") projectId: Long,
@Path("issue_id") issueId: Long, @Path("issue_iid") issueIid: Long,
@Query("state_event") @Issue.EditState status: String): Single<Issue> @Query("state_event") @Issue.EditState status: String): Single<Issue>
   
@GET(API_VERSION + "/projects/{id}/issues/{issue_id}/notes") @GET(API_VERSION + "/projects/{id}/issues/{issue_iid}/notes")
fun getIssueNotes(@Path("id") projectId: Long, fun getIssueNotes(@Path("id") projectId: Long,
@Path("issue_id") issueId: Long): Single<Response<List<Note>>> @Path("issue_iid") issueIid: Long): Single<Response<List<Note>>>
   
@GET @GET
fun getIssueNotes(@Url url: String): Single<Response<List<Note>>> fun getIssueNotes(@Url url: String): Single<Response<List<Note>>>
   
@FormUrlEncoded @FormUrlEncoded
@POST(API_VERSION + "/projects/{id}/issues/{issue_id}/notes") @POST(API_VERSION + "/projects/{id}/issues/{issue_iid}/notes")
fun addIssueNote(@Path("id") projectId: Long, fun addIssueNote(@Path("id") projectId: Long,
@Path("issue_id") issueId: Long, @Path("issue_iid") issueIid: Long,
@Field("body") body: String): Single<Note> @Field("body") body: String): Single<Note>
   
@DELETE(API_VERSION + "/projects/{id}/issues/{issue_id}") @DELETE(API_VERSION + "/projects/{id}/issues/{issue_iid}")
fun deleteIssue(@Path("id") projectId: Long, fun deleteIssue(@Path("id") projectId: Long,
@Path("issue_id") issueId: Long): Single<String> @Path("issue_iid") issueIid: Long): Single<String>
   
/* --- REPOSITORY --- */ /* --- REPOSITORY --- */
   
Loading
@@ -294,9 +294,9 @@ interface GitLabService {
Loading
@@ -294,9 +294,9 @@ interface GitLabService {
@Query("ref_name") branchName: String, @Query("ref_name") branchName: String,
@Query("path") path: String?): Single<List<RepositoryTreeObject>> @Query("path") path: String?): Single<List<RepositoryTreeObject>>
   
@GET(API_VERSION + "/projects/{id}/repository/files") @GET(API_VERSION + "/projects/{id}/repository/files/{file_path}")
fun getFile(@Path("id") projectId: Long, fun getFile(@Path("id") projectId: Long,
@Query("file_path") path: String, @Path("file_path") path: String,
@Query("ref") ref: String): Single<RepositoryFile> @Query("ref") ref: String): Single<RepositoryFile>
   
@GET(API_VERSION + "/projects/{id}/repository/commits") @GET(API_VERSION + "/projects/{id}/repository/commits")
Loading
@@ -352,7 +352,7 @@ interface GitLabService {
Loading
@@ -352,7 +352,7 @@ interface GitLabService {
   
   
/* --- BUILDS --- */ /* --- BUILDS --- */
@GET(API_VERSION + "/projects/{id}/builds") @GET(API_VERSION + "/projects/{id}/jobs")
fun getBuilds(@Path("id") projectId: Long, fun getBuilds(@Path("id") projectId: Long,
@Query("scope") scope: String?): Single<Response<List<Build>>> @Query("scope") scope: String?): Single<Response<List<Build>>>
   
Loading
@@ -360,19 +360,19 @@ interface GitLabService {
Loading
@@ -360,19 +360,19 @@ interface GitLabService {
fun getBuilds(@Url url: String, fun getBuilds(@Url url: String,
@Query("scope") state: String?): Single<Response<List<Build>>> @Query("scope") state: String?): Single<Response<List<Build>>>
   
@GET(API_VERSION + "/projects/{id}/builds/{build_id}") @GET(API_VERSION + "/projects/{id}/jobs/{build_id}")
fun getBuild(@Path("id") projectId: Long, fun getBuild(@Path("id") projectId: Long,
@Path("build_id") buildId: Long): Single<Build> @Path("build_id") buildId: Long): Single<Build>
   
@POST(API_VERSION + "/projects/{id}/builds/{build_id}/retry") @POST(API_VERSION + "/projects/{id}/jobs/{build_id}/retry")
fun retryBuild(@Path("id") projectId: Long, fun retryBuild(@Path("id") projectId: Long,
@Path("build_id") buildId: Long): Single<Build> @Path("build_id") buildId: Long): Single<Build>
   
@POST(API_VERSION + "/projects/{id}/builds/{build_id}/erase") @POST(API_VERSION + "/projects/{id}/jobs/{build_id}/erase")
fun eraseBuild(@Path("id") projectId: Long, fun eraseBuild(@Path("id") projectId: Long,
@Path("build_id") buildId: Long): Single<Build> @Path("build_id") buildId: Long): Single<Build>
   
@POST(API_VERSION + "/projects/{id}/builds/{build_id}/cancel") @POST(API_VERSION + "/projects/{id}/jobs/{build_id}/cancel")
fun cancelBuild(@Path("id") projectId: Long, fun cancelBuild(@Path("id") projectId: Long,
@Path("build_id") buildId: Long): Single<Build> @Path("build_id") buildId: Long): Single<Build>
   
Loading
Loading
Loading
@@ -105,7 +105,7 @@ class CommitsFragment : ButterKnifeFragment() {
Loading
@@ -105,7 +105,7 @@ class CommitsFragment : ButterKnifeFragment() {
   
swipeRefreshLayout.isRefreshing = true swipeRefreshLayout.isRefreshing = true
   
page = 0 page = 1
loading = true loading = true
   
App.get().gitLab.getCommits(project!!.id, branchName!!, page) App.get().gitLab.getCommits(project!!.id, branchName!!, page)
Loading
Loading
Loading
@@ -107,7 +107,7 @@ class ApiTests {
Loading
@@ -107,7 +107,7 @@ class ApiTests {
fun getCommits() { fun getCommits() {
val defaultBranch = "master" val defaultBranch = "master"
val commitsResponse = gitLab!! val commitsResponse = gitLab!!
.getCommits(fakeProject!!.id, defaultBranch, 0) .getCommits(fakeProject!!.id, defaultBranch, 1)
.blockingGet() .blockingGet()
assertNotNull(commitsResponse) assertNotNull(commitsResponse)
} }
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment