package org.gitlab4j.api; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; import javax.ws.rs.core.GenericType; import javax.ws.rs.core.Response; import org.gitlab4j.api.models.Application; /** * This class implements the client side API for the GitLab Applications API. * See Applications API at GitLab for more information. */ public class ApplicationsApi extends AbstractApi { public ApplicationsApi(GitLabApi gitLabApi) { super(gitLabApi); } /** * Get all OATH applications. * *
GitLab Endpoint: GET /api/v4/applications
*
* @return a List of OAUTH Application instances
* @throws GitLabApiException if any exception occurs
*/
public ListGitLab Endpoint: GET /api/v4/applications
*
* @param page the page to get
* @param perPage the number of items per page
* @return a list of OAUTH Applications in the specified range
* @throws GitLabApiException if any exception occurs
*/
public ListGitLab Endpoint: GET /api/v4/applications
*
* @param itemsPerPage the number of items per page
* @return a Pager of Application instances in the specified range
* @throws GitLabApiException if any exception occurs
*/
public PagerGitLab Endpoint: GET /api/v4/applications
*
* @return a Stream of OAUTH Application instances
* @throws GitLabApiException if any exception occurs
*/
public StreamGitLab Endpoint: POST /api/v4/applications
*
* @param name the name for the OAUTH Application
* @param redirectUri the redirect URI for the OAUTH Application
* @param scopes the scopes of the application (api, read_user, sudo, read_repository, openid, profile, email)
* @return the created Application instance
* @throws GitLabApiException if any exception occurs
*/
public Application createApplication(String name, String redirectUri, ApplicationScope[] scopes) throws GitLabApiException {
if (scopes == null || scopes.length == 0) {
throw new GitLabApiException("scopes cannot be null or empty");
}
return (createApplication(name, redirectUri, Arrays.asList(scopes)));
}
/**
* Create an OAUTH Application.
*
* GitLab Endpoint: POST /api/v4/applications
*
* @param name the name for the OAUTH Application
* @param redirectUri the redirect URI for the OAUTH Application
* @param scopes the scopes of the application (api, read_user, sudo, read_repository, openid, profile, email)
* @return the created Application instance
* @throws GitLabApiException if any exception occurs
*/
public Application createApplication(String name, String redirectUri, ListGitLab Endpoint: DELETE /api/v4/applications/:applicationId
*
* @param applicationId the ID of the OUAUTH Application to delete
* @throws GitLabApiException if any exception occurs
*/
public void deleteApplication(Integer applicationId) throws GitLabApiException {
delete(Response.Status.NO_CONTENT, null, "applications", applicationId);
}
}