Skip to content

Commit cce9afa

Browse files
authored
feat: add api endpoint to fecth filename of backup (#273)
1 parent a6bddec commit cce9afa

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

docs/rest_api.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,20 @@ For other part, we are using the GraphQL API. Check the [GraphQL API Documentati
8989

9090
---
9191

92+
### Backup Filename API
93+
94+
**GET** /persistent-volume/backup/:id/filename
95+
96+
**Example Response**
97+
98+
**200 OK**
99+
- Filename will be sent as response text
100+
101+
**Any other status code**
102+
- The filename will be failed to send
103+
104+
---
105+
92106
### Upload File for Restore API
93107
**POST** /persistent-volume/restore/<restore_id>/upload
94108

swiftwave_service/rest/persistent_volume.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,23 @@ func (server *Server) downloadPersistentVolumeBackup(c echo.Context) error {
8181
}
8282
}
8383

84+
// GET /persistent-volume/backup/:id/filename
85+
func (server *Server) getPersistentVolumeBackupFileName(c echo.Context) error {
86+
idStr := c.Param("id")
87+
// convert id to uint
88+
id, err := strconv.Atoi(idStr)
89+
if err != nil {
90+
return c.String(400, "Invalid id")
91+
}
92+
// fetch persistent volume backup
93+
var persistentVolumeBackup core.PersistentVolumeBackup
94+
err = persistentVolumeBackup.FindById(c.Request().Context(), server.ServiceManager.DbClient, uint(id))
95+
if err != nil {
96+
return c.String(500, "Internal server error")
97+
}
98+
return c.String(200, persistentVolumeBackup.File)
99+
}
100+
84101
// POST /persistent-volume/restore/:id/upload
85102
func (server *Server) uploadPersistentVolumeRestoreFile(c echo.Context) error {
86103
file, err := c.FormFile("file")

swiftwave_service/rest/server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ func (server *Server) initiateProjectRoutes(e *echo.Echo) {
2020
e.POST("/upload/code", server.uploadTarFile)
2121
// Initiating Routes for PersistentVolume
2222
e.GET("/persistent-volume/backup/:id/download", server.downloadPersistentVolumeBackup)
23+
e.GET("/persistent-volume/backup/:id/filename", server.getPersistentVolumeBackupFileName)
2324
e.POST("/persistent-volume/restore/:id/upload", server.uploadPersistentVolumeRestoreFile)
2425
// Initiating Routes for Webhook
2526
e.Any("/webhook/redeploy-app/:app-id/:webhook-token", server.redeployApp)

0 commit comments

Comments
 (0)