(c *gin.Context)
| 39 | ) |
| 40 | |
| 41 | func createDB(c *gin.Context) { |
| 42 | r := struct { |
| 43 | NodeCount uint16 `json:"node" form:"node" binding:"gt=0"` |
| 44 | }{} |
| 45 | |
| 46 | if err := c.ShouldBind(&r); err != nil { |
| 47 | abortWithError(c, http.StatusBadRequest, err) |
| 48 | return |
| 49 | } |
| 50 | |
| 51 | developer := getDeveloperID(c) |
| 52 | |
| 53 | p, err := model.GetMainAccount(model.GetDB(c), developer) |
| 54 | if err != nil { |
| 55 | _ = c.Error(err) |
| 56 | abortWithError(c, http.StatusBadRequest, ErrNoMainAccount) |
| 57 | return |
| 58 | } |
| 59 | |
| 60 | // run task |
| 61 | taskID, err := getTaskManager(c).New(model.TaskCreateDB, developer, p.ID, gin.H{ |
| 62 | "node_count": r.NodeCount, |
| 63 | }) |
| 64 | if err != nil { |
| 65 | _ = c.Error(err) |
| 66 | abortWithError(c, http.StatusInternalServerError, ErrCreateTaskFailed) |
| 67 | return |
| 68 | } |
| 69 | |
| 70 | responseWithData(c, http.StatusOK, gin.H{ |
| 71 | "task_id": taskID, |
| 72 | }) |
| 73 | } |
| 74 | |
| 75 | func topUp(c *gin.Context) { |
| 76 | r := struct { |
nothing calls this directly
no test coverage detected