Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.messners.gitlab.api;
  
  import java.net.URL;
  
  import  javax.ws.rs.core.MultivaluedMap;
  
  import  com.sun.jersey.api.representation.Form;
  
 public abstract class AbstractApi {
 
 	private GitLabApi gitLabApi;
 	
 	public AbstractApi (GitLabApi gitLabApi) {
 		this. = gitLabApi;
 	}
 
 	protected GitLabApiClient getApiClient () {
 		return (.getApiClient());
 	}



Perform an HTTP GET call with the specified query parameters and path objects, returning a ClientResponse instance with the data returned from the endpoint.

Parameters:
expectedStatus the HTTP status that should be returned from the server
queryParams
pathArgs
Returns:
a ClientResponse instance with the data returned from the endpoint
Throws:
GitLabApiException
 
 	protected  ClientResponse get (ClientResponse.Status expectedStatus, MultivaluedMap<StringStringqueryParamsObject ... pathArgs
 			throws GitLabApiException {	
 		
 		ClientResponse response = null;
 		try {			
 			response = getApiClient().get(queryParamspathArgs);			
 		} catch (Exception e) {
 			throw (new GitLabApiException(e));
 		}
 		
 		if (response.getStatus() != expectedStatus.getStatusCode()) {
 			throw (new GitLabApiException(response));			
 		}
 		
 		return (response);
 	}	


Perform an HTTP GET call with the specified query parameters and URL, returning a ClientResponse instance with the data returned from the endpoint.

Parameters:
expectedStatus the HTTP status that should be returned from the server
queryParams
url
Returns:
a ClientResponse instance with the data returned from the endpoint
Throws:
GitLabApiException
 
 	protected ClientResponse get (ClientResponse.Status expectedStatus, MultivaluedMap<StringStringqueryParamsURL url
 			throws GitLabApiException {		
 		
 		ClientResponse response = null;
 		try {			
 			response = getApiClient().get(queryParamsurl);			
 		} catch (Exception e) {
 			throw (new GitLabApiException(e));
 		}	
 		
 		if (response.getStatus() != expectedStatus.getStatusCode()) {
 			throw (new GitLabApiException(response));			
 		}
 		
 		return (response);
 	}		


Perform an HTTP POST call with the specified form data and path objects, returning a ClientResponse instance with the data returned from the endpoint.

Parameters:
expectedStatus the HTTP status that should be returned from the server
formData
pathArgs
Returns:
a ClientResponse instance with the data returned from the endpoint
Throws:
GitLabApiException
 
 	protected ClientResponse post (ClientResponse.Status expectedStatus, Form formDataObject ... pathArgsthrows GitLabApiException {
 		
 		ClientResponse response = null;
 		try {			
 			response = getApiClient().post(formDatapathArgs);			
 		} catch (Exception e) {
 			throw (new GitLabApiException(e));
 		}	
 		
 		if (response.getStatus() != expectedStatus.getStatusCode()) {
			throw (new GitLabApiException(response));			
		}
		return (response);
	}


Perform an HTTP POST call with the specified form data and URL, returning a ClientResponse instance with the data returned from the endpoint.

Parameters:
expectedStatus the HTTP status that should be returned from the server
formData
url
Returns:
a ClientResponse instance with the data returned from the endpoint
Throws:
GitLabApiException
	protected ClientResponse post (ClientResponse.Status expectedStatus, Form formDataURL urlthrows GitLabApiException {
		ClientResponse response = null;
		try {			
			response = getApiClient().post(formDataurl);
catch (Exception e) {
			throw (new GitLabApiException(e));
		}
		if (response.getStatus() != expectedStatus.getStatusCode()) {
			throw (new GitLabApiException(response));			
		}
		return (response);
	}



Perform an HTTP PUT call with the specified form data and path objects, returning a ClientResponse instance with the data returned from the endpoint.

Parameters:
expectedStatus the HTTP status that should be returned from the server
queryParams
pathArgs
Returns:
a ClientResponse instance with the data returned from the endpoint
Throws:
GitLabApiException
	protected  ClientResponse put (ClientResponse.Status expectedStatus, MultivaluedMap<StringStringqueryParamsObject ... pathArgsthrows GitLabApiException {
		ClientResponse response = null;
		try {			
			response = getApiClient().put(queryParamspathArgs);				
catch (Exception e) {
			throw (new GitLabApiException(e));
		}
		if (response.getStatus() != expectedStatus.getStatusCode()) {
			throw (new GitLabApiException(response));			
		}
		return (response);
	}	


Perform an HTTP PUT call with the specified form data and URL, returning a ClientResponse instance with the data returned from the endpoint.

Parameters:
expectedStatus the HTTP status that should be returned from the server
queryParams
url
Returns:
a ClientResponse instance with the data returned from the endpoint
Throws:
GitLabApiException
	protected ClientResponse put (ClientResponse.Status expectedStatus, MultivaluedMap<StringStringqueryParamsURL urlthrows GitLabApiException {	
		ClientResponse response = null;
		try {			
			response = getApiClient().put(queryParamsurl);			
catch (Exception e) {
			throw (new GitLabApiException(e));
		}	
		if (response.getStatus() != expectedStatus.getStatusCode()) {
			throw (new GitLabApiException(response));			
		}
		return (response);
	}	


Perform an HTTP DELETE call with the specified form data and path objects, returning a ClientResponse instance with the data returned from the endpoint.

Parameters:
expectedStatus the HTTP status that should be returned from the server
queryParams
pathArgs
Returns:
a ClientResponse instance with the data returned from the endpoint
Throws:
GitLabApiException
	protected  ClientResponse delete (ClientResponse.Status expectedStatus, MultivaluedMap<StringStringqueryParamsObject ... pathArgs)
		ClientResponse response = null;
		try {			
			response = getApiClient().delete(queryParamspathArgs);			
catch (Exception e) {
			throw (new GitLabApiException(e));
		}	
		if (response.getStatus() != expectedStatus.getStatusCode()) {
			throw (new GitLabApiException(response));			
		}
		return (response);
	}	


Perform an HTTP DELETE call with the specified form data and URL, returning a ClientResponse instance with the data returned from the endpoint.

Parameters:
expectedStatus the HTTP status that should be returned from the server
queryParams
url
Returns:
a ClientResponse instance with the data returned from the endpoint
Throws:
GitLabApiException
	protected ClientResponse delete (ClientResponse.Status expectedStatus, MultivaluedMap<StringStringqueryParamsURL urlthrows GitLabApiException {
		ClientResponse response = null;
		try {			
			response = getApiClient().delete(queryParamsurl);	
catch (Exception e) {
			throw (new GitLabApiException(e));
		}
		if (response.getStatus() != expectedStatus.getStatusCode()) {
			throw (new GitLabApiException(response));			
		}
		return (response);
	}


Parameters:
formData
string
email
	protected void addFormParam(Form formDataString nameObject valuethrows IllegalArgumentException {
		addFormParam(formDatanamevaluefalse);
	}


Parameters:
formData
string
email
required
	protected void addFormParam(Form formDataString nameObject valueboolean requiredthrows IllegalArgumentException {
			if (value == null) {
				if (required) {
					throw new IllegalArgumentException(name + " cannot be empty or null");
				}
				return;
			}
			String stringValue = value.toString().trim();
			if (required && stringValue.length() == 0) {
				throw new IllegalArgumentException(name + " cannot be empty or null");
			}
			formData.add(namestringValue);		
	}
New to GrepCode? Check out our FAQ X