Skip to content

Commit b20fd6f

Browse files
authored
chore: graduate aibridge API out of experimental (#20523)
<!-- If you have used AI to produce some or all of this PR, please ensure you have read our [AI Contribution guidelines](https://coder.com/docs/about/contributing/AI_CONTRIBUTING) before submitting. -->
1 parent 2294c55 commit b20fd6f

File tree

8 files changed

+22
-28
lines changed

8 files changed

+22
-28
lines changed

coderd/apidoc/docs.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codersdk/aibridge.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ func (f AIBridgeListInterceptionsFilter) asRequestOption() RequestOption {
113113

114114
// AIBridgeListInterceptions returns AIBridge interceptions with the given
115115
// filter.
116-
func (c *ExperimentalClient) AIBridgeListInterceptions(ctx context.Context, filter AIBridgeListInterceptionsFilter) (AIBridgeListInterceptionsResponse, error) {
117-
res, err := c.Request(ctx, http.MethodGet, "/api/experimental/aibridge/interceptions", nil, filter.asRequestOption(), filter.Pagination.asRequestOption(), filter.Pagination.asRequestOption())
116+
func (c *Client) AIBridgeListInterceptions(ctx context.Context, filter AIBridgeListInterceptionsFilter) (AIBridgeListInterceptionsResponse, error) {
117+
res, err := c.Request(ctx, http.MethodGet, "/api/v2/aibridge/interceptions", nil, filter.asRequestOption(), filter.Pagination.asRequestOption(), filter.Pagination.asRequestOption())
118118
if err != nil {
119119
return AIBridgeListInterceptionsResponse{}, err
120120
}

docs/reference/api/aibridge.md

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

enterprise/aibridged/aibridged.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ var _ io.Closer = &Server{}
1919

2020
// Server provides the AI Bridge functionality.
2121
// It is responsible for:
22-
// - receiving requests on /api/experimental/aibridged/* // TODO: update endpoint once out of experimental
22+
// - receiving requests on /api/v2/aibridged/*
2323
// - manipulating the requests
2424
// - relaying requests to upstream AI services and relaying responses to caller
2525
//

enterprise/coderd/aibridge.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const (
3636
// @Param after_id query string false "Cursor pagination after ID (cannot be used with offset)"
3737
// @Param offset query int false "Offset pagination (cannot be used with after_id)"
3838
// @Success 200 {object} codersdk.AIBridgeListInterceptionsResponse
39-
// @Router /api/experimental/aibridge/interceptions [get]
39+
// @Router /aibridge/interceptions [get]
4040
func (api *API) aiBridgeListInterceptions(rw http.ResponseWriter, r *http.Request) {
4141
ctx := r.Context()
4242
apiKey := httpmw.APIKey(r)

enterprise/coderd/aibridge_test.go

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ func TestAIBridgeListInterceptions(t *testing.T) {
3636
Features: license.Features{},
3737
},
3838
})
39-
experimentalClient := codersdk.NewExperimentalClient(client)
4039

4140
ctx := testutil.Context(t, testutil.WaitLong)
42-
_, err := experimentalClient.AIBridgeListInterceptions(ctx, codersdk.AIBridgeListInterceptionsFilter{})
41+
//nolint:gocritic // Owner role is irrelevant here.
42+
_, err := client.AIBridgeListInterceptions(ctx, codersdk.AIBridgeListInterceptionsFilter{})
4343
var sdkErr *codersdk.Error
4444
require.ErrorAs(t, err, &sdkErr)
4545
require.Equal(t, http.StatusForbidden, sdkErr.StatusCode())
@@ -59,9 +59,9 @@ func TestAIBridgeListInterceptions(t *testing.T) {
5959
},
6060
},
6161
})
62-
experimentalClient := codersdk.NewExperimentalClient(client)
6362
ctx := testutil.Context(t, testutil.WaitLong)
64-
res, err := experimentalClient.AIBridgeListInterceptions(ctx, codersdk.AIBridgeListInterceptionsFilter{})
63+
//nolint:gocritic // Owner role is irrelevant here.
64+
res, err := client.AIBridgeListInterceptions(ctx, codersdk.AIBridgeListInterceptionsFilter{})
6565
require.NoError(t, err)
6666
require.Empty(t, res.Results)
6767
})
@@ -79,7 +79,6 @@ func TestAIBridgeListInterceptions(t *testing.T) {
7979
},
8080
},
8181
})
82-
experimentalClient := codersdk.NewExperimentalClient(client)
8382
ctx := testutil.Context(t, testutil.WaitLong)
8483

8584
user1, err := client.User(ctx, codersdk.Me)
@@ -140,7 +139,7 @@ func TestAIBridgeListInterceptions(t *testing.T) {
140139
i1SDK := db2sdk.AIBridgeInterception(i1, user1Visible, []database.AIBridgeTokenUsage{i1tok2, i1tok1}, []database.AIBridgeUserPrompt{i1up2, i1up1}, []database.AIBridgeToolUsage{i1tool2, i1tool1})
141140
i2SDK := db2sdk.AIBridgeInterception(i2, user2Visible, nil, nil, nil)
142141

143-
res, err := experimentalClient.AIBridgeListInterceptions(ctx, codersdk.AIBridgeListInterceptionsFilter{})
142+
res, err := client.AIBridgeListInterceptions(ctx, codersdk.AIBridgeListInterceptionsFilter{})
144143
require.NoError(t, err)
145144
require.Len(t, res.Results, 2)
146145
require.Equal(t, i2SDK.ID, res.Results[0].ID)
@@ -190,7 +189,6 @@ func TestAIBridgeListInterceptions(t *testing.T) {
190189
},
191190
},
192191
})
193-
experimentalClient := codersdk.NewExperimentalClient(client)
194192
ctx := testutil.Context(t, testutil.WaitLong)
195193

196194
allInterceptionIDs := make([]uuid.UUID, 0, 20)
@@ -221,7 +219,7 @@ func TestAIBridgeListInterceptions(t *testing.T) {
221219
}
222220

