public abstract class AbstractApi extends Object implements Constants
Constants.ActionType, Constants.ApplicationScope, Constants.ArchiveFormat, Constants.CommitBuildState, Constants.DeploymentStatus, Constants.Encoding, Constants.EpicOrderBy, Constants.GroupOrderBy, Constants.GroupSearchScope, Constants.ImpersonationState, Constants.IssueOrderBy, Constants.IssueScope, Constants.IssueState, Constants.JobScope, Constants.LineType, Constants.MergeRequestOrderBy, Constants.MergeRequestScope, Constants.MergeRequestSearchIn, Constants.MergeRequestState, Constants.MilestoneState, Constants.PipelineOrderBy, Constants.PipelineScope, Constants.ProjectOrderBy, Constants.ProjectSearchScope, Constants.SearchScope, Constants.SortOrder, Constants.StateEvent, Constants.TagOrderBy, Constants.TargetType, Constants.TodoAction, Constants.TodoState, Constants.TodoType, Constants.TokenType
Modifier and Type | Field and Description |
---|---|
protected GitLabApi |
gitLabApi |
NEXT_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> |
getDefaultPerPageParam(boolean customAttributesEnabled)
Creates a MultivaluedMap instance containing the "per_page" param with the default value.
|
Object |
getGroupIdOrPath(Object obj)
Returns the group ID or path from the provided Integer, String, or Group instance.
|
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.MultivaluedMap<String,String> |
getPageQueryParams(int page,
int perPage,
boolean customAttributesEnabled)
Creates a MultivaluedMap instance containing "page" and "per_page" params.
|
protected javax.ws.rs.core.MultivaluedMap<String,String> |
getPerPageQueryParam(int perPage)
Creates a MultivaluedMap instance containing the "per_page" param.
|
Object |
getProjectIdOrPath(Object obj)
Returns the project ID or path from the provided Integer, String, or Project instance.
|
Object |
getUserIdOrUsername(Object obj)
Returns the user ID or path from the provided Integer, String, or User instance.
|
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 javax.ws.rs.core.Response |
head(javax.ws.rs.core.Response.Status expectedStatus,
javax.ws.rs.core.MultivaluedMap<String,String> queryParams,
Object... pathArgs)
Perform an HTTP HEAD call with the specified query parameters and path objects, returning
a ClientResponse instance with the data returned from the endpoint.
|
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 |
post(javax.ws.rs.core.Response.Status expectedStatus,
Object payload,
Object... pathArgs)
Perform an HTTP POST call with the specified payload object 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.StreamingOutput stream,
String mediaType,
Object... pathArgs)
Perform an HTTP POST call with the specified payload object 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 |
putUpload(javax.ws.rs.core.Response.Status expectedStatus,
String name,
File fileToUpload,
Object... pathArgs)
Perform a file upload using the HTTP PUT method with the specified File instance and path objects,
returning a ClientResponse instance with the data returned from the endpoint.
|
protected javax.ws.rs.core.Response |
putUpload(javax.ws.rs.core.Response.Status expectedStatus,
String name,
File fileToUpload,
URL url)
Perform a file upload using the HTTP PUT method with the specified File instance and path objects,
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 javax.ws.rs.core.Response |
upload(javax.ws.rs.core.Response.Status expectedStatus,
String name,
File fileToUpload,
String mediaType,
javax.ws.rs.core.Form formData,
URL url)
Perform a file upload with the specified File instance and path objects, returning
a ClientResponse instance with the data returned from the endpoint.
|
protected javax.ws.rs.core.Response |
upload(javax.ws.rs.core.Response.Status expectedStatus,
String name,
File fileToUpload,
String mediaType,
Object... pathArgs)
Perform a file upload with the specified File instance and path objects, returning
a ClientResponse instance with the data returned from the endpoint.
|
protected javax.ws.rs.core.Response |
upload(javax.ws.rs.core.Response.Status expectedStatus,
String name,
File fileToUpload,
String mediaType,
URL url)
Perform a file upload with the specified File instance and path objects, returning
a ClientResponse instance with the data returned from the endpoint.
|
protected String |
urlEncode(String s)
Encode a string to be used as in-path argument for a gitlab api request.
|
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.
|
protected final GitLabApi gitLabApi
public AbstractApi(GitLabApi gitLabApi)
public Object getProjectIdOrPath(Object obj) throws GitLabApiException
obj
- the object to determine the ID or path fromGitLabApiException
- if any exception occurs during executionpublic Object getGroupIdOrPath(Object obj) throws GitLabApiException
obj
- the object to determine the ID or path fromGitLabApiException
- if any exception occurs during executionpublic Object getUserIdOrUsername(Object obj) throws GitLabApiException
obj
- the object to determine the ID or username fromGitLabApiException
- if any exception occurs during executionprotected GitLabApi.ApiVersion getApiVersion()
protected boolean isApiVersion(GitLabApi.ApiVersion apiVersion)
protected int getDefaultPerPage()
protected GitLabApiClient getApiClient()
protected String urlEncode(String s) throws GitLabApiException
s
- the string to encodeGitLabApiException
- if encoding throws an exceptionprotected 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 head(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, 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, Object payload, Object... pathArgs) throws GitLabApiException
expectedStatus
- the HTTP status that should be returned from the serverpayload
- the object instance that will be serialized to JSON and used as 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.StreamingOutput stream, String mediaType, Object... pathArgs) throws GitLabApiException
expectedStatus
- the HTTP status that should be returned from the serverstream
- the StreamingOutput that will be used for the POST datamediaType
- the content-type for the streamed 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 upload(javax.ws.rs.core.Response.Status expectedStatus, String name, File fileToUpload, String mediaType, Object... pathArgs) throws GitLabApiException
expectedStatus
- the HTTP status that should be returned from the servername
- the name for the form field that contains the file namefileToUpload
- a File instance pointing to the file to uploadmediaType
- the content-type of the uploaded file, if null will be determined from fileToUploadpathArgs
- variable list of arguments used to build the URIGitLabApiException
- if any exception occurs during executionprotected javax.ws.rs.core.Response upload(javax.ws.rs.core.Response.Status expectedStatus, String name, File fileToUpload, String mediaType, URL url) throws GitLabApiException
expectedStatus
- the HTTP status that should be returned from the servername
- the name for the form field that contains the file namefileToUpload
- a File instance pointing to the file to uploadmediaType
- the content-type of the uploaded file, if null will be determined from fileToUploadurl
- the fully formed path to the GitLab API endpointGitLabApiException
- if any exception occurs during executionprotected javax.ws.rs.core.Response upload(javax.ws.rs.core.Response.Status expectedStatus, String name, File fileToUpload, String mediaType, javax.ws.rs.core.Form formData, URL url) throws GitLabApiException
expectedStatus
- the HTTP status that should be returned from the servername
- the name for the form field that contains the file namefileToUpload
- a File instance pointing to the file to uploadmediaType
- the content-type of the uploaded file, if null will be determined from fileToUploadformData
- the Form containing the name/value pairsurl
- 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 putUpload(javax.ws.rs.core.Response.Status expectedStatus, String name, File fileToUpload, Object... pathArgs) throws GitLabApiException
expectedStatus
- the HTTP status that should be returned from the servername
- the name for the form field that contains the file namefileToUpload
- a File instance pointing to the file to uploadpathArgs
- variable list of arguments used to build the URIGitLabApiException
- if any exception occurs during executionprotected javax.ws.rs.core.Response putUpload(javax.ws.rs.core.Response.Status expectedStatus, String name, File fileToUpload, URL url) throws GitLabApiException
expectedStatus
- the HTTP status that should be returned from the servername
- the name for the form field that contains the file namefileToUpload
- a File instance pointing to the file to uploadurl
- the fully formed path to the GitLab API endpointGitLabApiException
- 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 addIllegalArgumentException
protected 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> getPerPageQueryParam(int perPage)
perPage
- the number of projects per pageprotected javax.ws.rs.core.MultivaluedMap<String,String> getPageQueryParams(int page, int perPage)
page
- the page to getperPage
- the number of projects per pageprotected javax.ws.rs.core.MultivaluedMap<String,String> getPageQueryParams(int page, int perPage, boolean customAttributesEnabled)
page
- the page to getperPage
- the number of projects per pagecustomAttributesEnabled
- enables customAttributes for this queryprotected javax.ws.rs.core.MultivaluedMap<String,String> getDefaultPerPageParam()
protected javax.ws.rs.core.MultivaluedMap<String,String> getDefaultPerPageParam(boolean customAttributesEnabled)
customAttributesEnabled
- enables customAttributes for this queryCopyright © 2019. All rights reserved.