Skip to content
Snippets Groups Projects
Commit 95b835b7 authored by John's avatar John
Browse files

Merge branch '247-api-v4' into 'develop'

Resolve "API v4"

See merge request !29
parents cd291cdf 9244f470
No related branches found
No related tags found
1 merge request!29Resolve "API v4"
Pipeline #
Showing
with 58 additions and 51 deletions
Loading
Loading
@@ -76,6 +76,8 @@ android {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
ext.enableCrashlytics = false
applicationIdSuffix ".debug"
versionNameSuffix "-debug"
}
}
lintOptions {
Loading
Loading
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">LabCoat Debug</string>
<string name="leak_canary_display_activity_label">LabCoat Leaks</string>
</resources>
\ No newline at end of file
Loading
Loading
@@ -327,7 +327,7 @@ class AddIssueActivity : MorphActivity() {
isConfidential))
} else {
observeUpdate(App.get().gitLab.updateIssue(project.id,
issue!!.id,
issue!!.iid,
title,
description,
assigneeId,
Loading
Loading
Loading
Loading
@@ -119,7 +119,7 @@ class IssueActivity : BaseActivity() {
return@OnMenuItemClickListener true
}
R.id.action_delete -> {
App.get().gitLab.deleteIssue(project!!.id, issue!!.id)
App.get().gitLab.deleteIssue(project!!.id, issue!!.iid)
.setup(bindToLifecycle())
.subscribe(object : CustomSingleObserver<String>() {
 
Loading
Loading
@@ -194,7 +194,7 @@ class IssueActivity : BaseActivity() {
App.get().gitLab.getProject(projectNamespace, projectName)
.flatMap { project ->
this@IssueActivity.project = project
App.get().gitLab.getIssuesByIid(project.id, issueIid!!)
App.get().gitLab.getIssuesByIid(project.id)
}
.compose(this.bindToLifecycle<List<Issue>>())
.subscribeOn(Schedulers.io())
Loading
Loading
@@ -263,7 +263,7 @@ class IssueActivity : BaseActivity() {
fun loadNotes() {
swipeRefreshLayout.isRefreshing = 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>>>())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
Loading
Loading
@@ -323,7 +323,7 @@ class IssueActivity : BaseActivity() {
teleprinter.hideKeyboard()
sendMessageView.clearText()
 
App.get().gitLab.addIssueNote(project!!.id, issue!!.id, message)
App.get().gitLab.addIssueNote(project!!.id, issue!!.iid, message)
.setup(bindToLifecycle())
.subscribe(object : CustomSingleObserver<Note>() {
 
Loading
Loading
@@ -345,9 +345,9 @@ class IssueActivity : BaseActivity() {
fun closeOrOpenIssue() {
progress.visibility = View.VISIBLE
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 {
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
Loading
@@ -15,7 +15,7 @@ import retrofit2.http.*
interface GitLabService {
 
companion object {
const val API_VERSION = "api/v3"
const val API_VERSION = "api/v4"
}
 
/* --- LOGIN --- */
Loading
Loading
@@ -80,19 +80,19 @@ interface GitLabService {
 
/* --- 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>>>
 
@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>>>
 
@GET(API_VERSION + "/projects/starred")
@GET(API_VERSION + "/projects?starred=true")
fun getStarredProjects(): Single<Response<List<Project>>>
 
@GET(API_VERSION + "/projects/{id}")
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}")
fun getProject(@Path("namespace") namespace: String,
@Path("project_name") projectName: String): Single<Project>
Loading
Loading
@@ -100,8 +100,8 @@ interface GitLabService {
@GET
fun getProjects(@Url url: String): Single<Response<List<Project>>>
 
@GET(API_VERSION + "/projects/search/{query}")
fun searchAllProjects(@Path("query") query: String): Single<Response<List<Project>>>
@GET(API_VERSION + "/projects")
fun searchAllProjects(@Query("search") query: String): Single<Response<List<Project>>>
 
@GET(API_VERSION + "/projects/{id}/members")
fun getProjectMembers(@Path("id") projectId: Long): Single<Response<List<Member>>>
Loading
Loading
@@ -125,13 +125,13 @@ interface GitLabService {
fun removeProjectMember(@Path("id") projectId: Long,
@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>
 
@POST(API_VERSION + "/projects/{id}/star")
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>
 
@Multipart
Loading
Loading
@@ -150,7 +150,7 @@ interface GitLabService {
 
@GET(API_VERSION + "/projects/{id}/issues")
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")
fun getMilestoneIssues(@Path("id") projectId: Long,
Loading
Loading
@@ -191,9 +191,9 @@ interface GitLabService {
 
@GET(API_VERSION + "/projects/{id}/merge_requests")
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,
@Path("merge_request_id") mergeRequestId: Long): Single<MergeRequest>
 
Loading
Loading
@@ -236,8 +236,7 @@ interface GitLabService {
@Path("issue_id") issueId: String): Single<Issue>
 
@GET(API_VERSION + "/projects/{id}/issues")
fun getIssuesByIid(@Path("id") projectId: Long,
@Query("iid") internalIssueId: String): Single<List<Issue>>
fun getIssuesByIid(@Path("id") projectId: Long): Single<List<Issue>>
 
@FormUrlEncoded
@POST(API_VERSION + "/projects/{id}/issues")
Loading
Loading
@@ -249,9 +248,9 @@ interface GitLabService {
@Field("labels") commaSeparatedLabelNames: String?,
@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,
@Path("issue_id") issueId: Long,
@Path("issue_iid") issueIid: Long,
@Query("title") title: String,
@Query("description") description: String,
@Query("assignee_id") assigneeId: Long?,
Loading
Loading
@@ -259,27 +258,27 @@ interface GitLabService {
@Query("labels") commaSeparatedLabelNames: String?,
@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,
@Path("issue_id") issueId: Long,
@Path("issue_iid") issueIid: Long,
@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,
@Path("issue_id") issueId: Long): Single<Response<List<Note>>>
@Path("issue_iid") issueIid: Long): Single<Response<List<Note>>>
 
@GET
fun getIssueNotes(@Url url: String): Single<Response<List<Note>>>
 
@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,
@Path("issue_id") issueId: Long,
@Path("issue_iid") issueIid: Long,
@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,
@Path("issue_id") issueId: Long): Single<String>
@Path("issue_iid") issueIid: Long): Single<String>
 
/* --- REPOSITORY --- */
 
Loading
Loading
@@ -294,9 +293,9 @@ interface GitLabService {
@Query("ref_name") branchName: String,
@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,
@Query("file_path") path: String,
@Path("file_path") path: String,
@Query("ref") ref: String): Single<RepositoryFile>
 
@GET(API_VERSION + "/projects/{id}/repository/commits")
Loading
Loading
@@ -352,7 +351,7 @@ interface GitLabService {
 
 
/* --- BUILDS --- */
@GET(API_VERSION + "/projects/{id}/builds")
@GET(API_VERSION + "/projects/{id}/jobs")
fun getBuilds(@Path("id") projectId: Long,
@Query("scope") scope: String?): Single<Response<List<Build>>>
 
Loading
Loading
@@ -360,19 +359,19 @@ interface GitLabService {
fun getBuilds(@Url url: String,
@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,
@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,
@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,
@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,
@Path("build_id") buildId: Long): Single<Build>
 
Loading
Loading
Loading
Loading
@@ -105,7 +105,7 @@ class CommitsFragment : ButterKnifeFragment() {
 
swipeRefreshLayout.isRefreshing = true
 
page = 0
page = 1
loading = true
 
App.get().gitLab.getCommits(project!!.id, branchName!!, page)
Loading
Loading
Loading
Loading
@@ -141,7 +141,7 @@ class IssueDiscussionFragment : ButterKnifeFragment() {
 
fun loadNotes() {
swipeRefreshLayout.isRefreshing = true
App.get().gitLab.getMergeRequestNotes(project.id, mergeRequest.id)
App.get().gitLab.getMergeRequestNotes(project.id, mergeRequest.iid)
.setup(bindUntilEvent(FragmentEvent.DESTROY_VIEW))
.subscribe(object : CustomResponseSingleObserver<List<Note>>() {
 
Loading
Loading
Loading
Loading
@@ -114,7 +114,7 @@ class MergeRequestCommitsFragment : ButterKnifeFragment() {
page = 0
loading = true
 
App.get().gitLab.getMergeRequestCommits(project!!.id, mergeRequest!!.id)
App.get().gitLab.getMergeRequestCommits(project!!.id, mergeRequest!!.iid)
.setup(bindUntilEvent(FragmentEvent.DESTROY_VIEW))
.subscribe(object : CustomSingleObserver<List<RepositoryCommit>>() {
 
Loading
Loading
@@ -156,7 +156,7 @@ class MergeRequestCommitsFragment : ButterKnifeFragment() {
 
@Subscribe
fun onMergeRequestChangedEvent(event: MergeRequestChangedEvent) {
if (mergeRequest!!.id == event.mergeRequest.id) {
if (mergeRequest!!.iid == event.mergeRequest.id) {
mergeRequest = event.mergeRequest
loadData()
}
Loading
Loading
Loading
Loading
@@ -144,7 +144,7 @@ class MergeRequestDiscussionFragment : ButterKnifeFragment() {
 
fun loadNotes() {
swipeRefreshLayout.isRefreshing = true
App.get().gitLab.getMergeRequestNotes(project.id, mergeRequest.id)
App.get().gitLab.getMergeRequestNotes(project.id, mergeRequest.iid)
.setup(bindUntilEvent(FragmentEvent.DESTROY_VIEW))
.subscribe(object : CustomResponseSingleObserver<List<Note>>() {
 
Loading
Loading
Loading
Loading
@@ -12,6 +12,8 @@ import butterknife.BindView
import com.commit451.gitlab.App
import com.commit451.gitlab.R
import com.commit451.gitlab.event.PipelineChangedEvent
import com.commit451.gitlab.extension.getParcelerParcelable
import com.commit451.gitlab.extension.putParcelParcelableExtra
import com.commit451.gitlab.extension.setup
import com.commit451.gitlab.model.api.*
import com.commit451.gitlab.rx.CustomSingleObserver
Loading
Loading
@@ -28,15 +30,14 @@ import java.util.*
class PipelineDescriptionFragment : ButterKnifeFragment() {
 
companion object {
private val KEY_PROJECT = "project"
private val KEY_PIPELINE = "pipeline"
 
fun newInstance(project: Project, pipeline: Pipeline): PipelineDescriptionFragment {
val fragment = PipelineDescriptionFragment()
val args = Bundle()
args.putParcelable(KEY_PROJECT, Parcels.wrap(project))
args.putParcelable(KEY_PIPELINE, Parcels.wrap(pipeline))
args.putParcelParcelableExtra(KEY_PROJECT, project)
args.putParcelParcelableExtra(KEY_PIPELINE, pipeline)
fragment.arguments = args
return fragment
}
Loading
Loading
@@ -59,8 +60,8 @@ class PipelineDescriptionFragment : ButterKnifeFragment() {
 
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
project = Parcels.unwrap<Project>(arguments.getParcelable<Parcelable>(KEY_PROJECT))
pipeline = Parcels.unwrap<Pipeline>(arguments.getParcelable<Parcelable>(KEY_PIPELINE))
project = arguments.getParcelerParcelable<Project>(KEY_PROJECT)!!
pipeline = arguments.getParcelerParcelable<Pipeline>(KEY_PIPELINE)!!
}
 
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
Loading
Loading
@@ -109,13 +110,17 @@ class PipelineDescriptionFragment : ButterKnifeFragment() {
if (startedTime == null) {
startedTime = Date()
}
var createdTime: Date? = pipeline.createdAt
if (createdTime == null) {
createdTime = Date()
}
val status = String.format(getString(R.string.pipeline_status), pipeline.status)
textStatus.text = status
 
val name = String.format(getString(R.string.pipeline_name), pipeline.id)
textName.text = name
 
val created = String.format(getString(R.string.build_created), DateUtil.getRelativeTimeSpanString(activity, pipeline.createdAt))
val created = String.format(getString(R.string.pipeline_created), DateUtil.getRelativeTimeSpanString(activity, createdTime))
textCreated.text = created
 
val finished = String.format(getString(R.string.pipeline_finished), pipeline.finishedAt)
Loading
Loading
Loading
Loading
@@ -107,7 +107,7 @@ class ApiTests {
fun getCommits() {
val defaultBranch = "master"
val commitsResponse = gitLab!!
.getCommits(fakeProject!!.id, defaultBranch, 0)
.getCommits(fakeProject!!.id, defaultBranch, 1)
.blockingGet()
assertNotNull(commitsResponse)
}
Loading
Loading
Loading
Loading
@@ -8,7 +8,7 @@ buildscript {
maven { url "https://jitpack.io" }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'com.android.tools.build:gradle:2.3.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
//check with ./gradlew dependencyUpdates
classpath 'com.github.ben-manes:gradle-versions-plugin:0.15.0'
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