aiBridgeListClients returns all AI Bridge clients a user can see. @Summary List AI Bridge clients @ID list-ai-bridge-clients @Security CoderSessionToken @Produce json @Tags AI Bridge @Success 200 {array} string @Router /api/v2/aibridge/clients [get]
(rw http.ResponseWriter, r *http.Request)
| 590 | // @Success 200 {array} string |
| 591 | // @Router /api/v2/aibridge/clients [get] |
| 592 | func (api *API) aiBridgeListClients(rw http.ResponseWriter, r *http.Request) { |
| 593 | ctx := r.Context() |
| 594 | |
| 595 | page, ok := coderd.ParsePagination(rw, r) |
| 596 | if !ok { |
| 597 | return |
| 598 | } |
| 599 | |
| 600 | if page.Limit == 0 { |
| 601 | page.Limit = defaultListClientsLimit |
| 602 | } |
| 603 | |
| 604 | if page.Limit > maxListClientsLimit || page.Limit < 1 { |
| 605 | httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{ |
| 606 | Message: "Invalid pagination limit value.", |
| 607 | Detail: fmt.Sprintf("Pagination limit must be in range (0, %d]", maxListClientsLimit), |
| 608 | }) |
| 609 | return |
| 610 | } |
| 611 | |
| 612 | queryStr := r.URL.Query().Get("q") |
| 613 | filter, errs := searchquery.AIBridgeClients(queryStr, page) |
| 614 | |
| 615 | if len(errs) > 0 { |
| 616 | httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{ |
| 617 | Message: "Invalid AI Bridge clients search query.", |
| 618 | Validations: errs, |
| 619 | }) |
| 620 | return |
| 621 | } |
| 622 | |
| 623 | clients, err := api.Database.ListAIBridgeClients(ctx, filter) |
| 624 | if err != nil { |
| 625 | httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{ |
| 626 | Message: "Internal error getting AI Bridge clients.", |
| 627 | Detail: err.Error(), |
| 628 | }) |
| 629 | return |
| 630 | } |
| 631 | |
| 632 | httpapi.Write(ctx, rw, http.StatusOK, clients) |
| 633 | } |
| 634 | |
| 635 | // validateInterceptionCursor checks that a pagination cursor refers to an |
| 636 | // existing interception. When sessionID is non-empty the interception must |
nothing calls this directly
no test coverage detected