Skip to content

Commit 1995a3f

Browse files
committed
Merge remote-tracking branch 'origin/main' into move-to-jakarta
2 parents 267ffcf + 5391d2c commit 1995a3f

16 files changed

+533
-8
lines changed

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

+20
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public String getApiNamespace() {
8383
private PipelineApi pipelineApi;
8484
private ProjectApi projectApi;
8585
private ProtectedBranchesApi protectedBranchesApi;
86+
private ReleaseLinksApi releaseLinksApi;
8687
private ReleasesApi releasesApi;
8788
private RepositoryApi repositoryApi;
8889
private RepositoryFileApi repositoryFileApi;
@@ -1444,6 +1445,25 @@ public ProtectedBranchesApi getProtectedBranchesApi() {
14441445
return (this.protectedBranchesApi);
14451446
}
14461447

1448+
/**
1449+
* Gets the ReleaseLinksApi instance owned by this GitLabApi instance. The ReleaseLinksApi is used
1450+
* to perform all Release Links related API calls.
1451+
*
1452+
* @return the ReleaseLinksApi instance owned by this GitLabApi instance
1453+
*/
1454+
public ReleaseLinksApi getReleaseLinksApi() {
1455+
1456+
if (releaseLinksApi == null) {
1457+
synchronized (this) {
1458+
if (releaseLinksApi == null) {
1459+
releaseLinksApi = new ReleaseLinksApi(this);
1460+
}
1461+
}
1462+
}
1463+
1464+
return releaseLinksApi;
1465+
}
1466+
14471467
/**
14481468
* Gets the ReleasesApi instance owned by this GitLabApi instance. The ReleasesApi is used
14491469
* to perform all release related API calls.

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ public MergeRequest acceptMergeRequest(Object projectIdOrPath, Long mergeRequest
804804
*
805805
* <p>NOTE: GitLab API V4 uses IID (internal ID), V3 uses ID to identify the merge request.</p>
806806
*
807-
* <pre><code>GitLab Endpoint: PUT /projects/:id/merge_requests/:merge_request_iid/cancel_merge_when_pipeline_succeeds</code></pre>
807+
* <pre><code>GitLab Endpoint: POST /projects/:id/merge_requests/:merge_request_iid/cancel_merge_when_pipeline_succeeds</code></pre>
808808
*
809809
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
810810
* @param mergeRequestIid the internal ID of the merge request
@@ -817,7 +817,7 @@ public MergeRequest cancelMergeRequest(Object projectIdOrPath, Long mergeRequest
817817
throw new RuntimeException("mergeRequestIid cannot be null");
818818
}
819819

820-
Response response = put(Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "cancel_merge_when_pipeline_succeeds");
820+
Response response = post(Response.Status.OK, (Form)null, "projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "cancel_merge_when_pipeline_succeeds");
821821
return (response.readEntity(MergeRequest.class));
822822
}
823823

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
package org.gitlab4j.api;
2+
3+
import org.gitlab4j.api.models.Link;
4+
import org.gitlab4j.api.models.ReleaseLinkParams;
5+
6+
import jakarta.ws.rs.core.Response;
7+
import java.util.List;
8+
import java.util.Optional;
9+
import java.util.stream.Stream;
10+
11+
12+
/**
13+
* This class provides an entry point to all the GitLab ReleaseLinks API calls.
14+
* @see <a href="https://docs.gitlab.com/ce/api/releases/links.html">ReleaseLinks API at GitLab</a>
15+
*/
16+
public class ReleaseLinksApi extends AbstractApi {
17+
18+
public ReleaseLinksApi(GitLabApi gitLabApi) {
19+
super(gitLabApi);
20+
}
21+
22+
/**
23+
* Get assets as Links from a Release.
24+
*
25+
* <pre><code>GitLab Endpoint: GET /projects/:id/releases/:tagName/assets/links</code></pre>
26+
*
27+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
28+
* @param tagName the tag name that the release was created from
29+
* @return the list of assets for the specified release
30+
* @throws GitLabApiException if any exception occurs
31+
*/
32+
public List<Link> getLinks(Object projectIdOrPath, String tagName) throws GitLabApiException {
33+
return (getLinks(projectIdOrPath, tagName, getDefaultPerPage()).all());
34+
}
35+
36+
/**
37+
* Get assets as Links from a Release.
38+
*
39+
* <pre><code>GitLab Endpoint: GET /projects/:id/releases/:tagName/assets/links</code></pre>
40+
*
41+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
42+
* @param tagName the tag name that the release was created from
43+
* @param itemsPerPage the number of Link instances that will be fetched per page
44+
* @return the Pager of Link instances for the specified project ID
45+
* @throws GitLabApiException if any exception occurs
46+
*/
47+
public Pager<Link> getLinks(Object projectIdOrPath, String tagName, int itemsPerPage) throws GitLabApiException {
48+
return (new Pager<Link>(this, Link.class, itemsPerPage, null, "projects", getProjectIdOrPath(projectIdOrPath), "releases", urlEncode(tagName), "assets", "links"));
49+
}
50+
51+
/**
52+
* Get a Stream of assets as Links from a Release.
53+
*
54+
* <pre><code>GitLab Endpoint: GET /projects/:id/releases/:tagName/assets/links</code></pre>
55+
*
56+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
57+
* @param tagName the tag name that the release was created from
58+
* @return a Stream of Link instances for the specified project ID
59+
* @throws GitLabApiException if any exception occurs
60+
*/
61+
public Stream<Link> getLinksStream(Object projectIdOrPath, String tagName) throws GitLabApiException {
62+
return (getLinks(projectIdOrPath, tagName, getDefaultPerPage()).stream());
63+
}
64+
65+
/**
66+
* Get a Link for the given tag name and link id.
67+
*
68+
* <pre><code>GitLab Endpoint: GET /projects/:id/releases/:tagName/assets/links/:linkId</code></pre>
69+
*
70+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
71+
* @param tagName the name of the tag to fetch the Link for
72+
* @param linkId the id of the Link to fetch for
73+
* @return a Link instance with info on the specified tag and id
74+
* @throws GitLabApiException if any exception occurs
75+
*/
76+
public Link getLink(Object projectIdOrPath, String tagName, Integer linkId) throws GitLabApiException {
77+
Response response = get(Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath), "releases", urlEncode(tagName), "assets", "links", linkId);
78+
return (response.readEntity(Link.class));
79+
}
80+
81+
/**
82+
* Get an Optional instance holding a Link instance for the specific tag name and link id.
83+
*
84+
* <pre><code>GitLab Endpoint: GET /projects/:id/releases/:tagName/assets/links/:linkId</code></pre>
85+
*
86+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
87+
* @param tagName the name of the tag to fetch the Link for
88+
* @param linkId the id of the Link to fetch for
89+
* @return an Optional instance with the specified Link as the value
90+
* @throws GitLabApiException if any exception occurs
91+
*/
92+
public Optional<Link> getOptionalLink(Object projectIdOrPath, String tagName, Integer linkId) throws GitLabApiException {
93+
try {
94+
return (Optional.ofNullable(getLink(projectIdOrPath, tagName, linkId)));
95+
} catch (GitLabApiException glae) {
96+
return (GitLabApi.createOptionalFromException(glae));
97+
}
98+
}
99+
100+
/**
101+
* Create a Link. You need push access to the repository to create a Link.
102+
*
103+
* <pre><code>GitLab Endpoint: POST /projects/:id/releases/:tagName/assets/links</code></pre>
104+
*
105+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
106+
* @param params a ReleaseLinksParams instance holding the parameters for the link
107+
* @return a Link instance containing the newly created Link info
108+
* @throws GitLabApiException if any exception occurs
109+
*/
110+
public Link createLink(Object projectIdOrPath, ReleaseLinkParams params) throws GitLabApiException {
111+
String tagName = params.getTagName();
112+
if (tagName == null || tagName.trim().isEmpty()) {
113+
throw new RuntimeException("params.tagName cannot be null or empty");
114+
}
115+
116+
String name = params.getName();
117+
if (name == null || name.trim().isEmpty()) {
118+
throw new RuntimeException("params.name cannot be null or empty");
119+
}
120+
121+
String url = params.getUrl();
122+
if (url == null || url.trim().isEmpty()) {
123+
throw new RuntimeException("params.url cannot be null or empty");
124+
}
125+
126+
Response response = post(Response.Status.CREATED, params,
127+
"projects", getProjectIdOrPath(projectIdOrPath), "releases", urlEncode(tagName), "assets", "links");
128+
return (response.readEntity(Link.class));
129+
}
130+
131+
/**
132+
* Updates the attributes of a given Link.
133+
*
134+
* <pre><code>GitLab Endpoint: PUT /projects/:id/releases/:tagName/assets/links/:linkId</code></pre>
135+
*
136+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
137+
* @param linkId the id of the Link to fetch for
138+
* @param params a ReleaseLinksParams instance holding the parameters for the Link
139+
* @return a Link instance containing info on the updated Link
140+
* @throws GitLabApiException if any exception occurs
141+
*/
142+
public Link updateLink(Object projectIdOrPath, Integer linkId, ReleaseLinkParams params) throws GitLabApiException {
143+
String tagName = params.getTagName();
144+
if (tagName == null || tagName.trim().isEmpty()) {
145+
throw new RuntimeException("params.tagName cannot be null or empty");
146+
}
147+
148+
if (linkId == null) {
149+
throw new RuntimeException("linkId cannot be null");
150+
}
151+
152+
Response response = put(Response.Status.OK, params,
153+
"projects", getProjectIdOrPath(projectIdOrPath), "releases", urlEncode(tagName), "assets", "links", linkId);
154+
return (response.readEntity(Link.class));
155+
}
156+
157+
/**
158+
* Delete a Link.
159+
*
160+
* <pre><code>GitLab Endpoint: DELETE /projects/:id/releases/:tagName/assets/links/:linkId</code></pre>
161+
*
162+
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
163+
* @param tagName the tag name that the link was created from
164+
* @param linkId the id of the Link to delete
165+
* @throws GitLabApiException if any exception occurs
166+
*/
167+
public void deleteLink(Object projectIdOrPath, String tagName, Integer linkId) throws GitLabApiException {
168+
delete(Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath), "releases", urlEncode(tagName), "assets", "links", linkId);
169+
}
170+
}

