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

Method handlePutProtection

internal/httpapi/protection.go:158–178  ·  view source on GitHub ↗
(ctx context.Context, in *putProtectionInput)

Source from the content-addressed store, hash-verified

156}
157
158func (s *Server) handlePutProtection(ctx context.Context, in *putProtectionInput) (*protectionOutput, error) {
159 if _, err := s.requireAccountScope(ctx); err != nil {
160 return nil, err
161 }
162 ag, err := s.resolveOwnedAgent(ctx, in.Address)
163 if err != nil {
164 return nil, err
165 }
166 if s.deps.UpdateAgentProtection == nil {
167 return nil, NewError(http.StatusInternalServerError, "internal_error", "update unavailable")
168 }
169 cfg := protectionConfigFromView(in.Body)
170 if err := s.deps.UpdateAgentProtection(ctx, ag.ID, ag.UserID, cfg); err != nil {
171 return nil, NewError(http.StatusBadRequest, "invalid_request", err.Error())
172 }
173 updated, err := s.deps.GetAgent(ctx, ag.ID)
174 if err != nil || updated == nil {
175 return nil, NewError(http.StatusInternalServerError, "internal_error", "failed to reload agent")
176 }
177 return &protectionOutput{Body: protectionViewFromIdentity(updated)}, nil
178}

Callers

nothing calls this directly

Calls 7

requireAccountScopeMethod · 0.95
resolveOwnedAgentMethod · 0.95
NewErrorFunction · 0.85
protectionConfigFromViewFunction · 0.85
UpdateAgentProtectionMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected