diff --git a/src/main/java/com/messners/gitlab/api/GitLabApi.java b/src/main/java/com/messners/gitlab/api/GitLabApi.java index cefdd9ecd72871dd224dc15ad4e9628f3513c096..ffe55e04f9e6377d264175c4962b095e72e40252 100644 --- a/src/main/java/com/messners/gitlab/api/GitLabApi.java +++ b/src/main/java/com/messners/gitlab/api/GitLabApi.java @@ -117,8 +117,19 @@ public class GitLabApi { public RepositoryApi getRepositoryApi () { return (repositoryApi); } - - + + + /** + * Gets the RepositoryFileApi instance owned by this GitLabApi instance. The RepositoryFileApi is used + * to perform all repository files related API calls. + * + * @return the RepositoryFileApi instance owned by this GitLabApi instance + */ + public RepositoryFileApi getRepositoryFileApi() { + return repositoryFileApi; + } + + /** * Gets the SessionApi instance owned by this GitLabApi instance. The SessionApi is used * to perform a login to the GitLab API. @@ -139,26 +150,4 @@ public class GitLabApi { public UserApi getUserApi () { return (userApi); } - - - /** - * Gets the RepositoryFileApi instance owned by this GitLabApi instance. The RepositoryFileApi is used - * to perform all repository files related API calls. - * - * @return the RepositoryFileApi instance owned by this GitLabApi instance - */ - public RepositoryFileApi getRepositoryFileApi() { - return repositoryFileApi; - } - - /** - * Gets the RepositoryFileApi instance owned by this GitLabApi instance. The RepositoryFileApi is used - * to perform all repository files related API calls. - * - * @return the RepositoryFileApi instance owned by this GitLabApi instance - */ - public void setRepositoryFileApi(RepositoryFileApi repositoryFileApi) { - this.repositoryFileApi = repositoryFileApi; - } - } diff --git a/src/main/java/com/messners/gitlab/api/ProjectApi.java b/src/main/java/com/messners/gitlab/api/ProjectApi.java index df919e3b0206c221d91f3fad5e084cb7d74006bb..249b65afd419343ec8f2ee651b65d5d99f1b6c90 100644 --- a/src/main/java/com/messners/gitlab/api/ProjectApi.java +++ b/src/main/java/com/messners/gitlab/api/ProjectApi.java @@ -131,6 +131,7 @@ public class ProjectApi extends AbstractApi { return (createProject(project, null)); } + /** * Creates new project owned by the current user. The following properties on the Project instance * are utilized in the creation of the project: @@ -181,6 +182,7 @@ public class ProjectApi extends AbstractApi { return (response.readEntity(Project.class)); } + /** * Creates a Project * @@ -199,16 +201,16 @@ public class ProjectApi extends AbstractApi { * @throws GitLabApiException */ public Project createProject(String name, Integer namespaceId, String description, Boolean issuesEnabled, Boolean wallEnabled, Boolean mergeRequestsEnabled, Boolean wikiEnabled, Boolean snippetsEnabled, Boolean publik, Integer visibilityLevel, String importUrl) throws GitLabApiException{ - + if (name == null || name.trim().length() == 0) { return (null); } - + Form formData = new Form(); addFormParam(formData, "name", name, true); addFormParam(formData, "namespace_id", namespaceId); addFormParam(formData, "description", description); - addFormParam(formData, "issues_enabled", issuesEnabled); + addFormParam(formData, "issues_enabled", issuesEnabled); addFormParam(formData, "wall_enabled", wallEnabled); addFormParam(formData, "merge_requests_enabled", mergeRequestsEnabled); addFormParam(formData, "wiki_enabled", wikiEnabled); @@ -216,11 +218,12 @@ public class ProjectApi extends AbstractApi { addFormParam(formData, "public", publik); addFormParam(formData, "visibility_level", visibilityLevel); addFormParam(formData, "import_url", importUrl); - + Response response = post(Response.Status.CREATED, formData, "projects"); return (response.readEntity(Project.class)); } - + + /** * Removes project with all resources(issues, merge requests etc). * diff --git a/src/main/java/com/messners/gitlab/api/RepositoryApi.java b/src/main/java/com/messners/gitlab/api/RepositoryApi.java index b0cd4de07aafacb1d31c5574c90b29ffaba8a443..66f593c437c5f01f6659bd02c1542252b1c92037 100644 --- a/src/main/java/com/messners/gitlab/api/RepositoryApi.java +++ b/src/main/java/com/messners/gitlab/api/RepositoryApi.java @@ -135,26 +135,26 @@ public class RepositoryApi extends AbstractApi { Response response = put(Response.Status.OK, null, "projects", projectId, "repository", "tree"); return (response.readEntity(new GenericType>() {})); } - - + + /** * Get the raw file contents for a file by commit sha and path. - * + * * GET /projects/:id/repository/blobs/:sha - * + * * @param projectId * @param commitOrBranchName * @return a string with the file content for the specified file * @throws GitLabApiException */ - public String getRawFileContent (Integer projectId, String commitOrBranchName, String filepath) throws GitLabApiException { - + public String getRawFileContent (Integer projectId, String commitOrBranchName, String filepath) throws GitLabApiException { Form formData = new Form(); addFormParam(formData, "filepath", filepath, true); Response response = get(Response.Status.OK, formData.asMap(), "projects", projectId, "repository", "blobs", commitOrBranchName); return (response.readEntity(String.class)); } - + + /** * Get the raw file contents for a blob by blob SHA. * @@ -169,5 +169,4 @@ public class RepositoryApi extends AbstractApi { Response response = get(Response.Status.OK, null, "projects", projectId, "repository", "raw_blobs", sha); return (response.readEntity(String.class)); } - } diff --git a/src/main/java/com/messners/gitlab/api/RepositoryFileApi.java b/src/main/java/com/messners/gitlab/api/RepositoryFileApi.java index 8ca731c353a9a121e480ce6097a6f228397a1fe7..ac261aaae7436f1aed6afc63f835fcb1c489d52d 100644 --- a/src/main/java/com/messners/gitlab/api/RepositoryFileApi.java +++ b/src/main/java/com/messners/gitlab/api/RepositoryFileApi.java @@ -8,7 +8,7 @@ import com.messners.gitlab.api.models.RepositoryFile; /** * This class provides an entry point to all the GitLab API repository files calls. - * + * * @author lonfee88 */ public class RepositoryFileApi extends AbstractApi { @@ -16,14 +16,14 @@ public class RepositoryFileApi extends AbstractApi { public RepositoryFileApi (GitLabApi gitLabApi) { super(gitLabApi); } - + /** * Get file from repository * Allows you to receive information about file in repository like name, size, content. - * Note that file content is Base64 encoded. - * + * Note that file content is Base64 encoded. + * * GET /projects/:id/repository/files - * + * * @param file_path (required) - Full path to new file. Ex. lib/class.rb * @param projectId * @param ref (required) - The name of branch, tag or commit @@ -37,18 +37,18 @@ public class RepositoryFileApi extends AbstractApi { Response response = get(Response.Status.OK, form.asMap(),"projects", projectId, "repository", "files"); return (response.readEntity(RepositoryFile.class)); } - + /** * Create new file in repository - * + * * POST /projects/:id/repository/files - * + * * file_path (required) - Full path to new file. Ex. lib/class.rb * branch_name (required) - The name of branch * encoding (optional) - 'text' or 'base64'. Text is default. * content (required) - File content * commit_message (required) - Commit message - * + * * @param file * @param projectId * @param branchName @@ -61,18 +61,18 @@ public class RepositoryFileApi extends AbstractApi { Response response = post(Response.Status.CREATED, formData, "projects", projectId, "repository", "files"); return (response.readEntity(RepositoryFile.class)); } - + /** * Update existing file in repository - * + * * PUT /projects/:id/repository/files - * + * * file_path (required) - Full path to new file. Ex. lib/class.rb * branch_name (required) - The name of branch * encoding (optional) - 'text' or 'base64'. Text is default. * content (required) - File content * commit_message (required) - Commit message - * + * * @param file * @param projectId * @param branchName @@ -85,16 +85,16 @@ public class RepositoryFileApi extends AbstractApi { Response response = put(Response.Status.OK, form.asMap(), "projects", projectId, "repository", "files"); return (response.readEntity(RepositoryFile.class)); } - + /** * Delete existing file in repository - * + * * DELETE /projects/:id/repository/files * * file_path (required) - Full path to file. Ex. lib/class.rb * branch_name (required) - The name of branch * commit_message (required) - Commit message - * + * * @param filePath * @param projectId * @param branchName @@ -102,18 +102,18 @@ public class RepositoryFileApi extends AbstractApi { * @throws GitLabApiException */ public void deleteFile (String filePath, Integer projectId, String branchName, String commitMessage) throws GitLabApiException { - + if (filePath == null) { throw new RuntimeException("filePath cannot be null"); } - + Form form = new Form(); addFormParam(form, "file_path", filePath, true); addFormParam(form, "branch_name", branchName, true); addFormParam(form, "commit_message", commitMessage, true); delete(Response.Status.OK, form.asMap(), "projects", projectId, "repository", "files"); } - + private Form file2form(RepositoryFile file, String branchName, String commitMessage){ Form form = new Form(); addFormParam(form, "file_path", file.getFilePath(), true); @@ -123,5 +123,4 @@ public class RepositoryFileApi extends AbstractApi { addFormParam(form, "commit_message", commitMessage, true); return form; } - } diff --git a/src/main/java/com/messners/gitlab/api/UserApi.java b/src/main/java/com/messners/gitlab/api/UserApi.java index 3dc959d29205a3119bc396c7f6f4bb3fb9ae48c2..d2badefcc2a71831dd7612dfd6f4fb2e8474e2b9 100644 --- a/src/main/java/com/messners/gitlab/api/UserApi.java +++ b/src/main/java/com/messners/gitlab/api/UserApi.java @@ -62,13 +62,11 @@ public class UserApi extends AbstractApi { Response response = get(Response.Status.OK, null, "users", userId); return (response.readEntity(User.class)); } - - // Search users by Email or username - // GET /users?search=:email_or_username - + + /** * Search users by Email or username - * + * * GET /users?search=:email_or_username * * @param emailOrUsername @@ -81,12 +79,13 @@ public class UserApi extends AbstractApi { Response response = get(Response.Status.OK, formData.asMap(), "users"); return (response.readEntity(new GenericType>() {})); } - + + /** * Creates a new user. Note only administrators can create new users. - * + * * POST /users - * + * * email (required) - Email * password (required) - Password * username (required) - Username diff --git a/src/main/java/com/messners/gitlab/api/models/RepositoryFile.java b/src/main/java/com/messners/gitlab/api/models/RepositoryFile.java index dbc45f0d81a66c25b6b009880ea22a01f144ffb1..526eee8f86e70c0dc7d4a164fdfdb4805aec5623 100644 --- a/src/main/java/com/messners/gitlab/api/models/RepositoryFile.java +++ b/src/main/java/com/messners/gitlab/api/models/RepositoryFile.java @@ -9,7 +9,7 @@ import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class RepositoryFile { - + private String fileName; //file name only, Ex. lib/class.rb private String filePath; //full path to file. Ex. lib/class.rb private Integer size; @@ -18,68 +18,68 @@ public class RepositoryFile { private String ref; private String blobId; private String commitId; - - public String getFileName() { - return fileName; - } - - public void setFileName(String fileName) { - this.fileName = fileName; - } - - public String getFilePath() { - return filePath; - } - - public void setFilePath(String filePath) { - this.filePath = filePath; - } - - public Integer getSize() { - return size; - } - - public void setSize(Integer size) { - this.size = size; - } - - public String getEncoding() { - return encoding; - } - - public void setEncoding(String encoding) { - this.encoding = encoding; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getRef() { - return ref; - } - - public void setRef(String ref) { - this.ref = ref; - } - - public String getBlobId() { - return blobId; - } - - public void setBlobId(String blobId) { - this.blobId = blobId; - } - - public String getCommitId() { - return commitId; - } - - public void setCommitId(String commitId) { - this.commitId = commitId; - } + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public String getFilePath() { + return filePath; + } + + public void setFilePath(String filePath) { + this.filePath = filePath; + } + + public Integer getSize() { + return size; + } + + public void setSize(Integer size) { + this.size = size; + } + + public String getEncoding() { + return encoding; + } + + public void setEncoding(String encoding) { + this.encoding = encoding; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getRef() { + return ref; + } + + public void setRef(String ref) { + this.ref = ref; + } + + public String getBlobId() { + return blobId; + } + + public void setBlobId(String blobId) { + this.blobId = blobId; + } + + public String getCommitId() { + return commitId; + } + + public void setCommitId(String commitId) { + this.commitId = commitId; + } }