diff --git a/src/main/java/org/gitlab/api/GitlabAPI.java b/src/main/java/org/gitlab/api/GitlabAPI.java index c0c88fa7..492cfa87 100644 --- a/src/main/java/org/gitlab/api/GitlabAPI.java +++ b/src/main/java/org/gitlab/api/GitlabAPI.java @@ -1009,6 +1009,21 @@ public List getNamespaces() { return retrieve().getAll(tailUrl, GitlabNamespace[].class); } + /** + * Get a list of the namespaces of the authenticated user based on the search criteria. + * If the user is an administrator, a list of all namespaces in the GitLab instance is shown. + * + * @param search param to search + * @return A list of gitlab namespace + * @throws IOException on gitlab api call error + */ + public List getNamespaces(String search) throws IOException { + Query query = new Query() + .appendIf("search", search); + String tailUrl = GitlabNamespace.URL + query.toString(); + return retrieve().getAll(tailUrl, GitlabNamespace[].class); + } + /** * Uploads a file to a project * @@ -4252,4 +4267,18 @@ public List getProjectEvents(Serializable projectId, return Arrays.asList(retrieve().method(GET).to(tailUrl.toString(), GitlabEvent[].class)); } + + /** + * Judge a group is exist or not + * + * @param path path of a group + */ + public boolean isGroupNotExists(String path) throws IOException { + String tailUrl = GitlabGroup.URL; + Query query = new Query() + .append("search", path); + List gitlabGroupList = retrieve().getAll(tailUrl + query.toString(), GitlabGroup[].class); + return gitlabGroupList.isEmpty(); + } + }