public abstract class AbstractApi extends Object implements Constants
Constants.ActionType, Constants.IssueScope, Constants.IssueState, Constants.JobScope, Constants.LineType, Constants.PipelineOrderBy, Constants.PipelineScope, Constants.ProjectOrderBy, Constants.SortOrder, Constants.StateEvent, Constants.TargetType, Constants.TokenTypeNEXT_PAGE_HEADER, PAGE_HEADER, PAGE_PARAM, PER_PAGE, PER_PAGE_PARAM, PREV_PAGE_HEADER, TOTAL_HEADER, TOTAL_PAGES_HEADER| Constructor and Description |
|---|
AbstractApi(GitLabApi gitLabApi) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addFormParam(javax.ws.rs.core.Form formData,
String name,
Object value)
Convenience method for adding query and form parameters to a get() or post() call.
|
protected void |
addFormParam(javax.ws.rs.core.Form formData,
String name,
Object value,
boolean required)
Convenience method for adding query and form parameters to a get() or post() call.
|
protected javax.ws.rs.core.Response |
delete(javax.ws.rs.core.Response.Status expectedStatus,
javax.ws.rs.core.MultivaluedMap<String,String> queryParams,
Object... pathArgs)
Perform an HTTP DELETE call with the specified form data and path objects, returning
a ClientResponse instance with the data returned from the endpoint.
|
protected javax.ws.rs.core.Response |
delete(javax.ws.rs.core.Response.Status expectedStatus,
javax.ws.rs.core.MultivaluedMap<String,String> queryParams,
URL url)
Perform an HTTP DELETE call with the specified form data and URL, returning
a ClientResponse instance with the data returned from the endpoint.
|
protected javax.ws.rs.core.Response |
get(javax.ws.rs.core.Response.Status expectedStatus,
javax.ws.rs.core.MultivaluedMap<String,String> queryParams,
Object... pathArgs)
Perform an HTTP GET call with the specified query parameters and path objects, returning
a ClientResponse instance with the data returned from the endpoint.
|
protected javax.ws.rs.core.Response |
get(javax.ws.rs.core.Response.Status expectedStatus,
javax.ws.rs.core.MultivaluedMap<String,String> queryParams,
URL url)
Perform an HTTP GET call with the specified query parameters and URL, returning
a ClientResponse instance with the data returned from the endpoint.
|
protected GitLabApiClient |
getApiClient() |
protected GitLabApi.ApiVersion |
getApiVersion() |
protected int |
getDefaultPerPage() |
protected javax.ws.rs.core.MultivaluedMap<String,String> |
getDefaultPerPageParam()
Creates a MultivaluedMap instance containing the "per_page" param with the default value.
|
protected javax.ws.rs.core.MultivaluedMap<String,String> |
getPageQueryParams(int page,
int perPage)
Creates a MultivaluedMap instance containing "page" and "per_page" params.
|
protected javax.ws.rs.core.Response |
getWithAccepts(javax.ws.rs.core.Response.Status expectedStatus,
javax.ws.rs.core.MultivaluedMap<String,String> queryParams,
String accepts,
Object... pathArgs)
Perform an HTTP GET call with the specified query parameters and path objects, returning
a ClientResponse instance with the data returned from the endpoint.
|
protected GitLabApiException |
handle(Exception thrown)
Wraps an exception in a GitLabApiException if needed.
|
protected boolean |
isApiVersion(GitLabApi.ApiVersion apiVersion) |
protected javax.ws.rs.core.Response |
post(javax.ws.rs.core.Response.Status expectedStatus,
javax.ws.rs.core.Form formData,
Object... pathArgs)
Perform an HTTP POST call with the specified form data and path objects, returning
a ClientResponse instance with the data returned from the endpoint.
|
protected javax.ws.rs.core.Response |
post(javax.ws.rs.core.Response.Status expectedStatus,
javax.ws.rs.core.Form formData,
URL url)
Perform an HTTP POST call with the specified form data and URL, returning
a ClientResponse instance with the data returned from the endpoint.
|
protected javax.ws.rs.core.Response |
post(javax.ws.rs.core.Response.Status expectedStatus,
javax.ws.rs.core.MultivaluedMap<String,String> queryParams,
Object... pathArgs)
Perform an HTTP POST call with the specified form data and path objects, returning
a ClientResponse instance with the data returned from the endpoint.
|
protected javax.ws.rs.core.Response |
put(javax.ws.rs.core.Response.Status expectedStatus,
javax.ws.rs.core.MultivaluedMap<String,String> queryParams,
Object... pathArgs)
Perform an HTTP PUT call with the specified form data and path objects, returning
a ClientResponse instance with the data returned from the endpoint.
|
protected javax.ws.rs.core.Response |
put(javax.ws.rs.core.Response.Status expectedStatus,
javax.ws.rs.core.MultivaluedMap<String,String> queryParams,
URL url)
Perform an HTTP PUT call with the specified form data and URL, returning
a ClientResponse instance with the data returned from the endpoint.
|
protected javax.ws.rs.core.Response |
putWithFormData(javax.ws.rs.core.Response.Status expectedStatus,
javax.ws.rs.core.Form formData,
Object... pathArgs)
Perform an HTTP PUT call with the specified form data and path objects, returning
a ClientResponse instance with the data returned from the endpoint.
|
protected String |
urlEncode(String s) |
protected javax.ws.rs.core.Response |
validate(javax.ws.rs.core.Response response,
javax.ws.rs.core.Response.Status expected)
Validates response the response from the server against the expected HTTP status and
the returned secret token, if either is not correct will throw a GitLabApiException.
|
public AbstractApi(GitLabApi gitLabApi)
protected GitLabApi.ApiVersion getApiVersion()
protected boolean isApiVersion(GitLabApi.ApiVersion apiVersion)
protected int getDefaultPerPage()
protected GitLabApiClient getApiClient()
protected String urlEncode(String s) throws GitLabApiException
GitLabApiExceptionprotected javax.ws.rs.core.Response get(javax.ws.rs.core.Response.Status expectedStatus,
javax.ws.rs.core.MultivaluedMap<String,String> queryParams,
Object... pathArgs)
throws GitLabApiException
expectedStatus - the HTTP status that should be returned from the serverqueryParams - multivalue map of request parameterspathArgs - variable list of arguments used to build the URIGitLabApiException - if any exception occurs during executionprotected javax.ws.rs.core.Response getWithAccepts(javax.ws.rs.core.Response.Status expectedStatus,
javax.ws.rs.core.MultivaluedMap<String,String> queryParams,
String accepts,
Object... pathArgs)
throws GitLabApiException
expectedStatus - the HTTP status that should be returned from the serverqueryParams - multivalue map of request parametersaccepts - if non-empty will set the Accepts header to this valuepathArgs - variable list of arguments used to build the URIGitLabApiException - if any exception occurs during executionprotected javax.ws.rs.core.Response get(javax.ws.rs.core.Response.Status expectedStatus,
javax.ws.rs.core.MultivaluedMap<String,String> queryParams,
URL url)
throws GitLabApiException
expectedStatus - the HTTP status that should be returned from the serverqueryParams - multivalue map of request parametersurl - the fully formed path to the GitLab API endpointGitLabApiException - if any exception occurs during executionprotected javax.ws.rs.core.Response post(javax.ws.rs.core.Response.Status expectedStatus,
javax.ws.rs.core.Form formData,
Object... pathArgs)
throws GitLabApiException
expectedStatus - the HTTP status that should be returned from the serverformData - the Form containing the name/value pairs for the POST datapathArgs - variable list of arguments used to build the URIGitLabApiException - if any exception occurs during executionprotected javax.ws.rs.core.Response post(javax.ws.rs.core.Response.Status expectedStatus,
javax.ws.rs.core.MultivaluedMap<String,String> queryParams,
Object... pathArgs)
throws GitLabApiException
expectedStatus - the HTTP status that should be returned from the serverqueryParams - multivalue map of request parameterspathArgs - variable list of arguments used to build the URIGitLabApiException - if any exception occurs during executionprotected javax.ws.rs.core.Response post(javax.ws.rs.core.Response.Status expectedStatus,
javax.ws.rs.core.Form formData,
URL url)
throws GitLabApiException
expectedStatus - the HTTP status that should be returned from the serverformData - the Form containing the name/value pairs for the POST dataurl - the fully formed path to the GitLab API endpointGitLabApiException - if any exception occurs during executionprotected javax.ws.rs.core.Response put(javax.ws.rs.core.Response.Status expectedStatus,
javax.ws.rs.core.MultivaluedMap<String,String> queryParams,
Object... pathArgs)
throws GitLabApiException
expectedStatus - the HTTP status that should be returned from the serverqueryParams - multivalue map of request parameterspathArgs - variable list of arguments used to build the URIGitLabApiException - if any exception occurs during executionprotected javax.ws.rs.core.Response put(javax.ws.rs.core.Response.Status expectedStatus,
javax.ws.rs.core.MultivaluedMap<String,String> queryParams,
URL url)
throws GitLabApiException
expectedStatus - the HTTP status that should be returned from the serverqueryParams - multivalue map of request parametersurl - the fully formed path to the GitLab API endpointGitLabApiException - if any exception occurs during executionprotected javax.ws.rs.core.Response putWithFormData(javax.ws.rs.core.Response.Status expectedStatus,
javax.ws.rs.core.Form formData,
Object... pathArgs)
throws GitLabApiException
expectedStatus - the HTTP status that should be returned from the serverformData - the Form containing the name/value pairs for the POST datapathArgs - variable list of arguments used to build the URIGitLabApiException - if any exception occurs during executionprotected javax.ws.rs.core.Response delete(javax.ws.rs.core.Response.Status expectedStatus,
javax.ws.rs.core.MultivaluedMap<String,String> queryParams,
Object... pathArgs)
throws GitLabApiException
expectedStatus - the HTTP status that should be returned from the serverqueryParams - multivalue map of request parameterspathArgs - variable list of arguments used to build the URIGitLabApiException - if any exception occurs during executionprotected javax.ws.rs.core.Response delete(javax.ws.rs.core.Response.Status expectedStatus,
javax.ws.rs.core.MultivaluedMap<String,String> queryParams,
URL url)
throws GitLabApiException
expectedStatus - the HTTP status that should be returned from the serverqueryParams - multivalue map of request parametersurl - the fully formed path to the GitLab API endpointGitLabApiException - if any exception occurs during executionprotected void addFormParam(javax.ws.rs.core.Form formData,
String name,
Object value)
throws IllegalArgumentException
formData - the Form containing the name/value pairsname - the name of the field/attribute to addvalue - the value of the field/attribute to addIllegalArgumentExceptionprotected void addFormParam(javax.ws.rs.core.Form formData,
String name,
Object value,
boolean required)
throws IllegalArgumentException
formData - the Form containing the name/value pairsname - the name of the field/attribute to addvalue - the value of the field/attribute to addrequired - the field is required flagIllegalArgumentException - if a required parameter is null or emptyprotected javax.ws.rs.core.Response validate(javax.ws.rs.core.Response response,
javax.ws.rs.core.Response.Status expected)
throws GitLabApiException
response - responseexpected - expected response statusGitLabApiException - if HTTP status is not as expected, or the secret token doesn't matchprotected GitLabApiException handle(Exception thrown)
thrown - the exception that should be wrappedprotected javax.ws.rs.core.MultivaluedMap<String,String> getPageQueryParams(int page, int perPage)
page - the page to getperPage - the number of projects per pageCopyright © 2017. All rights reserved.