Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.messners.gitlab.api;
  
  import java.util.List;
  
 import  com.sun.jersey.api.representation.Form;


This class provides an entry point to all the GitLab API repository calls.

Author(s):
Greg Messner <greg@messners.com>
 
 public class RepositoryApi extends AbstractApi {
 
 	public RepositoryApi (GitLabApi gitLabApi) {
 		super(gitLabApi);
 	}


Get a list of repository branches from a project, sorted by name alphabetically. GET /projects/:id/repository/branches

Parameters:
projectId
Returns:
the list of repository branches for mthe specified project ID
Throws:
GitLabApiException
 
 	public List<BranchgetBranches (Integer projectIdthrows GitLabApiException {		
 		ClientResponse response = get(..null"projects"projectId"repository""branches");
 		return (response.getEntity(new GenericType<List<Branch>>() {}));
 	}


Get a single project repository branch. GET /projects/:id/repository/branches/:branch

Parameters:
projectId
branchName
Returns:
the branch info for the specified project ID/branch name pair
Throws:
GitLabApiException
 
 	public Branch getBranch (Integer projectIdString branchNamethrows GitLabApiException {		
 		ClientResponse response = get(..null"projects"projectId"repository""branches"branchName);
 		return (response.getEntity(Branch.class));
 	}


Protects a single project repository branch. This is an idempotent function, protecting an already protected repository branch will not produce an error. PUT /projects/:id/repository/branches/:branch/protect

Parameters:
projectId
branchName
Returns:
the branch info for the protected branch
Throws:
GitLabApiException
 
 	public Branch protectBranch (Integer projectIdString branchNamethrows GitLabApiException {		
 		ClientResponse response = put(..null"projects"projectId"repository""branches"branchName"protect");
 		return (response.getEntity(Branch.class));
 	}


Unprotects a single project repository branch. This is an idempotent function, unprotecting an already unprotected repository branch will not produce an error. PUT /projects/:id/repository/branches/:branch/unprotect

Parameters:
projectId
branchName
Returns:
the branch info for the unprotected branch
Throws:
GitLabApiException
 
 	public Branch unprotectBranch (Integer projectIdString branchNamethrows GitLabApiException {		
 		ClientResponse response = put(..null"projects"projectId"repository""branches"branchName"unprotect");
 		return (response.getEntity(Branch.class));
 	}


Get a list of repository tags from a project, sorted by name in reverse alphabetical order. GET /projects/:id/repository/tags

Parameters:
projectId
Returns:
the list of tags for the specified project ID
Throws:
GitLabApiException
 
 	public List<TaggetTags (Integer projectIdthrows GitLabApiException {		
		ClientResponse response = put(..null"projects"projectId"repository""tags");
		 return (response.getEntity(new GenericType<List<Tag>>() {}));
	}


Get a list of repository files and directories in a project. GET /projects/:id/repository/tree

Parameters:
projectId
Returns:
a tree with the diurectories and files of a project
Throws:
GitLabApiException
	public List<TreeItemgetTree (Integer projectIdthrows GitLabApiException {		
		ClientResponse response = put(..null"projects"projectId"repository""tree");
		return (response.getEntity(new GenericType<List<TreeItem>>() {}));
	}


Get the raw file contents for a file by commit sha and path. GET /projects/:id/repository/blobs/:sha

Parameters:
projectId
commitOrBranchName
Returns:
a string with the file content for the specified file
Throws:
GitLabApiException
	public String getRawFileContent (Integer projectIdString commitOrBranchNameString filepaththrows GitLabApiException {
		Form formData = new Form();
		addFormParam(formData"filepath"filepathtrue);		
		ClientResponse response = get(..formData"projects"projectId"repository""blobs"commitOrBranchName);
		return (response.getEntity(String.class));
	}
New to GrepCode? Check out our FAQ X