mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat(coderd/database): add AI Gateway key auth lookup and last-used queries (#26505)
Adds DB methods`GetAIGatewayKeyIDByHashedSecret` and `UpdateAIGatewayKeyLastUsedAt`. `GetAIGatewayKeyIDByHashedSecret` - returns AI Gateway key ID by hashed secret value. `UpdateAIGatewayKeyLastUsedAt` - updates last used timestamp for given AI Gateway key. Used by standalone AI Gateway for authentication and keeping track of currently used keys.
This commit is contained in:
Generated
+8
@@ -301,6 +301,10 @@ type sqlcQuerier interface {
|
||||
GetAIBridgeTokenUsagesByInterceptionID(ctx context.Context, interceptionID uuid.UUID) ([]AIBridgeTokenUsage, error)
|
||||
GetAIBridgeToolUsagesByInterceptionID(ctx context.Context, interceptionID uuid.UUID) ([]AIBridgeToolUsage, error)
|
||||
GetAIBridgeUserPromptsByInterceptionID(ctx context.Context, interceptionID uuid.UUID) ([]AIBridgeUserPrompt, error)
|
||||
// Authenticates a standalone AI Gateway replica by its hashed key secret,
|
||||
// returning the matched key. The lookup is an exact match on a unique index,
|
||||
// so a returned row is itself proof the secret is valid.
|
||||
GetAIGatewayKeyByHashedSecret(ctx context.Context, hashedSecret []byte) (AIGatewayKey, error)
|
||||
GetAIModelPriceByProviderModel(ctx context.Context, arg GetAIModelPriceByProviderModelParams) (AIModelPrice, error)
|
||||
GetAIProviderByID(ctx context.Context, id uuid.UUID) (AIProvider, error)
|
||||
// Lock the provider row until the model-config write completes. The
|
||||
@@ -1307,6 +1311,10 @@ type sqlcQuerier interface {
|
||||
UnpinChatByID(ctx context.Context, id uuid.UUID) error
|
||||
UnsetDefaultChatModelConfigs(ctx context.Context) error
|
||||
UpdateAIBridgeInterceptionEnded(ctx context.Context, arg UpdateAIBridgeInterceptionEndedParams) (AIBridgeInterception, error)
|
||||
// Records liveness for an active Gateway DRPC session. The database sets the
|
||||
// timestamp so it stays consistent regardless of clock drift between API
|
||||
// replicas.
|
||||
UpdateAIGatewayKeyLastUsedAt(ctx context.Context, id uuid.UUID) (int64, error)
|
||||
UpdateAIProvider(ctx context.Context, arg UpdateAIProviderParams) (AIProvider, error)
|
||||
UpdateAPIKeyByID(ctx context.Context, arg UpdateAPIKeyByIDParams) error
|
||||
UpdateChatACLByID(ctx context.Context, arg UpdateChatACLByIDParams) error
|
||||
|
||||
Reference in New Issue
Block a user