2727import java .util .stream .Stream ;
2828
2929import javax .ws .rs .core .GenericType ;
30+ import javax .ws .rs .core .MultivaluedMap ;
3031import javax .ws .rs .core .Response ;
3132
3233import org .gitlab4j .api .models .Package ;
3334import org .gitlab4j .api .models .PackageFile ;
35+ import org .gitlab4j .api .models .PackageFilter ;
3436
3537/**
3638 * <p>This class implements the client side API for the GitLab Packages API.
@@ -88,8 +90,25 @@ public List<Package> getPackages(Object projectIdOrPath, int page, int perPage)
8890 * @throws GitLabApiException if any exception occurs
8991 */
9092 public Pager <Package > getPackages (Object projectIdOrPath , int itemsPerPage ) throws GitLabApiException {
91- return (new Pager <Package >(this , Package .class , itemsPerPage , null ,
92- "projects" , getProjectIdOrPath (projectIdOrPath ), "packages" ));
93+ return getPackages (projectIdOrPath ,null ,itemsPerPage );
94+ }
95+
96+ /**
97+ * Get a Pager of project packages. Both Maven and NPM packages are included in results.
98+ * When accessed without authentication, only packages of public projects are returned.
99+ *
100+ * <pre><code>GitLab Endpoint: GET /projects/:id/packages</code></pre>
101+ *
102+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
103+ * @param filter the PackageFilter instance holding the filter values for the query
104+ * @param itemsPerPage the number of Package instances per page
105+ * @return a Pager of project packages for the specified range
106+ * @throws GitLabApiException if any exception occurs
107+ */
108+ public Pager <Package > getPackages (Object projectIdOrPath , PackageFilter filter , int itemsPerPage ) throws GitLabApiException {
109+ MultivaluedMap query = filter !=null ?filter .getQueryParams ().asMap ():null ;
110+ return (new Pager <Package >(this , Package .class , itemsPerPage , query ,
111+ "projects" , getProjectIdOrPath (projectIdOrPath ), "packages" ));
93112 }
94113
95114 /**
@@ -106,6 +125,21 @@ public Stream<Package> getPackagesStream(Object projectIdOrPath) throws GitLabAp
106125 return (getPackages (projectIdOrPath , getDefaultPerPage ()).stream ());
107126 }
108127
128+ /**
129+ * Get a Stream of project packages. Both Maven and NPM packages are included in results.
130+ * When accessed without authentication, only packages of public projects are returned.
131+ *
132+ * <pre><code>GitLab Endpoint: GET /projects/:id/packages</code></pre>
133+ *
134+ * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
135+ * @param filter the PackageFilter instance holding the filter values for the query
136+ * @return a Stream of pages in the project's packages
137+ * @throws GitLabApiException if any exception occurs
138+ */
139+ public Stream <Package > getPackagesStream (Object projectIdOrPath , PackageFilter filter ) throws GitLabApiException {
140+ return (getPackages (projectIdOrPath , filter , getDefaultPerPage ()).stream ());
141+ }
142+
109143 /**
110144 * Get a single project package.
111145 *
0 commit comments