Commit 0f393ef3 authored by Michaël van de Giessen's avatar Michaël van de Giessen
Browse files

#755 added PackageFilter to getPackages and getPackagesStream methods

parent d1e99e34
...@@ -27,10 +27,12 @@ import java.util.List; ...@@ -27,10 +27,12 @@ import java.util.List;
import java.util.stream.Stream; import java.util.stream.Stream;
import javax.ws.rs.core.GenericType; import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import org.gitlab4j.api.models.Package; import org.gitlab4j.api.models.Package;
import org.gitlab4j.api.models.PackageFile; import org.gitlab4j.api.models.PackageFile;
import org.gitlab4j.api.models.PackageFilter;
/** /**
* <p>This class implements the client side API for the GitLab Packages API. * <p>This class implements the client side API for the GitLab Packages API.
...@@ -88,8 +90,25 @@ public class PackagesApi extends AbstractApi { ...@@ -88,8 +90,25 @@ public class PackagesApi extends AbstractApi {
* @throws GitLabApiException if any exception occurs * @throws GitLabApiException if any exception occurs
*/ */
public Pager<Package> getPackages(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException { public Pager<Package> getPackages(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException {
return (new Pager<Package>(this, Package.class, itemsPerPage, null, return getPackages(projectIdOrPath,null,itemsPerPage);
"projects", getProjectIdOrPath(projectIdOrPath), "packages")); }
/**
* 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.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/packages</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param filter the PackageFilter instance holding the filter values for the query
* @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<Package> getPackages(Object projectIdOrPath, PackageFilter filter, int itemsPerPage) throws GitLabApiException {
MultivaluedMap query = filter!=null?filter.getQueryParams().asMap():null;
return (new Pager<Package>(this, Package.class, itemsPerPage, query,
"projects", getProjectIdOrPath(projectIdOrPath), "packages"));
} }
/** /**
...@@ -106,6 +125,21 @@ public class PackagesApi extends AbstractApi { ...@@ -106,6 +125,21 @@ public class PackagesApi extends AbstractApi {
return (getPackages(projectIdOrPath, getDefaultPerPage()).stream()); return (getPackages(projectIdOrPath, getDefaultPerPage()).stream());
} }
/**
* 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.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/packages</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param filter the PackageFilter instance holding the filter values for the query
* @return a Stream of pages in the project's packages
* @throws GitLabApiException if any exception occurs
*/
public Stream<Package> getPackagesStream(Object projectIdOrPath, PackageFilter filter) throws GitLabApiException {
return (getPackages(projectIdOrPath, filter, getDefaultPerPage()).stream());
}
/** /**
* Get a single project package. * Get a single project package.
* *
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment