diff --git a/api/app_management/openapi.yaml b/api/app_management/openapi.yaml index 8d65d6ad..95b586af 100644 --- a/api/app_management/openapi.yaml +++ b/api/app_management/openapi.yaml @@ -304,6 +304,21 @@ paths: $ref: "#/components/responses/ComposeAppStoreInfoListsOK" "500": $ref: "#/components/responses/ResponseInternalServerError" + + /apps/upgradable: + get: + summary: Get the list of upgradable apps from installed app. + description: | + (TODO) + operationId: upgradableAppList + tags: + - AppStore methods + responses: + "200": + $ref: "#/components/responses/UpgradableAppListOK" + "500": + $ref: "#/components/responses/ResponseInternalServerError" + /apps/{id}: get: @@ -482,7 +497,7 @@ paths: patch: summary: Update container images of compose app to match the compose app in AppStore. description: | - TODO - add description + Update a ComposeApp to the latest version of the app in the AppStore. operationId: updateComposeApp tags: - Compose methods @@ -928,6 +943,18 @@ components: items: $ref: "#/components/schemas/GlobalSetting" + UpgradableAppListOK: + description: OK + content: + application/json: + schema: + allOf: + - $ref: "#/components/schemas/BaseResponse" + - properties: + data: + type: array + items: + $ref: "#/components/schemas/UpgradableAppInfo" AppStoreListOK: description: OK content: @@ -1444,6 +1471,31 @@ components: type: string example: "8384" + UpgradableAppInfo: + title: Upgradable app info + description: |- + Schema for `UpgradableAppListOK` response. + required: + - title + - version + - store_app_id + - status + properties: + title: + type: string + example: "{en_US:\"Syncthing\"}" + version: + description: current version of the installed app + type: string + example: "v10.2" + store_app_id: + $ref: "#/components/schemas/StoreAppID" + status: + type: string + enum: + - "idle" + - "updating" + AppStoreInfo: title: StoreInfo of an app description: |- diff --git a/route/v2/appstore.go b/route/v2/appstore.go index d57342d3..5953a86b 100644 --- a/route/v2/appstore.go +++ b/route/v2/appstore.go @@ -363,3 +363,30 @@ func FilterCatalogByAppStoreID(catalog map[string]*service.ComposeApp, appStoreI return lo.Contains(appStoreIDs, storeAppID) }) } + +func (a *AppManagement) UpgradableAppList(ctx echo.Context) error { + composeApps, err := service.MyService.Compose().List(ctx.Request().Context()) + + var upgradableAppList []codegen.UpgradableAppInfo = []codegen.UpgradableAppInfo{} + if err != nil { + message := err.Error() + return ctx.JSON(http.StatusInternalServerError, codegen.ResponseInternalServerError{Message: &message}) + } + for id, composeApp := range composeApps { + if composeApp == nil { + continue + } + + if composeApp.IsUpdateAvailable() { + upgradableAppList = append(upgradableAppList, codegen.UpgradableAppInfo{ + Title: composeApp.Name, + Version: "", + StoreAppID: lo.ToPtr(id), + Status: "upgradable", + }) + } + } + return ctx.JSON(http.StatusNotImplemented, codegen.ResponseOK{ + Message: lo.ToPtr("not implemented"), + }) +}