223221
// Try to fetch with an invalid limit.
224-
res, err := experimentalClient.AIBridgeListInterceptions(ctx, codersdk.AIBridgeListInterceptionsFilter{
222+
res, err := client.AIBridgeListInterceptions(ctx, codersdk.AIBridgeListInterceptionsFilter{
225223
Pagination: codersdk.Pagination{
226224
Limit: 1001,
227225
},
@@ -232,7 +230,7 @@ func TestAIBridgeListInterceptions(t *testing.T) {
232230
require.Empty(t, res.Results)
233231

234232
// Try to fetch with both after_id and offset pagination.
235-
res, err = experimentalClient.AIBridgeListInterceptions(ctx, codersdk.AIBridgeListInterceptionsFilter{
233+
res, err = client.AIBridgeListInterceptions(ctx, codersdk.AIBridgeListInterceptionsFilter{
236234
Pagination: codersdk.Pagination{
237235
AfterID: allInterceptionIDs[0],
238236
Offset: 1,
@@ -265,7 +263,7 @@ func TestAIBridgeListInterceptions(t *testing.T) {
265263
} else {
266264
pagination.Offset = len(interceptionIDs)
267265
}
268-
res, err := experimentalClient.AIBridgeListInterceptions(ctx, codersdk.AIBridgeListInterceptionsFilter{
266+
res, err := client.AIBridgeListInterceptions(ctx, codersdk.AIBridgeListInterceptionsFilter{
269267
Pagination: pagination,
270268
})
271269
require.NoError(t, err)
@@ -305,11 +303,9 @@ func TestAIBridgeListInterceptions(t *testing.T) {
305303
},
306304
},
307305
})
308-
adminExperimentalClient := codersdk.NewExperimentalClient(adminClient)
309306
ctx := testutil.Context(t, testutil.WaitLong)
310307

311308
secondUserClient, secondUser := coderdtest.CreateAnotherUser(t, adminClient, firstUser.OrganizationID)
312-
secondUserExperimentalClient := codersdk.NewExperimentalClient(secondUserClient)
313309

314310
now := dbtime.Now()
315311
i1 := dbgen.AIBridgeInterception(t, db, database.InsertAIBridgeInterceptionParams{
@@ -322,15 +318,15 @@ func TestAIBridgeListInterceptions(t *testing.T) {
322318
}, &now)
323319

324320
// Admin can see all interceptions.
325-
res, err := adminExperimentalClient.AIBridgeListInterceptions(ctx, codersdk.AIBridgeListInterceptionsFilter{})
321+
res, err := adminClient.AIBridgeListInterceptions(ctx, codersdk.AIBridgeListInterceptionsFilter{})
326322
require.NoError(t, err)
327323
require.EqualValues(t, 2, res.Count)
328324
require.Len(t, res.Results, 2)
329325
require.Equal(t, i1.ID, res.Results[0].ID)
330326
require.Equal(t, i2.ID, res.Results[1].ID)
331327

332328
// Second user can only see their own interceptions.
333-
res, err = secondUserExperimentalClient.AIBridgeListInterceptions(ctx, codersdk.AIBridgeListInterceptionsFilter{})
329+
res, err = secondUserClient.AIBridgeListInterceptions(ctx, codersdk.AIBridgeListInterceptionsFilter{})
334330
require.NoError(t, err)
335331
require.EqualValues(t, 1, res.Count)
336332
require.Len(t, res.Results, 1)
@@ -350,7 +346,6 @@ func TestAIBridgeListInterceptions(t *testing.T) {
350346
},
351347
},
352348
})
353-
experimentalClient := codersdk.NewExperimentalClient(client)
354349
ctx := testutil.Context(t, testutil.WaitLong)
355350

356351
user1, err := client.User(ctx, codersdk.Me)
@@ -500,7 +495,7 @@ func TestAIBridgeListInterceptions(t *testing.T) {
500495
t.Run(tc.name, func(t *testing.T) {
501496
t.Parallel()
502497
ctx := testutil.Context(t, testutil.WaitLong)
503-
res, err := experimentalClient.AIBridgeListInterceptions(ctx, tc.filter)
498+
res, err := client.AIBridgeListInterceptions(ctx, tc.filter)
504499
require.NoError(t, err)
505500
require.EqualValues(t, len(tc.want), res.Count)
506501
// We just compare UUID strings for the sake of this test.
@@ -530,7 +525,6 @@ func TestAIBridgeListInterceptions(t *testing.T) {
530525
},
531526
},
532527
})
533-
experimentalClient := codersdk.NewExperimentalClient(client)
534528

535529
// No need to insert any test data, we're just testing the filter
536530
// errors.
@@ -587,7 +581,7 @@ func TestAIBridgeListInterceptions(t *testing.T) {
587581
t.Run(tc.name, func(t *testing.T) {
588582
t.Parallel()
589583
ctx := testutil.Context(t, testutil.WaitLong)
590-
res, err := experimentalClient.AIBridgeListInterceptions(ctx, codersdk.AIBridgeListInterceptionsFilter{
584+
res, err := client.AIBridgeListInterceptions(ctx, codersdk.AIBridgeListInterceptionsFilter{
591585
FilterQuery: tc.q,
592586
})
593587
var sdkErr *codersdk.Error

enterprise/coderd/coderd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ func New(ctx context.Context, options *Options) (_ *API, err error) {
226226
return api.refreshEntitlements(ctx)
227227
}
228228

229-
api.AGPL.ExperimentalHandler.Group(func(r chi.Router) {
229+
api.AGPL.APIHandler.Group(func(r chi.Router) {
230230
r.Route("/aibridge", func(r chi.Router) {
231231
r.Use(api.RequireFeatureMW(codersdk.FeatureAIBridge))
232232
r.Group(func(r chi.Router) {
@@ -243,7 +243,7 @@ func New(ctx context.Context, options *Options) (_ *API, err error) {
243243
})
244244
return
245245
}
246-
http.StripPrefix("/api/experimental/aibridge", api.aibridgedHandler).ServeHTTP(rw, r)
246+
http.StripPrefix("/api/v2/aibridge", api.aibridgedHandler).ServeHTTP(rw, r)
247247
})
248248
})
249249
})

0 commit comments

Comments
 (0)