src/main/java/org/gitlab4j/api/models/Job.java

+16-4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public class Job {
2929
private Boolean manual;
3030
private Boolean allowFailure;
3131
private Float duration;
32+
private Float queuedDuration;
3233
private Project project;
3334

3435
public Long getId() {
@@ -206,11 +207,18 @@ public Float getDuration() {
206207
public void setDuration(Float duration) {
207208
this.duration = duration;
208209
}
209-
210+
211+
public Float getQueuedDuration() {
212+
return queuedDuration;
213+
}
214+
215+
public void setQueuedDuration(Float queuedDuration) {
216+
this.queuedDuration = queuedDuration;
217+
}
218+
210219
public Project getProject() {
211220
return project;
212221
}
213-
214222
public void setProject(Project project) {
215223
this.project = project;
216224
}
@@ -304,12 +312,16 @@ public Job withAllowFailure(Boolean allowFailure) {
304312
this.allowFailure = allowFailure;
305313
return this;
306314
}
307-
308315
public Job withDuration(Float duration) {
309316
this.duration = duration;
310317
return this;
311318
}
312-
319+
320+
public Job withQueuedDuration(Float queuedDuration) {
321+
this.queuedDuration = queuedDuration;
322+
return this;
323+
}
324+
313325
public Job withProject(Project project) {
314326
this.project = project;
315327
return this;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package org.gitlab4j.api.models;
2+
3+
import org.gitlab4j.api.utils.JacksonJson;
4+
5+
import java.util.Date;
6+
import java.util.List;
7+
8+
public class Link {
9+
10+
private Integer id;
11+
private String name;
12+
private String url;
13+
/**
14+
* @deprecated deprecated in GitLab 15.9, will be removed in GitLab 16.0.
15+
*/
16+
@Deprecated
17+
private Boolean external;
18+
private String linkType;
19+
20+
public Integer getId() {
21+
return id;
22+
}
23+
24+
public void setId(Integer id) {
25+
this.id = id;
26+
}
27+
28+
public String getName() {
29+
return name;
30+
}
31+
32+
public void setName(String name) {
33+
this.name = name;
34+
}
35+
36+
public String getUrl() {
37+
return url;
38+
}
39+
40+
public void setUrl(String url) {
41+
this.url = url;
42+
}
43+
44+
/**
45+
* @deprecated deprecated in GitLab 15.9, will be removed in GitLab 16.0.
46+
*/
47+
@Deprecated
48+
public Boolean getExternal() {
49+
return external;
50+
}
51+
52+
/**
53+
* @deprecated deprecated in GitLab 15.9, will be removed in GitLab 16.0.
54+
*/
55+
@Deprecated
56+
public void setExternal(Boolean external) {
57+
this.external = external;
58+
}
59+
60+
public String getLinkType() {
61+
return linkType;
62+
}
63+
64+
public void setLinkType(String linkType) {
65+
this.linkType = linkType;
66+
}
67+
68+
@Override
69+
public String toString() {
70+
return (JacksonJson.toJsonString(this));
71+
}
72+
}

src/main/java/org/gitlab4j/api/models/Pipeline.java

+9
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class Pipeline {
2222
private Date committedAt;
2323
private String coverage;
2424
private Integer duration;
25+
private Float queuedDuration;
2526
private String webUrl;
2627
private DetailedStatus detailedStatus;
2728

@@ -225,6 +226,14 @@ public void setDuration(Integer duration) {
225226
this.duration = duration;
226227
}
227228

229+
public Float getQueuedDuration() {
230+
return queuedDuration;
231+
}
232+
233+
public void setQueuedDuration(Float queuedDuration) {
234+
this.queuedDuration = queuedDuration;
235+
}
236+
228237
public String getWebUrl() {
229238
return webUrl;
230239
}

0 commit comments

Comments
 (0)