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

Method ListAuthorizedAIBridgeModels

coderd/database/modelqueries.go:1025–1052  ·  view source on GitHub ↗
(ctx context.Context, arg ListAIBridgeModelsParams, prepared rbac.PreparedAuthorized)

Source from the content-addressed store, hash-verified

1023}
1024
1025func (q *sqlQuerier) ListAuthorizedAIBridgeModels(ctx context.Context, arg ListAIBridgeModelsParams, prepared rbac.PreparedAuthorized) ([]string, error) {
1026 authorizedFilter, err := prepared.CompileToSQL(ctx, regosql.ConvertConfig{
1027 VariableConverter: regosql.AIBridgeInterceptionConverter(),
1028 })
1029 if err != nil {
1030 return nil, xerrors.Errorf("compile authorized filter: %w", err)
1031 }
1032 filtered, err := insertAuthorizedFilter(listAIBridgeModels, fmt.Sprintf(" AND %s", authorizedFilter))
1033 if err != nil {
1034 return nil, xerrors.Errorf("insert authorized filter: %w", err)
1035 }
1036
1037 query := fmt.Sprintf("-- name: ListAIBridgeModels :many\n%s", filtered)
1038 rows, err := q.db.QueryContext(ctx, query, arg.Model, arg.Offset, arg.Limit)
1039 if err != nil {
1040 return nil, err
1041 }
1042 defer rows.Close()
1043 var items []string
1044 for rows.Next() {
1045 var model string
1046 if err := rows.Scan(&model); err != nil {
1047 return nil, err
1048 }
1049 items = append(items, model)
1050 }
1051 return items, nil
1052}
1053
1054func (q *sqlQuerier) ListAuthorizedAIBridgeClients(ctx context.Context, arg ListAIBridgeClientsParams, prepared rbac.PreparedAuthorized) ([]string, error) {
1055 authorizedFilter, err := prepared.CompileToSQL(ctx, regosql.ConvertConfig{

Callers

nothing calls this directly

Calls 8

insertAuthorizedFilterFunction · 0.85
QueryContextMethod · 0.80
CompileToSQLMethod · 0.65
CloseMethod · 0.65
NextMethod · 0.65
ErrorfMethod · 0.45
ScanMethod · 0.45

Tested by

no test coverage detected