DisablePlugin disables a plugin. swagger:operation POST /plugin/{id}/disable plugin disablePlugin Disable a plugin. --- consumes: [application/json] produces: [application/json] parameters: - name: id in: path description: the plugin id required: true type: integer format: int6
(ctx *gin.Context)
| 180 | // schema: |
| 181 | // $ref: "#/definitions/Error" |
| 182 | func (c *PluginAPI) DisablePlugin(ctx *gin.Context) { |
| 183 | withID(ctx, "id", func(id uint) { |
| 184 | conf, err := c.DB.GetPluginConfByID(id) |
| 185 | if success := successOrAbort(ctx, 500, err); !success { |
| 186 | return |
| 187 | } |
| 188 | if conf == nil || !isPluginOwner(ctx, conf) { |
| 189 | ctx.AbortWithError(404, errors.New("unknown plugin")) |
| 190 | return |
| 191 | } |
| 192 | _, err = c.Manager.Instance(id) |
| 193 | if err != nil { |
| 194 | ctx.AbortWithError(404, errors.New("plugin instance not found")) |
| 195 | return |
| 196 | } |
| 197 | if err := c.Manager.SetPluginEnabled(id, false); err == plugin.ErrAlreadyEnabledOrDisabled { |
| 198 | ctx.AbortWithError(400, err) |
| 199 | } else if err != nil { |
| 200 | ctx.AbortWithError(500, err) |
| 201 | } |
| 202 | }) |
| 203 | } |
| 204 | |
| 205 | // GetDisplay get display info for Displayer plugin. |
| 206 | // swagger:operation GET /plugin/{id}/display plugin getPluginDisplay |