aiBridgeListInterceptions returns all AI Bridge interceptions a user can read. Optional filters with query params. Deprecated: Use /aibridge/sessions instead, which provides richer session-level aggregation including threads and agentic actions. @Summary List AI Bridge interceptions @ID list-ai-br
(rw http.ResponseWriter, r *http.Request)
| 111 | // @Router /api/v2/aibridge/interceptions [get] |
| 112 | // @Deprecated Use /aibridge/sessions instead. |
| 113 | func (api *API) aiBridgeListInterceptions(rw http.ResponseWriter, r *http.Request) { |
| 114 | ctx := r.Context() |
| 115 | apiKey := httpmw.APIKey(r) |
| 116 | |
| 117 | page, ok := coderd.ParsePagination(rw, r) |
| 118 | if !ok { |
| 119 | return |
| 120 | } |
| 121 | if page.AfterID != uuid.Nil && page.Offset != 0 { |
| 122 | httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{ |
| 123 | Message: "Query parameters have invalid values.", |
| 124 | Detail: "Cannot use both after_id and offset pagination in the same request.", |
| 125 | }) |
| 126 | return |
| 127 | } |
| 128 | if page.Limit == 0 { |
| 129 | page.Limit = defaultListInterceptionsLimit |
| 130 | } |
| 131 | if page.Limit > maxListInterceptionsLimit || page.Limit < 1 { |
| 132 | httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{ |
| 133 | Message: "Invalid pagination limit value.", |
| 134 | Detail: fmt.Sprintf("Pagination limit must be in range (0, %d]", maxListInterceptionsLimit), |
| 135 | }) |
| 136 | return |
| 137 | } |
| 138 | |
| 139 | queryStr := r.URL.Query().Get("q") |
| 140 | filter, errs := searchquery.AIBridgeInterceptions(ctx, api.Database, queryStr, page, apiKey.UserID) |
| 141 | if len(errs) > 0 { |
| 142 | httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{ |
| 143 | Message: "Invalid workspace search query.", |
| 144 | Validations: errs, |
| 145 | }) |
| 146 | return |
| 147 | } |
| 148 | |
| 149 | var ( |
| 150 | count int64 |
| 151 | rows []database.ListAIBridgeInterceptionsRow |
| 152 | ) |
| 153 | err := api.Database.InTx(func(db database.Store) error { |
| 154 | // Validate the cursor interception exists and is visible. |
| 155 | if err := validateInterceptionCursor(ctx, db, page.AfterID, "after_id", ""); err != nil { |
| 156 | return err |
| 157 | } |
| 158 | |
| 159 | var err error |
| 160 | // Get the full count of authorized interceptions matching the filter |
| 161 | // for pagination purposes. |
| 162 | count, err = db.CountAIBridgeInterceptions(ctx, database.CountAIBridgeInterceptionsParams{ |
| 163 | StartedAfter: filter.StartedAfter, |
| 164 | StartedBefore: filter.StartedBefore, |
| 165 | InitiatorID: filter.InitiatorID, |
| 166 | Provider: filter.Provider, |
| 167 | ProviderName: filter.ProviderName, |
| 168 | Model: filter.Model, |
| 169 | Client: filter.Client, |
| 170 | }) |
nothing calls this directly
no test coverage detected