(ctx context.Context, in *updateAgentInput)
| 117 | } |
| 118 | |
| 119 | func (s *Server) handleUpdateAgent(ctx context.Context, in *updateAgentInput) (*agentOutput, error) { |
| 120 | // Mutating an agent is account administration — an agent-scoped credential |
| 121 | // must not rename its own agent (Slice 5a hard ceiling), so this is |
| 122 | // account-only even for the bound agent. (Screening posture moved to the |
| 123 | // account-scoped /protection sub-resource; only the display name is left.) |
| 124 | if _, err := s.requireAccountScope(ctx); err != nil { |
| 125 | return nil, err |
| 126 | } |
| 127 | ag, err := s.resolveOwnedAgent(ctx, in.Address) |
| 128 | if err != nil { |
| 129 | return nil, err |
| 130 | } |
| 131 | if in.Body.Name == nil { |
| 132 | return nil, NewError(http.StatusBadRequest, "invalid_request", "no recognized fields in request") |
| 133 | } |
| 134 | if s.deps.UpdateAgentName == nil { |
| 135 | return nil, NewError(http.StatusInternalServerError, "internal_error", "update unavailable") |
| 136 | } |
| 137 | if err := s.deps.UpdateAgentName(ctx, ag.ID, ag.UserID, *in.Body.Name); err != nil { |
| 138 | return nil, NewError(http.StatusBadRequest, "invalid_request", err.Error()) |
| 139 | } |
| 140 | |
| 141 | // Re-read for the authoritative post-update state (ag.ID is the email). |
| 142 | updated, err := s.deps.GetAgent(ctx, ag.ID) |
| 143 | if err != nil || updated == nil { |
| 144 | return nil, NewError(http.StatusInternalServerError, "internal_error", "failed to reload agent") |
| 145 | } |
| 146 | return &agentOutput{Body: agentViewFromIdentity(updated)}, nil |
| 147 | } |
| 148 | |
| 149 | type deleteAgentOutput struct{} |
| 150 |
nothing calls this directly
no test coverage detected