Commit 67b1e3b0 authored by Greg Messner's avatar Greg Messner
Browse files

Minor format changes from previous merge.

parent 6b73b770
Showing with 119 additions and 130 deletions
+119 -130
......@@ -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;
}
}
......@@ -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).
*
......
......@@ -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<List<TreeItem>>() {}));
}
/**
* 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));
}
}
......@@ -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 <lonfee88@gmail.com>
*/
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;
}
}
......@@ -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<List<User>>() {}));
}
/**
* Creates a new user. Note only administrators can create new users.
*
*
* POST /users
*
*
* email (required) - Email
* password (required) - Password
* username (required) - Username
......
......@@ -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;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment