public class GitLabApiClient extends Object
Modifier and Type | Class and Description |
---|---|
protected class |
GitLabApiClient.AcceptAllHostnameVerifier |
Modifier and Type | Field and Description |
---|---|
protected static String |
API_NAMESPACE |
protected static String |
PRIVATE_TOKEN_HEADER |
protected static String |
X_GITLAB_TOKEN_HEADER |
Constructor and Description |
---|
GitLabApiClient(String hostUrl,
String privateToken)
Construct an instance to communicate with a GitLab API server using the specified
server URL, private token, and secret token.
|
GitLabApiClient(String hostUrl,
String privateToken,
String secretToken)
Construct an instance to communicate with a GitLab API server using the specified
server URL, private token, and secret token.
|
GitLabApiClient(String hostUrl,
String privateToken,
String secretToken,
Map<String,Object> clientConfigProperties)
Construct an instance to communicate with a GitLab API server using the specified
server URL and private token.
|
Modifier and Type | Method and Description |
---|---|
protected javax.ws.rs.core.Response |
delete(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 Response instance with the data returned from the endpoint.
|
protected javax.ws.rs.core.Response |
delete(javax.ws.rs.core.MultivaluedMap<String,String> queryParams,
URL url)
Perform an HTTP DELETE call with the specified form data and URL, returning
a Response instance with the data returned from the endpoint.
|
protected javax.ws.rs.core.Response |
get(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.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 URL |
getApiUrl(Object... pathArgs)
Construct a REST URL with the specified path arguments.
|
boolean |
getIgnoreCertificateErrors()
Returns true if the API is setup to ignore SSL certificate errors, otherwise returns false.
|
protected javax.ws.rs.client.Invocation.Builder |
invocation(URL url,
javax.ws.rs.core.MultivaluedMap<String,String> queryParams) |
protected javax.ws.rs.core.Response |
post(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.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.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.MultivaluedMap<String,String> queryParams,
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 |
put(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.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.
|
void |
setIgnoreCerificateErrors(boolean ignoreCertificateErrors)
Sets up the Jersey system ignore SSL certificate errors or not.
|
protected boolean |
validateSecretToken(javax.ws.rs.core.Response response)
Validates the secret token (X-GitLab-Token) header against the expected secret token, returns true if valid,
otherwise returns false.
|
protected static final String PRIVATE_TOKEN_HEADER
protected static final String X_GITLAB_TOKEN_HEADER
protected static final String API_NAMESPACE
public GitLabApiClient(String hostUrl, String privateToken)
hostUrl
- the URL to the GitLab API serverprivateToken
- the private token to authenticate withpublic GitLabApiClient(String hostUrl, String privateToken, String secretToken)
hostUrl
- the URL to the GitLab API serverprivateToken
- the private token to authenticate withsecretToken
- use this token to validate received payloadspublic GitLabApiClient(String hostUrl, String privateToken, String secretToken, Map<String,Object> clientConfigProperties)
hostUrl
- the URL to the GitLab API serverprivateToken
- the private token to authenticate withsecretToken
- use this token to validate received payloadsclientConfigProperties
- the properties given to Jersey's clientconfigpublic boolean getIgnoreCertificateErrors()
public void setIgnoreCerificateErrors(boolean ignoreCertificateErrors)
ignoreCertificateErrors
- if true will set up the Jersey system ignore SSL certificate errorsprotected URL getApiUrl(Object... pathArgs) throws IOException
pathArgs
- ariable list of arguments used to build the URIIOException
- if an error occurs while constructing the URLprotected boolean validateSecretToken(javax.ws.rs.core.Response response)
response
- the Response instance sent from the GitLab serverprotected javax.ws.rs.core.Response get(javax.ws.rs.core.MultivaluedMap<String,String> queryParams, Object... pathArgs) throws IOException
queryParams
- multivalue map of request parameterspathArgs
- variable list of arguments used to build the URIIOException
- if an error occurs while constructing the URLprotected javax.ws.rs.core.Response get(javax.ws.rs.core.MultivaluedMap<String,String> queryParams, URL url)
queryParams
- multivalue map of request parametersurl
- the fully formed path to the GitLab API endpointprotected javax.ws.rs.core.Response post(javax.ws.rs.core.Form formData, Object... pathArgs) throws IOException
formData
- the Form containing the name/value pairspathArgs
- variable list of arguments used to build the URIIOException
- if an error occurs while constructing the URLprotected javax.ws.rs.core.Response post(javax.ws.rs.core.MultivaluedMap<String,String> queryParams, Object... pathArgs) throws IOException
queryParams
- multivalue map of request parameterspathArgs
- variable list of arguments used to build the URIIOException
- if an error occurs while constructing the URLprotected javax.ws.rs.core.Response post(javax.ws.rs.core.Form formData, URL url)
formData
- the Form containing the name/value pairsurl
- the fully formed path to the GitLab API endpointprotected javax.ws.rs.core.Response post(javax.ws.rs.core.MultivaluedMap<String,String> queryParams, URL url)
queryParams
- multivalue map of request parametersformData the Form containing the name/value pairsurl
- the fully formed path to the GitLab API endpointprotected javax.ws.rs.core.Response put(javax.ws.rs.core.MultivaluedMap<String,String> queryParams, Object... pathArgs) throws IOException
queryParams
- multivalue map of request parameterspathArgs
- variable list of arguments used to build the URIIOException
- if an error occurs while constructing the URLprotected javax.ws.rs.core.Response put(javax.ws.rs.core.MultivaluedMap<String,String> queryParams, URL url)
queryParams
- multivalue map of request parametersurl
- the fully formed path to the GitLab API endpointprotected javax.ws.rs.core.Response delete(javax.ws.rs.core.MultivaluedMap<String,String> queryParams, Object... pathArgs) throws IOException
queryParams
- multivalue map of request parameterspathArgs
- variable list of arguments used to build the URIIOException
- if an error occurs while constructing the URLprotected javax.ws.rs.core.Response delete(javax.ws.rs.core.MultivaluedMap<String,String> queryParams, URL url)
queryParams
- multivalue map of request parametersurl
- the fully formed path to the GitLab API endpointCopyright © 2017. All rights reserved.