MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / HandleDeleteAgent

Method HandleDeleteAgent

internal/auth/auth.go:612–640  ·  view source on GitHub ↗

HandleDeleteAgent deletes an agent owned by the authenticated user.

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

610
611// HandleDeleteAgent deletes an agent owned by the authenticated user.
612func (ua *UserAuth) HandleDeleteAgent(w http.ResponseWriter, r *http.Request) {
613 user := ua.AuthenticateRequest(r)
614 if user == nil {
615 http.Error(w, "not authenticated", http.StatusUnauthorized)
616 return
617 }
618
619 // Extract agent email from URL path
620 path := strings.TrimPrefix(r.URL.Path, "/api/dashboard/agents/")
621 email, _ := url.PathUnescape(path)
622 email = identity.NormalizeEmail(email)
623 if email == "" {
624 http.Error(w, "agent email required", http.StatusBadRequest)
625 return
626 }
627
628 agent, err := ua.store.GetAgentByEmail(r.Context(), email)
629 if err != nil {
630 http.Error(w, "agent not found", http.StatusNotFound)
631 return
632 }
633
634 if err := ua.store.DeleteAgent(r.Context(), agent.ID, user.ID); err != nil {
635 http.Error(w, err.Error(), http.StatusForbidden)
636 return
637 }
638
639 w.WriteHeader(http.StatusOK)
640}
641
642// HandleUpdateAgent updates an agent owned by the authenticated user.
643func (ua *UserAuth) HandleUpdateAgent(w http.ResponseWriter, r *http.Request) {

Callers

nothing calls this directly

Calls 6

AuthenticateRequestMethod · 0.95
NormalizeEmailFunction · 0.92
DeleteAgentMethod · 0.80
GetAgentByEmailMethod · 0.65
ErrorMethod · 0.45
WriteHeaderMethod · 0.45

Tested by

no test coverage detected