diff --git a/build.gradle b/build.gradle
index 4e447c3..a936e8a 100644
--- a/build.gradle
+++ b/build.gradle
@@ -9,7 +9,7 @@ repositories {
mavenCentral()
}
-version = '2.0.0'
+version = '2.0.1'
sourceSets {
diff --git a/src/main/java/io/linuxserver/fleet/v2/types/api/external/AllImagesExternalApiResponse.java b/src/main/java/io/linuxserver/fleet/v2/types/api/external/AllImagesExternalApiResponse.java
new file mode 100644
index 0000000..5397f98
--- /dev/null
+++ b/src/main/java/io/linuxserver/fleet/v2/types/api/external/AllImagesExternalApiResponse.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2020 LinuxServer.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package io.linuxserver.fleet.v2.types.api.external;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class AllImagesExternalApiResponse {
+
+ private final Map> repositories;
+
+ public AllImagesExternalApiResponse() {
+ this.repositories = new HashMap<>();
+ }
+
+ public final void addImage(final String repositoryName,
+ final String imageName,
+ final long pullCount,
+ final String version,
+ final boolean stable) {
+
+ if (!repositories.containsKey(repositoryName)) {
+ repositories.put(repositoryName, new ArrayList<>());
+ }
+
+ repositories.get(repositoryName).add(new ExternalApiImage(imageName, pullCount, version, stable));
+ }
+
+ public final long getTotalPullCount() {
+
+ long totalPullCount = 0L;
+ for (List repositoryImages : repositories.values()) {
+ for (ExternalApiImage image : repositoryImages) {
+ totalPullCount += image.getPullCount();
+ }
+ }
+ return totalPullCount;
+ }
+
+ public final Map> getRepositories() {
+ return repositories;
+ }
+}
diff --git a/src/main/java/io/linuxserver/fleet/v2/types/api/external/ExternalApiImage.java b/src/main/java/io/linuxserver/fleet/v2/types/api/external/ExternalApiImage.java
new file mode 100644
index 0000000..35d49df
--- /dev/null
+++ b/src/main/java/io/linuxserver/fleet/v2/types/api/external/ExternalApiImage.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2020 LinuxServer.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package io.linuxserver.fleet.v2.types.api.external;
+
+public class ExternalApiImage {
+
+ private String name;
+ private long pullCount;
+ private String version;
+ private boolean stable;
+
+ public ExternalApiImage(final String name, final long pullCount, final String version, final boolean stable) {
+ this.name = name;
+ this.pullCount = pullCount;
+ this.version = version;
+ this.stable = stable;
+ }
+
+ public final String getName() {
+ return name;
+ }
+
+ public final long getPullCount() {
+ return pullCount;
+ }
+
+ public final String getVersion() {
+ return version;
+ }
+
+ public final boolean isStable() {
+ return stable;
+ }
+}
diff --git a/src/main/java/io/linuxserver/fleet/v2/types/api/external/ExternalApiResponse.java b/src/main/java/io/linuxserver/fleet/v2/types/api/external/ExternalApiResponse.java
new file mode 100644
index 0000000..37eeaac
--- /dev/null
+++ b/src/main/java/io/linuxserver/fleet/v2/types/api/external/ExternalApiResponse.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2020 LinuxServer.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package io.linuxserver.fleet.v2.types.api.external;
+
+public class ExternalApiResponse {
+
+ private ApiStatus status;
+ private T data;
+
+ public ExternalApiResponse(final ApiStatus status, final T data) {
+ this.status = status;
+ this.data = data;
+ }
+
+ public final ApiStatus getStatus() {
+ return status;
+ }
+
+ public final T getData() {
+ return data;
+ }
+
+ public enum ApiStatus {
+ OK, Error
+ }
+}
diff --git a/src/main/java/io/linuxserver/fleet/v2/web/WebRouteController.java b/src/main/java/io/linuxserver/fleet/v2/web/WebRouteController.java
index 7119529..426bb6a 100644
--- a/src/main/java/io/linuxserver/fleet/v2/web/WebRouteController.java
+++ b/src/main/java/io/linuxserver/fleet/v2/web/WebRouteController.java
@@ -123,6 +123,9 @@ public class WebRouteController {
put(apiController::runSchedule, roles(AppRole.Admin));
});
});
+
+ final LegacyExternalApiController externalApiController = new LegacyExternalApiController(app);
+ get(Locations.Api.Images, externalApiController::fetchAllImages, roles(AppRole.Anyone));
});
Runtime.getRuntime().addShutdownHook(new Thread(webInstance::stop));
diff --git a/src/main/java/io/linuxserver/fleet/v2/web/routes/LegacyExternalApiController.java b/src/main/java/io/linuxserver/fleet/v2/web/routes/LegacyExternalApiController.java
new file mode 100644
index 0000000..497c9ec
--- /dev/null
+++ b/src/main/java/io/linuxserver/fleet/v2/web/routes/LegacyExternalApiController.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2019 LinuxServer.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package io.linuxserver.fleet.v2.web.routes;
+
+import io.javalin.http.Context;
+import io.linuxserver.fleet.core.FleetAppController;
+import io.linuxserver.fleet.v2.service.AbstractAppService;
+import io.linuxserver.fleet.v2.types.Image;
+import io.linuxserver.fleet.v2.types.Repository;
+import io.linuxserver.fleet.v2.types.api.external.AllImagesExternalApiResponse;
+import io.linuxserver.fleet.v2.types.api.external.ExternalApiResponse;
+import io.linuxserver.fleet.v2.web.ApiException;
+
+import java.util.List;
+
+public class LegacyExternalApiController extends AbstractAppService {
+
+ public LegacyExternalApiController(final FleetAppController controller) {
+ super(controller);
+ }
+
+ public final void fetchAllImages(final Context ctx) {
+
+ try {
+
+ final AllImagesExternalApiResponse responseData = new AllImagesExternalApiResponse();
+
+ final List repositories = getController().getImageService().getAllShownRepositories();
+ for (Repository repository : repositories) {
+
+ for (Image image : repository.getImages()) {
+
+ responseData.addImage(image.getRepositoryName(),
+ image.getName(),
+ image.getPullCount(),
+ image.getLatestTag().getVersion(),
+ image.isStable());
+ }
+ }
+
+ ctx.json(new ExternalApiResponse<>(ExternalApiResponse.ApiStatus.OK, responseData));
+
+ } catch (IllegalArgumentException e) {
+ throw new ApiException(e.getMessage(), e);
+ }
+ }
+}
diff --git a/src/main/resources/version.properties b/src/main/resources/version.properties
index 2e46667..7d81db2 100644
--- a/src/main/resources/version.properties
+++ b/src/main/resources/version.properties
@@ -1,5 +1,5 @@
-#Sun Apr 26 14:55:33 BST 2020
-app.build.date=2020-04-26T14\:55\:33
+#Sun Apr 26 20:17:59 BST 2020
+app.build.date=2020-04-26T20\:17\:59
app.build.os=Linux
app.build.user=josh
-app.version=2.0.0
+app.version=2.0.1