MCPcopy Index your code
hub / github.com/coder/coder / aiBridgeListClients

Method aiBridgeListClients

enterprise/coderd/aibridge.go:592–633  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

590// @Success 200 {array} string
591// @Router /api/v2/aibridge/clients [get]
592func (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

Callers

nothing calls this directly

Calls 7

ParsePaginationFunction · 0.92
WriteFunction · 0.92
AIBridgeClientsFunction · 0.92
ContextMethod · 0.65
GetMethod · 0.65
ListAIBridgeClientsMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected