(ctx context.Context, in *putProtectionInput)
| 156 | } |
| 157 | |
| 158 | func (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 | } |
nothing calls this directly
no test coverage detected