From b36eea5606dfcb7f9079ef234b22ca81e73f21fd Mon Sep 17 00:00:00 2001 From: Jony Jas J Date: Fri, 15 Aug 2025 14:58:42 +0530 Subject: [PATCH] feat: Add Pull mirror API (#1227) --- .../java/org/gitlab4j/api/ProjectApi.java | 36 +++++ .../org/gitlab4j/api/models/PullMirror.java | 124 ++++++++++++++++++ 2 files changed, 160 insertions(+) create mode 100644 gitlab4j-models/src/main/java/org/gitlab4j/api/models/PullMirror.java diff --git a/gitlab4j-api/src/main/java/org/gitlab4j/api/ProjectApi.java b/gitlab4j-api/src/main/java/org/gitlab4j/api/ProjectApi.java index c431dec5..1f89f34f 100644 --- a/gitlab4j-api/src/main/java/org/gitlab4j/api/ProjectApi.java +++ b/gitlab4j-api/src/main/java/org/gitlab4j/api/ProjectApi.java @@ -64,6 +64,7 @@ import org.gitlab4j.api.models.ProjectGroupsFilter; import org.gitlab4j.api.models.ProjectHook; import org.gitlab4j.api.models.ProjectUser; +import org.gitlab4j.api.models.PullMirror; import org.gitlab4j.api.models.PushRules; import org.gitlab4j.api.models.RemoteMirror; import org.gitlab4j.api.models.Snippet; @@ -4428,6 +4429,41 @@ public void deleteCustomAttribute(final Object projectIdOrPath, final String key delete(Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath), "custom_attributes", key); } + /** + * Get all pull mirrors for the specified project. + * + *
GitLab Endpoint: GET /projects/:id/mirror/pull
+ * + * @param projectIdOrPath the project in the form of a Long(ID), String(path), or Project instance + * @return a list of project's pull mirrors + * @throws GitLabApiException if any exception occurs + */ + public List getPullMirrors(final Object projectIdOrPath) throws GitLabApiException { + return (getPullMirrors(projectIdOrPath, getDefaultPerPage()).all()); + } + + /** + * Get a Pager of pull mirrors for the specified project. + * + *
GitLab Endpoint: GET /projects/:id/mirror/pull
+ * + * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance + * @param itemsPerPage the number of items per page + * @return a Pager of project's pull mirrors + * @throws GitLabApiException if any exception occurs + */ + public Pager getPullMirrors(final Object projectIdOrPath, int itemsPerPage) throws GitLabApiException { + return new Pager( + this, + PullMirror.class, + itemsPerPage, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "mirror", + "pull"); + } + /** * Get all remote mirrors and their statuses for the specified project. * diff --git a/gitlab4j-models/src/main/java/org/gitlab4j/api/models/PullMirror.java b/gitlab4j-models/src/main/java/org/gitlab4j/api/models/PullMirror.java new file mode 100644 index 00000000..5e84aa1b --- /dev/null +++ b/gitlab4j-models/src/main/java/org/gitlab4j/api/models/PullMirror.java @@ -0,0 +1,124 @@ +package org.gitlab4j.api.models; + +import java.io.Serializable; +import java.util.Date; + +import org.gitlab4j.models.utils.JacksonJson; + +public class PullMirror implements Serializable { + private static final long serialVersionUID = 1L; + + private Long id; + private String lastError; + private Date lastSuccessfulUpdateAt; + private Date lastUpdateAt; + private Date lastUpdateStartedAt; + private String updatedStatus; + private String url; + private Boolean enabled; + private Boolean mirrorTriggerBuilds; + private Boolean onlyMirrorProtectedBranches; + private Boolean mirrorOverwritesDivergedBranches; + private String mirrorBranchRegex; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getLastError() { + return lastError; + } + + public void setLastError(String lastError) { + this.lastError = lastError; + } + + public Date getLastSuccessfulUpdateAt() { + return lastSuccessfulUpdateAt; + } + + public void setLastSuccessfulUpdateAt(Date lastSuccessfulUpdateAt) { + this.lastSuccessfulUpdateAt = lastSuccessfulUpdateAt; + } + + public Date getLastUpdateAt() { + return lastUpdateAt; + } + + public void setLastUpdateAt(Date lastUpdateAt) { + this.lastUpdateAt = lastUpdateAt; + } + + public Date getLastUpdateStartedAt() { + return lastUpdateStartedAt; + } + + public void setLastUpdateStartedAt(Date lastUpdateStartedAt) { + this.lastUpdateStartedAt = lastUpdateStartedAt; + } + + public String getUpdatedStatus() { + return updatedStatus; + } + + public void setUpdatedStatus(String updatedStatus) { + this.updatedStatus = updatedStatus; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public Boolean getEnabled() { + return enabled; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + public Boolean getMirrorTriggerBuilds() { + return mirrorTriggerBuilds; + } + + public void setMirrorTriggerBuilds(Boolean mirrorTriggerBuilds) { + this.mirrorTriggerBuilds = mirrorTriggerBuilds; + } + + public Boolean getOnlyMirrorProtectedBranches() { + return onlyMirrorProtectedBranches; + } + + public void setOnlyMirrorProtectedBranches(Boolean onlyMirrorProtectedBranches) { + this.onlyMirrorProtectedBranches = onlyMirrorProtectedBranches; + } + + public Boolean getMirrorOverwritesDivergedBranches() { + return mirrorOverwritesDivergedBranches; + } + + public void setMirrorOverwritesDivergedBranches(Boolean mirrorOverwritesDivergedBranches) { + this.mirrorOverwritesDivergedBranches = mirrorOverwritesDivergedBranches; + } + + public String getMirrorBranchRegex() { + return mirrorBranchRegex; + } + + public void setMirrorBranchRegex(String mirrorBranchRegex) { + this.mirrorBranchRegex = mirrorBranchRegex; + } + + @Override + public String toString() { + return JacksonJson.toJsonString(this); + } +}