Skip to content

Commit 87ea8f6

Browse files
committed
Added support for the Packages API (#317).
1 parent 0e96088 commit 87ea8f6

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/main/java/org/gitlab4j/api/GitLabApi.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public String getApiNamespace() {
6767
private NamespaceApi namespaceApi;
6868
private NotesApi notesApi;
6969
private NotificationSettingsApi notificationSettingsApi;
70+
private PackagesApi packagesApi;
7071
private PipelineApi pipelineApi;
7172
private ProjectApi projectApi;
7273
private ProtectedBranchesApi protectedBranchesApi;
@@ -1141,6 +1142,25 @@ public NotificationSettingsApi getNotificationSettingsApi() {
11411142
return (notificationSettingsApi);
11421143
}
11431144

1145+
/**
1146+
* Gets the PackagesApi instance owned by this GitLabApi instance. The PackagesApi is used
1147+
* to perform all Package related API calls.
1148+
*
1149+
* @return the PackagesApi instance owned by this GitLabApi instance
1150+
*/
1151+
public PackagesApi getPackagesApi() {
1152+
1153+
if (packagesApi == null) {
1154+
synchronized (this) {
1155+
if (packagesApi == null) {
1156+
packagesApi = new PackagesApi(this);
1157+
}
1158+
}
1159+
}
1160+
1161+
return (packagesApi);
1162+
}
1163+
11441164
/**
11451165
* Gets the PipelineApi instance owned by this GitLabApi instance. The PipelineApi is used
11461166
* to perform all pipeline related API calls.

src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@
6060
import org.gitlab4j.api.models.Note;
6161
import org.gitlab4j.api.models.NotificationSettings;
6262
import org.gitlab4j.api.models.OauthTokenResponse;
63+
import org.gitlab4j.api.models.Package;
64+
import org.gitlab4j.api.models.PackageFile;
6365
import org.gitlab4j.api.models.Pipeline;
6466
import org.gitlab4j.api.models.PipelineSchedule;
6567
import org.gitlab4j.api.models.Project;
@@ -204,6 +206,18 @@ public void testMergeRequestDiscussions() throws Exception {
204206
assertTrue(compareJson(discussions, "merge-request-discussions.json"));
205207
}
206208

209+
@Test
210+
public void testPackages() throws Exception {
211+
List<Package> packages = unmarshalResourceList(Package.class, "packages.json");
212+
assertTrue(compareJson(packages, "packages.json"));
213+
}
214+
215+
@Test
216+
public void testPackageFiles() throws Exception {
217+
List<PackageFile> packageFiles = unmarshalResourceList(PackageFile.class, "package-files.json");
218+
assertTrue(compareJson(packageFiles, "package-files.json"));
219+
}
220+
207221
@Test
208222
public void testSnippetDiscussions() throws Exception {
209223
List<Discussion> discussions = unmarshalResourceList(Discussion.class, "snippet-discussions.json");

0 commit comments

Comments
 (0)