-
Notifications
You must be signed in to change notification settings - Fork 21
/
handler_inference_delete.go
48 lines (40 loc) · 1.32 KB
/
handler_inference_delete.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package server
import (
"errors"
"net/http"
"github.com/gin-gonic/gin"
"github.com/tensorchord/openmodelz/agent/api/types"
)
// @Summary Delete the inferences.
// @Description Delete the inferences.
// @Tags inference
// @Accept json
// @Produce json
// @Param request body types.DeleteFunctionRequest true "query params"
// @Param namespace query string true "Namespace" example("modelz-d3524a71-c17c-4c92-8faf-8603f02f4713")
// @Success 202 {object} types.DeleteFunctionRequest
// @Router /system/inferences [delete]
func (s *Server) handleInferenceDelete(c *gin.Context) error {
event := types.DeploymentDeleteEvent
var req types.DeleteFunctionRequest
if err := c.ShouldBindJSON(&req); err != nil {
return NewError(http.StatusBadRequest, err, event)
}
namespace := c.Query("namespace")
if namespace == "" {
return NewError(
http.StatusBadRequest,
errors.New("namespace is required"), event)
}
if req.FunctionName == "" {
return NewError(
http.StatusBadRequest,
errors.New("function name is required"), event)
}
if err := s.runtime.InferenceDelete(c.Request.Context(),
namespace, req.FunctionName, s.config.Ingress.Namespace, event); err != nil {
return errFromErrDefs(err, event)
}
c.JSON(http.StatusAccepted, req)
return nil
}