Skip to content

Commit b36eea5

Browse files
committed
feat: Add Pull mirror API (#1227)
1 parent d5bce14 commit b36eea5

File tree

2 files changed

+160
-0
lines changed

2 files changed

+160
-0
lines changed

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
import org.gitlab4j.api.models.ProjectGroupsFilter;
6565
import org.gitlab4j.api.models.ProjectHook;
6666
import org.gitlab4j.api.models.ProjectUser;
67+
import org.gitlab4j.api.models.PullMirror;
6768
import org.gitlab4j.api.models.PushRules;
6869
import org.gitlab4j.api.models.RemoteMirror;
6970
import org.gitlab4j.api.models.Snippet;
@@ -4428,6 +4429,41 @@ public void deleteCustomAttribute(final Object projectIdOrPath, final String key
44284429
delete(Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath), "custom_attributes", key);
44294430
}
44304431

4432+
/**
4433+
* Get all pull mirrors for the specified project.
4434+
*
4435+
* <pre><code>GitLab Endpoint: GET /projects/:id/mirror/pull</code></pre>
4436+
*
4437+
* @param projectIdOrPath the project in the form of a Long(ID), String(path), or Project instance
4438+
* @return a list of project's pull mirrors
4439+
* @throws GitLabApiException if any exception occurs
4440+
*/
4441+
public List<PullMirror> getPullMirrors(final Object projectIdOrPath) throws GitLabApiException {
4442+
return (getPullMirrors(projectIdOrPath, getDefaultPerPage()).all());
4443+
}
4444+
4445+
/**
4446+
* Get a Pager of pull mirrors for the specified project.
4447+
*
4448+
* <pre><code>GitLab Endpoint: GET /projects/:id/mirror/pull</code></pre>
4449+
*
4450+
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
4451+
* @param itemsPerPage the number of items per page
4452+
* @return a Pager of project's pull mirrors
4453+
* @throws GitLabApiException if any exception occurs
4454+
*/
4455+
public Pager<PullMirror> getPullMirrors(final Object projectIdOrPath, int itemsPerPage) throws GitLabApiException {
4456+
return new Pager<PullMirror>(
4457+
this,
4458+
PullMirror.class,
4459+
itemsPerPage,
4460+
null,
4461+
"projects",
4462+
getProjectIdOrPath(projectIdOrPath),
4463+
"mirror",
4464+
"pull");
4465+
}
4466+
44314467
/**
44324468
* Get all remote mirrors and their statuses for the specified project.
44334469
*
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
package org.gitlab4j.api.models;
2+
3+
import java.io.Serializable;
4+
import java.util.Date;
5+
6+
import org.gitlab4j.models.utils.JacksonJson;
7+
8+
public class PullMirror implements Serializable {
9+
private static final long serialVersionUID = 1L;
10+
11+
private Long id;
12+
private String lastError;
13+
private Date lastSuccessfulUpdateAt;
14+
private Date lastUpdateAt;
15+
private Date lastUpdateStartedAt;
16+
private String updatedStatus;
17+
private String url;
18+
private Boolean enabled;
19+
private Boolean mirrorTriggerBuilds;
20+
private Boolean onlyMirrorProtectedBranches;
21+
private Boolean mirrorOverwritesDivergedBranches;
22+
private String mirrorBranchRegex;
23+
24+
public Long getId() {
25+
return id;
26+
}
27+
28+
public void setId(Long id) {
29+
this.id = id;
30+
}
31+
32+
public String getLastError() {
33+
return lastError;
34+
}
35+
36+
public void setLastError(String lastError) {
37+
this.lastError = lastError;
38+
}
39+
40+
public Date getLastSuccessfulUpdateAt() {
41+
return lastSuccessfulUpdateAt;
42+
}
43+
44+
public void setLastSuccessfulUpdateAt(Date lastSuccessfulUpdateAt) {
45+
this.lastSuccessfulUpdateAt = lastSuccessfulUpdateAt;
46+
}
47+
48+
public Date getLastUpdateAt() {
49+
return lastUpdateAt;
50+
}
51+
52+
public void setLastUpdateAt(Date lastUpdateAt) {
53+
this.lastUpdateAt = lastUpdateAt;
54+
}
55+
56+
public Date getLastUpdateStartedAt() {
57+
return lastUpdateStartedAt;
58+
}
59+
60+
public void setLastUpdateStartedAt(Date lastUpdateStartedAt) {
61+
this.lastUpdateStartedAt = lastUpdateStartedAt;
62+
}
63+
64+
public String getUpdatedStatus() {
65+
return updatedStatus;
66+
}
67+
68+
public void setUpdatedStatus(String updatedStatus) {
69+
this.updatedStatus = updatedStatus;
70+
}
71+
72+
public String getUrl() {
73+
return url;
74+
}
75+
76+
public void setUrl(String url) {
77+
this.url = url;
78+
}
79+
80+
public Boolean getEnabled() {
81+
return enabled;
82+
}
83+
84+
public void setEnabled(Boolean enabled) {
85+
this.enabled = enabled;
86+
}
87+
88+
public Boolean getMirrorTriggerBuilds() {
89+
return mirrorTriggerBuilds;
90+
}
91+
92+
public void setMirrorTriggerBuilds(Boolean mirrorTriggerBuilds) {
93+
this.mirrorTriggerBuilds = mirrorTriggerBuilds;
94+
}
95+
96+
public Boolean getOnlyMirrorProtectedBranches() {
97+
return onlyMirrorProtectedBranches;
98+
}
99+
100+
public void setOnlyMirrorProtectedBranches(Boolean onlyMirrorProtectedBranches) {
101+
this.onlyMirrorProtectedBranches = onlyMirrorProtectedBranches;
102+
}
103+
104+
public Boolean getMirrorOverwritesDivergedBranches() {
105+
return mirrorOverwritesDivergedBranches;
106+
}
107+
108+
public void setMirrorOverwritesDivergedBranches(Boolean mirrorOverwritesDivergedBranches) {
109+
this.mirrorOverwritesDivergedBranches = mirrorOverwritesDivergedBranches;
110+
}
111+
112+
public String getMirrorBranchRegex() {
113+
return mirrorBranchRegex;
114+
}
115+
116+
public void setMirrorBranchRegex(String mirrorBranchRegex) {
117+
this.mirrorBranchRegex = mirrorBranchRegex;
118+
}
119+
120+
@Override
121+
public String toString() {
122+
return JacksonJson.toJsonString(this);
123+
}
124+
}

0 commit comments

Comments
 (0)