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

Method GetAIProviderKeysByProviderIDs

coderd/database/queries.sql.go:294–322  ·  view source on GitHub ↗

Returns all keys for the requested providers, ordered by provider then created_at ASC so callers can select the oldest non-empty key per provider without issuing N queries.

(ctx context.Context, providerIds []uuid.UUID)

Source from the content-addressed store, hash-verified

292// Returns all keys for the requested providers, ordered by provider then created_at ASC
293// so callers can select the oldest non-empty key per provider without issuing N queries.
294func (q *sqlQuerier) GetAIProviderKeysByProviderIDs(ctx context.Context, providerIds []uuid.UUID) ([]AIProviderKey, error) {
295 rows, err := q.db.QueryContext(ctx, getAIProviderKeysByProviderIDs, pq.Array(providerIds))
296 if err != nil {
297 return nil, err
298 }
299 defer rows.Close()
300 var items []AIProviderKey
301 for rows.Next() {
302 var i AIProviderKey
303 if err := rows.Scan(
304 &i.ID,
305 &i.ProviderID,
306 &i.APIKey,
307 &i.ApiKeyKeyID,
308 &i.CreatedAt,
309 &i.UpdatedAt,
310 ); err != nil {
311 return nil, err
312 }
313 items = append(items, i)
314 }
315 if err := rows.Close(); err != nil {
316 return nil, err
317 }
318 if err := rows.Err(); err != nil {
319 return nil, err
320 }
321 return items, nil
322}
323
324const insertAIProviderKey = `-- name: InsertAIProviderKey :one
325INSERT INTO ai_provider_keys (

Callers

nothing calls this directly

Calls 5

QueryContextMethod · 0.80
ErrMethod · 0.80
CloseMethod · 0.65
NextMethod · 0.65
ScanMethod · 0.45

Tested by

no test coverage detected