Skip to content

Commit

Permalink
chore: add upgradable app list api (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
CorrectRoadH authored Apr 10, 2024
1 parent 6ca7318 commit 1c89f7f
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 1 deletion.
54 changes: 53 additions & 1 deletion api/app_management/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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: |-
Expand Down
27 changes: 27 additions & 0 deletions route/v2/appstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
})
}

0 comments on commit 1c89f7f

Please sign in to comment.