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)
| 247 | // key per provider; multiple keys are stored to support future |
| 248 | // failover and rotation flows. |
| 249 | func (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 | |
| 279 | const getAIProviderKeysByProviderIDs = `-- name: GetAIProviderKeysByProviderIDs :many |
| 280 | SELECT |
nothing calls this directly
no test coverage detected