()
| 194 | } |
| 195 | |
| 196 | func (s *Server) registerWebhooks() { |
| 197 | huma.Register(s.API, huma.Operation{ |
| 198 | OperationID: "createWebhook", Method: http.MethodPost, Path: "/v1/webhooks", |
| 199 | Summary: "Create a webhook", Tags: []string{"webhooks"}, |
| 200 | Security: []map[string][]string{{"bearer": {}}}, DefaultStatus: http.StatusCreated, |
| 201 | }, s.handleCreateWebhook) |
| 202 | |
| 203 | huma.Register(s.API, huma.Operation{ |
| 204 | OperationID: "listWebhooks", Method: http.MethodGet, Path: "/v1/webhooks", |
| 205 | Summary: "List webhooks", Tags: []string{"webhooks"}, |
| 206 | Security: []map[string][]string{{"bearer": {}}}, |
| 207 | }, s.handleListWebhooks) |
| 208 | |
| 209 | huma.Register(s.API, huma.Operation{ |
| 210 | OperationID: "getWebhook", Method: http.MethodGet, Path: "/v1/webhooks/{id}", |
| 211 | Summary: "Get a webhook", Tags: []string{"webhooks"}, |
| 212 | Security: []map[string][]string{{"bearer": {}}}, |
| 213 | }, s.handleGetWebhook) |
| 214 | |
| 215 | huma.Register(s.API, huma.Operation{ |
| 216 | OperationID: "deleteWebhook", Method: http.MethodDelete, Path: "/v1/webhooks/{id}", |
| 217 | Summary: "Delete a webhook", Tags: []string{"webhooks"}, |
| 218 | Security: []map[string][]string{{"bearer": {}}}, DefaultStatus: http.StatusNoContent, |
| 219 | }, s.handleDeleteWebhook) |
| 220 | |
| 221 | huma.Register(s.API, huma.Operation{ |
| 222 | OperationID: "updateWebhook", Method: http.MethodPatch, Path: "/v1/webhooks/{id}", |
| 223 | Summary: "Update a webhook", Tags: []string{"webhooks"}, |
| 224 | Description: "Partial update. url/events/filters are full-replace when present. Re-enabling within the auto-disable cooldown returns 409.", |
| 225 | Security: []map[string][]string{{"bearer": {}}}, |
| 226 | }, s.handleUpdateWebhook) |
| 227 | |
| 228 | huma.Register(s.API, huma.Operation{ |
| 229 | OperationID: "rotateWebhookSecret", Method: http.MethodPost, Path: "/v1/webhooks/{id}/rotate-secret", |
| 230 | Summary: "Rotate a webhook signing secret", Tags: []string{"webhooks"}, |
| 231 | Description: "Mint a new signing secret; the previous one stays valid for a 24h grace window. Returns the new secret (shown once). Honors Idempotency-Key so a retried rotate replays the same secret instead of rotating twice.", |
| 232 | Security: []map[string][]string{{"bearer": {}}}, |
| 233 | }, s.handleRotateWebhookSecret) |
| 234 | |
| 235 | huma.Register(s.API, huma.Operation{ |
| 236 | OperationID: "testWebhook", Method: http.MethodPost, Path: "/v1/webhooks/{id}/test", |
| 237 | Summary: "Fire a synthetic event", Tags: []string{"webhooks"}, |
| 238 | Description: "Schedule a one-off synthetic delivery to this webhook for development. Returns the delivery id.", |
| 239 | Security: []map[string][]string{{"bearer": {}}}, |
| 240 | }, s.handleTestWebhook) |
| 241 | |
| 242 | huma.Register(s.API, huma.Operation{ |
| 243 | OperationID: "listWebhookDeliveries", Method: http.MethodGet, Path: "/v1/webhooks/{id}/deliveries", |
| 244 | Summary: "List webhook deliveries", Tags: []string{"webhooks"}, |
| 245 | Description: "The per-webhook delivery log (read-only debug view).", |
| 246 | Security: []map[string][]string{{"bearer": {}}}, |
| 247 | }, s.handleListWebhookDeliveries) |
| 248 | } |
| 249 | |
| 250 | // TestWebhookRequest mirrors the legacy body. |
| 251 | type TestWebhookRequest struct { |
no test coverage detected