All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.gitlab4j.api.PackagesApi Maven / Gradle / Ivy

Go to download

GitLab4J-API (gitlab4j-api) provides a full featured Java client library for working with GitLab repositories and servers via the GitLab REST API.

There is a newer version: 6.0.0-rc.5
Show newest version
/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2017 Greg Messner 
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
 * this software and associated documentation files (the "Software"), to deal in
 * the Software without restriction, including without limitation the rights to
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
 * the Software, and to permit persons to whom the Software is furnished to do so,
 * subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

package org.gitlab4j.api;

import java.util.List;
import java.util.stream.Stream;

import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.Response;

import org.gitlab4j.api.models.Package;
import org.gitlab4j.api.models.PackageFile;

/**
 * 

This class implements the client side API for the GitLab Packages API. * See Packages API at GitLab for more information.

* * NOTE: This API is not available in the Community edition of GitLab. */ public class PackagesApi extends AbstractApi { public PackagesApi(GitLabApi gitLabApi) { super(gitLabApi); } /** * Get a list of project packages. Both Maven and NPM packages are included in results. * When accessed without authentication, only packages of public projects are returned. * *
GitLab Endpoint: GET /projects/:id/packages
* * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance * @return a list of pages in the project's packages * @throws GitLabApiException if any exception occurs */ public List getPackages(Object projectIdOrPath) throws GitLabApiException { return (getPackages(projectIdOrPath, getDefaultPerPage()).all()); } /** * Get a list of project packages for the specified page. Both Maven and NPM packages are included in results. * When accessed without authentication, only packages of public projects are returned. * *
GitLab Endpoint: GET /projects/:id/packages
* * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance * @param page the page to get * @param perPage the number of Package instances per page * @return a list of project packages for the specified range * @throws GitLabApiException if any exception occurs */ public List getPackages(Object projectIdOrPath, int page, int perPage) throws GitLabApiException { Response response = get(Response.Status.OK, getPageQueryParams(page, perPage), "projects", getProjectIdOrPath(projectIdOrPath), "packages"); return response.readEntity(new GenericType>() {}); } /** * Get a Pager of project packages. Both Maven and NPM packages are included in results. * When accessed without authentication, only packages of public projects are returned. * *
GitLab Endpoint: GET /projects/:id/packages
* * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance * @param itemsPerPage the number of Package instances per page * @return a Pager of project packages for the specified range * @throws GitLabApiException if any exception occurs */ public Pager getPackages(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException { return (new Pager(this, Package.class, itemsPerPage, null, "projects", getProjectIdOrPath(projectIdOrPath), "packages")); } /** * Get a Stream of project packages. Both Maven and NPM packages are included in results. * When accessed without authentication, only packages of public projects are returned. * *
GitLab Endpoint: GET /projects/:id/packages
* * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance * @return a Stream of pages in the project's packages * @throws GitLabApiException if any exception occurs */ public Stream getPackagesStream(Object projectIdOrPath) throws GitLabApiException { return (getPackages(projectIdOrPath, getDefaultPerPage()).stream()); } /** * Get a single project package. * *
GitLab Endpoint: GET /projects/:id/packages/:package_id
* * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance * @param packageId the ID of the package to get * @return a Package instance for the specified package ID * @throws GitLabApiException if any exception occurs */ public Package getPackage(Object projectIdOrPath, Integer packageId) throws GitLabApiException { Response response = get(Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath), "packages", packageId); return (response.readEntity(Package.class)); } /** * Get a list of package files of a single package. * *
GitLab Endpoint: GET /projects/:id/packages/:package_id/package_files
* * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance * @param packageId the ID of the package to get the package files for * @return a list of PackageFile instances for the specified package ID * @throws GitLabApiException if any exception occurs */ public List getPackageFiles(Object projectIdOrPath, Integer packageId) throws GitLabApiException { return (getPackageFiles(projectIdOrPath, packageId, getDefaultPerPage()).all()); } /** * Get a list of package files of a single package for the specified page. * *
GitLab Endpoint: GET /projects/:id/packages/:package_id/package_files
* * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance * @param packageId the ID of the package to get the package files for * @param page the page to get * @param perPage the number of PackageFile instances per page * @return a list of PackageFile instances for the specified package ID * @throws GitLabApiException if any exception occurs */ public List getPackageFiles(Object projectIdOrPath, Integer packageId, int page, int perPage) throws GitLabApiException { Response response = get(Response.Status.OK, getPageQueryParams(page, perPage), "projects", getProjectIdOrPath(projectIdOrPath), "packages", packageId, "package_files"); return response.readEntity(new GenericType>() {}); } /** * Get a Pager of project package files. * *
GitLab Endpoint: GET /projects/:id/packages/:package_id/package_files
* * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance * @param packageId the ID of the package to get the package files for * @param itemsPerPage the number of PackageFile instances per page * @return a Pager of PackageFile instances for the specified package ID * @throws GitLabApiException if any exception occurs */ public Pager getPackageFiles(Object projectIdOrPath, Integer packageId, int itemsPerPage) throws GitLabApiException { return (new Pager(this, PackageFile.class, itemsPerPage, null, "projects", getProjectIdOrPath(projectIdOrPath), "packages", packageId, "package_files")); } /** * Get a Stream of project package files. * *
GitLab Endpoint: GET /projects/:id/packages/:package_id/package_files
* * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance * @param packageId the ID of the package to get the package files for * @return a Stream of PackageFile instances for the specified package ID * @throws GitLabApiException if any exception occurs */ public Stream getPackagesStream(Object projectIdOrPath, Integer packageId) throws GitLabApiException { return (getPackageFiles(projectIdOrPath, packageId, getDefaultPerPage()).stream()); } /** * Deletes a project package. * *
GitLab Endpoint: DELETE /projects/:id/packages/:package_id
* * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance * @param packageId the ID of the package to delete * @throws GitLabApiException if any exception occurs */ public void deletePackage(Object projectIdOrPath, Integer packageId) throws GitLabApiException { if (packageId == null) { throw new RuntimeException("packageId cannot be null"); } delete(Response.Status.NO_CONTENT, null,"projects", getProjectIdOrPath(projectIdOrPath), "packages", packageId); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy