Skip to content

Commit 26fc152

Browse files
authored
Remove support for REST API v3 (#1245)
Fixes #1202
1 parent 6f2f878 commit 26fc152

15 files changed

+138
-341
lines changed

gitlab4j-api/src/main/java/org/gitlab4j/api/GitLabApi.java

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public class GitLabApi implements AutoCloseable {
3333

3434
/** Specifies the version of the GitLab API to communicate with. */
3535
public enum ApiVersion {
36-
V3,
3736
V4;
3837

3938
public String getApiNamespace() {

gitlab4j-api/src/main/java/org/gitlab4j/api/GroupApi.java

+6-11
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import jakarta.ws.rs.core.MultivaluedMap;
1616
import jakarta.ws.rs.core.Response;
1717

18-
import org.gitlab4j.api.GitLabApi.ApiVersion;
1918
import org.gitlab4j.api.models.AccessLevel;
2019
import org.gitlab4j.api.models.AccessRequest;
2120
import org.gitlab4j.api.models.AuditEvent;
@@ -686,7 +685,7 @@ public Group addGroup(Group group) throws GitLabApiException {
686685
.withParam("visibility", group.getVisibility())
687686
.withParam("lfs_enabled", group.getLfsEnabled())
688687
.withParam("request_access_enabled", group.getRequestAccessEnabled())
689-
.withParam("parent_id", isApiVersion(ApiVersion.V3) ? null : group.getParentId());
688+
.withParam("parent_id", group.getParentId());
690689
Response response = post(Response.Status.CREATED, formData, "groups");
691690
return (response.readEntity(Group.class));
692691
}
@@ -723,7 +722,7 @@ public Group addGroup(
723722
.withParam("visibility", visibility)
724723
.withParam("lfs_enabled", lfsEnabled)
725724
.withParam("request_access_enabled", requestAccessEnabled)
726-
.withParam("parent_id", isApiVersion(ApiVersion.V3) ? null : parentId);
725+
.withParam("parent_id", parentId);
727726
Response response = post(Response.Status.CREATED, formData, "groups");
728727
return (response.readEntity(Group.class));
729728
}
@@ -745,7 +744,7 @@ public Group updateGroup(Group group) throws GitLabApiException {
745744
.withParam("visibility", group.getVisibility())
746745
.withParam("lfs_enabled", group.getLfsEnabled())
747746
.withParam("request_access_enabled", group.getRequestAccessEnabled())
748-
.withParam("parent_id", isApiVersion(ApiVersion.V3) ? null : group.getParentId());
747+
.withParam("parent_id", group.getParentId());
749748
Response response = put(Response.Status.OK, formData.asMap(), "groups", group.getId());
750749
return (response.readEntity(Group.class));
751750
}
@@ -784,7 +783,7 @@ public Group updateGroup(
784783
.withParam("visibility", visibility)
785784
.withParam("lfs_enabled", lfsEnabled)
786785
.withParam("request_access_enabled", requestAccessEnabled)
787-
.withParam("parent_id", isApiVersion(ApiVersion.V3) ? null : parentId);
786+
.withParam("parent_id", parentId);
788787
Response response = put(Response.Status.OK, formData.asMap(), "groups", getGroupIdOrPath(groupIdOrPath));
789788
return (response.readEntity(Group.class));
790789
}
@@ -898,9 +897,7 @@ public Group updateGroup(
898897
* @throws GitLabApiException if any exception occurs
899898
*/
900899
public void deleteGroup(Object groupIdOrPath) throws GitLabApiException {
901-
Response.Status expectedStatus =
902-
(isApiVersion(ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT);
903-
delete(expectedStatus, null, "groups", getGroupIdOrPath(groupIdOrPath));
900+
delete(Response.Status.NO_CONTENT, null, "groups", getGroupIdOrPath(groupIdOrPath));
904901
}
905902

906903
/**
@@ -1329,9 +1326,7 @@ public Member updateMember(Object groupIdOrPath, Long userId, Integer accessLeve
13291326
* @throws GitLabApiException if any exception occurs
13301327
*/
13311328
public void removeMember(Object groupIdOrPath, Long userId) throws GitLabApiException {
1332-
Response.Status expectedStatus =
1333-
(isApiVersion(ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT);
1334-
delete(expectedStatus, null, "groups", getGroupIdOrPath(groupIdOrPath), "members", userId);
1329+
delete(Response.Status.NO_CONTENT, null, "groups", getGroupIdOrPath(groupIdOrPath), "members", userId);
13351330
}
13361331

13371332
/**

gitlab4j-api/src/main/java/org/gitlab4j/api/IssuesApi.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import jakarta.ws.rs.core.GenericType;
1010
import jakarta.ws.rs.core.Response;
1111

12-
import org.gitlab4j.api.GitLabApi.ApiVersion;
1312
import org.gitlab4j.api.models.Duration;
1413
import org.gitlab4j.api.models.Issue;
1514
import org.gitlab4j.api.models.IssueFilter;
@@ -707,10 +706,8 @@ public void deleteIssue(Object projectIdOrPath, Long issueIid) throws GitLabApiE
707706
throw new RuntimeException("issue IID cannot be null");
708707
}
709708

710-
Response.Status expectedStatus =
711-
(isApiVersion(ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT);
712709
delete(
713-
expectedStatus,
710+
Response.Status.NO_CONTENT,
714711
getDefaultPerPageParam(),
715712
"projects",
716713
getProjectIdOrPath(projectIdOrPath),

gitlab4j-api/src/main/java/org/gitlab4j/api/MergeRequestApi.java

+2-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import jakarta.ws.rs.core.MultivaluedMap;
1010
import jakarta.ws.rs.core.Response;
1111

12-
import org.gitlab4j.api.GitLabApi.ApiVersion;
1312
import org.gitlab4j.api.models.AcceptMergeRequestParams;
1413
import org.gitlab4j.api.models.ApprovalRule;
1514
import org.gitlab4j.api.models.ApprovalRuleParams;
@@ -885,10 +884,8 @@ public void deleteMergeRequest(Object projectIdOrPath, Long mergeRequestIid) thr
885884
throw new RuntimeException("mergeRequestIid cannot be null");
886885
}
887886

888-
Response.Status expectedStatus =
889-
(isApiVersion(ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT);
890887
delete(
891-
expectedStatus,
888+
Response.Status.NO_CONTENT,
892889
null,
893890
"projects",
894891
getProjectIdOrPath(projectIdOrPath),
@@ -1023,9 +1020,7 @@ public MergeRequest acceptMergeRequest(
10231020
Form formData = new GitLabApiForm()
10241021
.withParam("merge_commit_message", mergeCommitMessage)
10251022
.withParam("should_remove_source_branch", shouldRemoveSourceBranch)
1026-
.withParam(
1027-
(isApiVersion(ApiVersion.V3) ? "merge_when_build_succeeds" : "merge_when_pipeline_succeeds"),
1028-
mergeWhenPipelineSucceeds)
1023+
.withParam("merge_when_pipeline_succeeds", mergeWhenPipelineSucceeds)
10291024
.withParam("sha", sha);
10301025

10311026
Response response = put(

gitlab4j-api/src/main/java/org/gitlab4j/api/NotesApi.java

+2-6
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,8 @@ public void deleteIssueNote(Object projectIdOrPath, Long issueIid, Long noteId)
230230
throw new RuntimeException("noteId cannot be null");
231231
}
232232

233-
Response.Status expectedStatus =
234-
(isApiVersion(GitLabApi.ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT);
235233
delete(
236-
expectedStatus,
234+
Response.Status.NO_CONTENT,
237235
getDefaultPerPageParam(),
238236
"projects",
239237
getProjectIdOrPath(projectIdOrPath),
@@ -522,10 +520,8 @@ public void deleteMergeRequestNote(Object projectIdOrPath, Long mergeRequestIid,
522520
throw new RuntimeException("noteId cannot be null");
523521
}
524522

525-
Response.Status expectedStatus =
526-
(isApiVersion(GitLabApi.ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT);
527523
delete(
528-
expectedStatus,
524+
Response.Status.NO_CONTENT,
529525
null,
530526
"projects",
531527
getProjectIdOrPath(projectIdOrPath),

gitlab4j-api/src/main/java/org/gitlab4j/api/PersonalAccessTokenApi.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,6 @@ public void revokePersonalAccessToken(Long tokenId) throws GitLabApiException {
121121
if (tokenId == null) {
122122
throw new RuntimeException("tokenId cannot be null");
123123
}
124-
Response.Status expectedStatus =
125-
(isApiVersion(GitLabApi.ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT);
126-
delete(expectedStatus, null, "personal_access_tokens", tokenId);
124+
delete(Response.Status.NO_CONTENT, null, "personal_access_tokens", tokenId);
127125
}
128126
}

gitlab4j-api/src/main/java/org/gitlab4j/api/PipelineApi.java

+2-6
Original file line numberDiff line numberDiff line change
@@ -633,10 +633,8 @@ public PipelineSchedule createPipelineSchedule(Object projectIdOrPath, PipelineS
633633
* @throws GitLabApiException if any exception occurs
634634
*/
635635
public void deletePipelineSchedule(Object projectIdOrPath, Long pipelineScheduleId) throws GitLabApiException {
636-
Response.Status expectedStatus =
637-
(isApiVersion(GitLabApi.ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT);
638636
delete(
639-
expectedStatus,
637+
Response.Status.NO_CONTENT,
640638
null,
641639
"projects",
642640
getProjectIdOrPath(projectIdOrPath),
@@ -785,10 +783,8 @@ public Variable updatePipelineScheduleVariable(
785783
*/
786784
public void deletePipelineScheduleVariable(Object projectIdOrPath, Long pipelineScheduleId, String key)
787785
throws GitLabApiException {
788-
Response.Status expectedStatus =
789-
(isApiVersion(GitLabApi.ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT);
790786
delete(
791-
expectedStatus,
787+
Response.Status.NO_CONTENT,
792788
null,
793789
"projects",
794790
getProjectIdOrPath(projectIdOrPath),

0 commit comments

Comments
 (0)