MCPcopy Create free account
hub / github.com/QuantumNous/new-api / DeleteTaskPluginVersion

Function DeleteTaskPluginVersion

controller/task_plugin.go:358–395  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

356}
357
358func DeleteTaskPluginVersion(c *gin.Context) {
359 key := c.Param("key")
360 version := c.Param("version")
361 plugin, lookupErr := model.GetTaskPluginVersion(key, version)
362 if lookupErr != nil {
363 if errors.Is(lookupErr, gorm.ErrRecordNotFound) {
364 common.ApiErrorMsg(c, "override plugin version not found; factory plugins cannot be deleted")
365 return
366 }
367 common.ApiError(c, lookupErr)
368 return
369 }
370 if plugin.Active && !taskPluginHasFactory(key) {
371 channels, inFlight, usageErr := model.GetTaskPluginUsage(key)
372 if usageErr != nil {
373 common.ApiError(c, usageErr)
374 return
375 }
376 if (len(channels) > 0 || inFlight > 0) && c.Query("force") != "true" {
377 c.JSON(200, gin.H{"success": false, "message": "task plugin is still in use", "data": gin.H{"channels": channels, "in_flight_count": inFlight}})
378 return
379 }
380 }
381 _, err := model.DeleteTaskPluginVersion(key, version)
382 if err != nil {
383 if errors.Is(err, gorm.ErrRecordNotFound) {
384 common.ApiErrorMsg(c, "override plugin version not found; factory plugins cannot be deleted")
385 return
386 }
387 common.ApiError(c, err)
388 return
389 }
390 if err = syncTaskPluginsOnceContext(c.Request.Context()); err != nil {
391 common.ApiError(c, err)
392 return
393 }
394 common.ApiSuccess(c, nil)
395}
396
397type taskPluginActivateRequest struct {
398 Version string `json:"version" binding:"required"`

Calls 9

GetTaskPluginVersionFunction · 0.92
ApiErrorMsgFunction · 0.92
ApiErrorFunction · 0.92
GetTaskPluginUsageFunction · 0.92
DeleteTaskPluginVersionFunction · 0.92
ApiSuccessFunction · 0.92
taskPluginHasFactoryFunction · 0.85
QueryMethod · 0.80