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

Method GetAIProviderKeysByProviderID

coderd/database/queries.sql.go:249–277  ·  view source on GitHub ↗

Returns all keys for a provider, ordered by created_at ASC so the oldest key is returned first. AI Bridge currently uses the oldest key per provider; multiple keys are stored to support future failover and rotation flows.

(ctx context.Context, providerID uuid.UUID)

Source from the content-addressed store, hash-verified

247// key per provider; multiple keys are stored to support future
248// failover and rotation flows.
249func (q *sqlQuerier) GetAIProviderKeysByProviderID(ctx context.Context, providerID uuid.UUID) ([]AIProviderKey, error) {
250 rows, err := q.db.QueryContext(ctx, getAIProviderKeysByProviderID, providerID)
251 if err != nil {
252 return nil, err
253 }
254 defer rows.Close()
255 var items []AIProviderKey
256 for rows.Next() {
257 var i AIProviderKey
258 if err := rows.Scan(
259 &i.ID,
260 &i.ProviderID,
261 &i.APIKey,
262 &i.ApiKeyKeyID,
263 &i.CreatedAt,
264 &i.UpdatedAt,
265 ); err != nil {
266 return nil, err
267 }
268 items = append(items, i)
269 }
270 if err := rows.Close(); err != nil {
271 return nil, err
272 }
273 if err := rows.Err(); err != nil {
274 return nil, err
275 }
276 return items, nil
277}
278
279const getAIProviderKeysByProviderIDs = `-- name: GetAIProviderKeysByProviderIDs :many
280SELECT

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