b88f88c1a3
- store: DeleteAccount, DeleteTask, UpdateEndpoint (+ cascade/update tests)
- httpapi: DELETE /tasks/{id}, DELETE /tasks/{id}/accounts/{accountId},
PUT /endpoints/{id}; delete guarded with 409 while task running
- orchestrator: enrich WS events with login/host/port/error (test + run + errors)
- web: delete buttons (task, account) with confirm, endpoint edit form,
human-readable event log (source/dest, host:port, error text)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MMHQTtnQtQqL8muAXHr9kd
54 lines
1.5 KiB
Go
54 lines
1.5 KiB
Go
package store
|
|
|
|
import "context"
|
|
|
|
type Endpoint struct {
|
|
ID int64 `json:"id"`
|
|
RoleLabel string `json:"role_label"`
|
|
Host string `json:"host"`
|
|
Port int `json:"port"`
|
|
TLSMode string `json:"tls_mode"`
|
|
}
|
|
|
|
func (s *Store) CreateEndpoint(ctx context.Context, e Endpoint) (int64, error) {
|
|
var id int64
|
|
err := s.Pool.QueryRow(ctx,
|
|
`INSERT INTO endpoints (role_label, host, port, tls_mode)
|
|
VALUES ($1,$2,$3,$4) RETURNING id`,
|
|
e.RoleLabel, e.Host, e.Port, e.TLSMode).Scan(&id)
|
|
return id, err
|
|
}
|
|
|
|
func (s *Store) UpdateEndpoint(ctx context.Context, e Endpoint) error {
|
|
_, err := s.Pool.Exec(ctx,
|
|
`UPDATE endpoints SET role_label=$2, host=$3, port=$4, tls_mode=$5 WHERE id=$1`,
|
|
e.ID, e.RoleLabel, e.Host, e.Port, e.TLSMode)
|
|
return err
|
|
}
|
|
|
|
func (s *Store) GetEndpoint(ctx context.Context, id int64) (Endpoint, error) {
|
|
var e Endpoint
|
|
err := s.Pool.QueryRow(ctx,
|
|
`SELECT id, role_label, host, port, tls_mode FROM endpoints WHERE id=$1`, id).
|
|
Scan(&e.ID, &e.RoleLabel, &e.Host, &e.Port, &e.TLSMode)
|
|
return e, err
|
|
}
|
|
|
|
func (s *Store) ListEndpoints(ctx context.Context) ([]Endpoint, error) {
|
|
rows, err := s.Pool.Query(ctx,
|
|
`SELECT id, role_label, host, port, tls_mode FROM endpoints ORDER BY id`)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
out := []Endpoint{}
|
|
for rows.Next() {
|
|
var e Endpoint
|
|
if err := rows.Scan(&e.ID, &e.RoleLabel, &e.Host, &e.Port, &e.TLSMode); err != nil {
|
|
return nil, err
|
|
}
|
|
out = append(out, e)
|
|
}
|
|
return out, rows.Err()
|
|
}
|