GetPlugins returns all plugins a user has. swagger:operation GET /plugin plugin getPlugins Return all plugins. --- consumes: [application/json] produces: [application/json] security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []] responses:
(ctx *gin.Context)
| 61 | // schema: |
| 62 | // $ref: "#/definitions/Error" |
| 63 | func (c *PluginAPI) GetPlugins(ctx *gin.Context) { |
| 64 | userID := auth.GetUserID(ctx) |
| 65 | plugins, err := c.DB.GetPluginConfByUser(userID) |
| 66 | if success := successOrAbort(ctx, 500, err); !success { |
| 67 | return |
| 68 | } |
| 69 | result := make([]model.PluginConfExternal, 0) |
| 70 | for _, conf := range plugins { |
| 71 | if inst, err := c.Manager.Instance(conf.ID); err == nil { |
| 72 | info := c.Manager.PluginInfo(conf.ModulePath) |
| 73 | result = append(result, model.PluginConfExternal{ |
| 74 | ID: conf.ID, |
| 75 | Name: info.String(), |
| 76 | Token: conf.Token, |
| 77 | ModulePath: conf.ModulePath, |
| 78 | Author: info.Author, |
| 79 | Website: info.Website, |
| 80 | License: info.License, |
| 81 | Enabled: conf.Enabled, |
| 82 | Capabilities: inst.Supports().Strings(), |
| 83 | }) |
| 84 | } |
| 85 | } |
| 86 | ctx.JSON(200, result) |
| 87 | } |
| 88 | |
| 89 | // EnablePlugin enables a plugin. |
| 90 | // swagger:operation POST /plugin/{id}/enable plugin enablePlugin |