2022-01-05 09:20:56 -06:00
// Code generated by sqlc. DO NOT EDIT.
2022-05-02 14:30:46 -05:00
// versions:
2025-10-29 18:45:56 +02:00
// sqlc v1.30.0
2022-01-05 09:20:56 -06:00
package database
import (
"context"
2022-06-17 00:26:40 -05:00
"time"
2022-01-24 11:07:42 -06:00
"github.com/google/uuid"
2022-01-05 09:20:56 -06:00
)
2022-10-10 15:37:06 -05:00
type sqlcQuerier interface {
2026-03-11 11:00:08 -07:00
// Acquires up to @num_chats pending chats for processing. Uses SKIP LOCKED
// to prevent multiple replicas from acquiring the same chat.
AcquireChats ( ctx context . Context , arg AcquireChatsParams ) ([] Chat , error )
2023-03-08 06:38:11 +11:00
// Blocks until the lock is acquired.
//
// This must be called from within a transaction. The lock will be automatically
// released when the transaction ends.
AcquireLock ( ctx context . Context , pgAdvisoryXactLock int64 ) error
2024-06-28 11:21:25 +02:00
// Acquires the lease for a given count of notification messages, to enable concurrent dequeuing and subsequent sending.
// Only rows that aren't already leased (or ones which are leased but have exceeded their lease period) are returned.
//
// A "lease" here refers to a notifier taking ownership of a notification_messages row. A lease survives for the duration
// of CODER_NOTIFICATIONS_LEASE_PERIOD. Once a message is delivered, its status is updated and the lease expires (set to NULL).
// If a message exceeds its lease, that implies the notifier did not shutdown cleanly, or the table update failed somehow,
// and the row will then be eligible to be dequeued by another notifier.
//
// SKIP LOCKED is used to jump over locked rows. This prevents multiple notifiers from acquiring the same messages.
// See: https://www.postgresql.org/docs/9.5/sql-select.html#SQL-FOR-UPDATE-SHARE
//
AcquireNotificationMessages ( ctx context . Context , arg AcquireNotificationMessagesParams ) ([] AcquireNotificationMessagesRow , error )
2022-05-02 14:30:46 -05:00
// Acquires the lock for a single job that isn't started, completed,
// canceled, and that matches an array of provisioner types.
//
// SKIP LOCKED is used to jump over locked rows. This prevents
// multiple provisioners from acquiring the same jobs. See:
// https://www.postgresql.org/docs/9.5/sql-select.html#SQL-FOR-UPDATE-SHARE
2022-01-29 17:38:32 -06:00
AcquireProvisionerJob ( ctx context . Context , arg AcquireProvisionerJobParams ) ( ProvisionerJob , error )
2026-03-10 18:46:01 +00:00
AcquireStaleChatDiffStatuses ( ctx context . Context , limitVal int32 ) ([] AcquireStaleChatDiffStatusesRow , error )
2024-02-12 23:00:35 -08:00
// Bumps the workspace deadline by the template's configured "activity_bump"
// duration (default 1h). If the workspace bump will cross an autostart
// threshold, then the bump is autostart + TTL. This is the deadline behavior if
// the workspace was to autostart from a stopped state.
//
// Max deadline is respected, and the deadline will never be bumped past it.
2023-11-15 09:42:27 -06:00
// The deadline will never decrease.
2024-02-12 23:00:35 -08:00
// We only bump if the template has an activity bump duration set.
2023-10-13 13:53:02 +01:00
// We only bump if the raw interval is positive and non-zero.
2023-09-14 09:09:51 +01:00
// We only bump if workspace shutdown is manual.
// We only bump when 5% of the deadline has elapsed.
2023-11-15 09:42:27 -06:00
ActivityBumpWorkspace ( ctx context . Context , arg ActivityBumpWorkspaceParams ) error
2023-09-15 15:09:40 +01:00
// AllUserIDs returns all UserIDs regardless of user status or deletion.
2025-03-25 14:18:06 +02:00
AllUserIDs ( ctx context . Context , includeSystem bool ) ([] uuid . UUID , error )
2026-02-27 16:46:19 -05:00
ArchiveChatByID ( ctx context . Context , id uuid . UUID ) error
2023-10-10 10:52:42 -05:00
// Archiving templates is a soft delete action, so is reversible.
// Archiving prevents the version from being used and discovered
// by listing.
// Only unused template versions will be archived, which are any versions not
// referenced by the latest build of a workspace.
ArchiveUnusedTemplateVersions ( ctx context . Context , arg ArchiveUnusedTemplateVersionsParams ) ([] uuid . UUID , error )
2026-03-10 18:46:01 +00:00
BackoffChatDiffStatus ( ctx context . Context , arg BackoffChatDiffStatusParams ) error
2026-01-22 22:47:49 -08:00
BatchUpdateWorkspaceAgentMetadata ( ctx context . Context , arg BatchUpdateWorkspaceAgentMetadataParams ) error
2024-01-16 14:06:39 +00:00
BatchUpdateWorkspaceLastUsedAt ( ctx context . Context , arg BatchUpdateWorkspaceLastUsedAtParams ) error
2024-12-02 21:02:36 +00:00
BatchUpdateWorkspaceNextStartAt ( ctx context . Context , arg BatchUpdateWorkspaceNextStartAtParams ) error
2024-06-28 11:21:25 +02:00
BulkMarkNotificationMessagesFailed ( ctx context . Context , arg BulkMarkNotificationMessagesFailedParams ) ( int64 , error )
BulkMarkNotificationMessagesSent ( ctx context . Context , arg BulkMarkNotificationMessagesSentParams ) ( int64 , error )
2025-10-28 03:16:41 +11:00
// Calculates the telemetry summary for a given provider, model, and client
// combination for telemetry reporting.
CalculateAIBridgeInterceptionsTelemetrySummary ( ctx context . Context , arg CalculateAIBridgeInterceptionsTelemetrySummaryParams ) ( CalculateAIBridgeInterceptionsTelemetrySummaryRow , error )
2025-04-03 10:58:30 +02:00
ClaimPrebuiltWorkspace ( ctx context . Context , arg ClaimPrebuiltWorkspaceParams ) ( ClaimPrebuiltWorkspaceRow , error )
2023-06-23 13:23:28 +04:00
CleanTailnetCoordinators ( ctx context . Context ) error
2023-12-01 10:02:30 +04:00
CleanTailnetLostPeers ( ctx context . Context ) error
CleanTailnetTunnels ( ctx context . Context ) error
2025-10-21 22:50:00 +11:00
CountAIBridgeInterceptions ( ctx context . Context , arg CountAIBridgeInterceptionsParams ) ( int64 , error )
2025-07-01 07:31:14 +02:00
CountAuditLogs ( ctx context . Context , arg CountAuditLogsParams ) ( int64 , error )
2025-07-15 15:03:30 +10:00
CountConnectionLogs ( ctx context . Context , arg CountConnectionLogsParams ) ( int64 , error )
2025-04-17 09:29:29 -04:00
// CountInProgressPrebuilds returns the number of in-progress prebuilds, grouped by preset ID and transition.
2025-10-24 15:27:49 +01:00
// Prebuild considered in-progress if it's in the "pending", "starting", "stopping", or "deleting" state.
2025-04-03 10:58:30 +02:00
CountInProgressPrebuilds ( ctx context . Context ) ([] CountInProgressPrebuildsRow , error )
2025-10-24 15:27:49 +01:00
// CountPendingNonActivePrebuilds returns the number of pending prebuilds for non-active template versions
CountPendingNonActivePrebuilds ( ctx context . Context ) ([] CountPendingNonActivePrebuildsRow , error )
2025-03-03 10:12:48 +01:00
CountUnreadInboxNotificationsByUserID ( ctx context . Context , userID uuid . UUID ) ( int64 , error )
2025-08-07 15:58:59 -04:00
CreateUserSecret ( ctx context . Context , arg CreateUserSecretParams ) ( UserSecret , error )
2024-05-21 13:14:00 -05:00
CustomRoles ( ctx context . Context , arg CustomRolesParams ) ([] CustomRole , error )
2022-05-27 16:47:03 -04:00
DeleteAPIKeyByID ( ctx context . Context , id string ) error
2022-10-19 21:12:03 -05:00
DeleteAPIKeysByUserID ( ctx context . Context , userID uuid . UUID ) error
2026-02-27 11:50:56 -05:00
DeleteAllChatQueuedMessages ( ctx context . Context , chatID uuid . UUID ) error
2023-11-15 10:13:27 +04:00
DeleteAllTailnetTunnels ( ctx context . Context , arg DeleteAllTailnetTunnelsParams ) error
2025-03-27 10:03:53 +00:00
// Deletes all existing webpush subscriptions.
// This should be called when the VAPID keypair is regenerated, as the old
// keypair will no longer be valid and all existing subscriptions will need to
// be recreated.
DeleteAllWebpushSubscriptions ( ctx context . Context ) error
2023-04-06 04:41:55 +10:00
DeleteApplicationConnectAPIKeysByUserID ( ctx context . Context , userID uuid . UUID ) error
2026-02-27 11:50:56 -05:00
DeleteChatMessagesAfterID ( ctx context . Context , arg DeleteChatMessagesAfterIDParams ) error
DeleteChatModelConfigByID ( ctx context . Context , id uuid . UUID ) error
DeleteChatProviderByID ( ctx context . Context , id uuid . UUID ) error
DeleteChatQueuedMessage ( ctx context . Context , arg DeleteChatQueuedMessageParams ) error
2024-09-17 18:08:18 +01:00
DeleteCryptoKey ( ctx context . Context , arg DeleteCryptoKeyParams ) ( CryptoKey , error )
2024-08-07 12:37:55 -05:00
DeleteCustomRole ( ctx context . Context , arg DeleteCustomRoleParams ) error
2025-11-24 10:24:32 -06:00
DeleteExpiredAPIKeys ( ctx context . Context , arg DeleteExpiredAPIKeysParams ) ( int64 , error )
2023-12-05 14:03:44 -06:00
DeleteExternalAuthLink ( ctx context . Context , arg DeleteExternalAuthLinkParams ) error
2022-10-10 15:37:06 -05:00
DeleteGroupByID ( ctx context . Context , id uuid . UUID ) error
2023-02-02 09:46:42 -06:00
DeleteGroupMemberFromGroup ( ctx context . Context , arg DeleteGroupMemberFromGroupParams ) error
2022-08-25 14:04:31 -07:00
DeleteLicense ( ctx context . Context , id int32 ) ( int32 , error )
2025-07-03 18:33:47 +02:00
DeleteOAuth2ProviderAppByClientID ( ctx context . Context , id uuid . UUID ) error
2023-12-21 12:38:42 -09:00
DeleteOAuth2ProviderAppByID ( ctx context . Context , id uuid . UUID ) error
2024-02-20 15:58:43 -08:00
DeleteOAuth2ProviderAppCodeByID ( ctx context . Context , id uuid . UUID ) error
DeleteOAuth2ProviderAppCodesByAppAndUserID ( ctx context . Context , arg DeleteOAuth2ProviderAppCodesByAppAndUserIDParams ) error
2023-12-21 12:38:42 -09:00
DeleteOAuth2ProviderAppSecretByID ( ctx context . Context , id uuid . UUID ) error
2024-02-20 15:58:43 -08:00
DeleteOAuth2ProviderAppTokensByAppAndUserID ( ctx context . Context , arg DeleteOAuth2ProviderAppTokensByAppAndUserIDParams ) error
2025-11-21 11:35:36 +02:00
// Cumulative count.
2025-12-03 11:37:18 +02:00
DeleteOldAIBridgeRecords ( ctx context . Context , beforeTime time . Time ) ( int64 , error )
2025-07-15 15:45:36 +10:00
DeleteOldAuditLogConnectionEvents ( ctx context . Context , arg DeleteOldAuditLogConnectionEventsParams ) error
2025-12-02 16:50:09 +02:00
// Deletes old audit logs based on retention policy, excluding deprecated
// connection events (connect, disconnect, open, close) which are handled
// separately by DeleteOldAuditLogConnectionEvents.
DeleteOldAuditLogs ( ctx context . Context , arg DeleteOldAuditLogsParams ) ( int64 , error )
2025-12-02 16:17:52 +02:00
DeleteOldConnectionLogs ( ctx context . Context , arg DeleteOldConnectionLogsParams ) ( int64 , error )
2024-06-28 11:21:25 +02:00
// Delete all notification messages which have not been updated for over a week.
DeleteOldNotificationMessages ( ctx context . Context ) error
2023-12-01 13:43:05 +01:00
// Delete provisioner daemons that have been created at least a week ago
// and have not connected to coderd since a week.
2023-12-12 11:19:28 +00:00
// A provisioner daemon with "zeroed" last_seen_at column indicates possible
2023-12-01 13:43:05 +01:00
// connectivity issues (no provisioner daemon activity since registration).
DeleteOldProvisionerDaemons ( ctx context . Context ) error
2025-10-28 03:16:41 +11:00
// Deletes old telemetry locks from the telemetry_locks table.
DeleteOldTelemetryLocks ( ctx context . Context , periodEndingAtBefore time . Time ) error
2025-12-02 18:01:33 +02:00
// If an agent hasn't connected within the retention period, we purge its logs.
2024-08-30 17:39:09 +01:00
// Exception: if the logs are related to the latest build, we keep those around.
2023-03-23 14:09:13 -05:00
// Logs can take up a lot of space, so it's important we clean up frequently.
2025-12-02 18:01:33 +02:00
DeleteOldWorkspaceAgentLogs ( ctx context . Context , threshold time . Time ) ( int64 , error )
2023-02-28 13:33:33 -06:00
DeleteOldWorkspaceAgentStats ( ctx context . Context ) error
2024-06-20 05:06:37 -10:00
DeleteOrganizationMember ( ctx context . Context , arg DeleteOrganizationMemberParams ) error
2024-07-16 13:27:12 -04:00
DeleteProvisionerKey ( ctx context . Context , id uuid . UUID ) error
2022-10-17 08:43:30 -05:00
DeleteReplicasUpdatedBefore ( ctx context . Context , updatedAt time . Time ) error
2024-09-09 14:14:52 -05:00
DeleteRuntimeConfig ( ctx context . Context , key string ) error
2023-11-15 10:13:27 +04:00
DeleteTailnetPeer ( ctx context . Context , arg DeleteTailnetPeerParams ) ( DeleteTailnetPeerRow , error )
DeleteTailnetTunnel ( ctx context . Context , arg DeleteTailnetTunnelParams ) ( DeleteTailnetTunnelRow , error )
2026-02-06 11:55:33 +02:00
DeleteTask ( ctx context . Context , arg DeleteTaskParams ) ( uuid . UUID , error )
2025-08-07 15:58:59 -04:00
DeleteUserSecret ( ctx context . Context , id uuid . UUID ) error
2025-03-27 10:03:53 +00:00
DeleteWebpushSubscriptionByUserIDAndEndpoint ( ctx context . Context , arg DeleteWebpushSubscriptionByUserIDAndEndpointParams ) error
DeleteWebpushSubscriptions ( ctx context . Context , ids [] uuid . UUID ) error
2025-09-12 12:21:01 -04:00
DeleteWorkspaceACLByID ( ctx context . Context , id uuid . UUID ) error
2026-01-14 09:47:50 -08:00
DeleteWorkspaceACLsByOrganization ( ctx context . Context , organizationID uuid . UUID ) error
2024-02-13 09:31:20 -05:00
DeleteWorkspaceAgentPortShare ( ctx context . Context , arg DeleteWorkspaceAgentPortShareParams ) error
2024-03-05 13:47:01 -05:00
DeleteWorkspaceAgentPortSharesByTemplate ( ctx context . Context , templateID uuid . UUID ) error
2025-05-29 12:15:47 +01:00
DeleteWorkspaceSubAgentByID ( ctx context . Context , id uuid . UUID ) error
2025-01-08 16:22:51 +01:00
// Disable foreign keys and triggers for all tables.
// Deprecated: disable foreign keys was created to aid in migrating off
// of the test-only in-memory database. Do not use this in new code.
DisableForeignKeysAndTriggers ( ctx context . Context ) error
2024-07-11 10:57:49 +02:00
EnqueueNotificationMessage ( ctx context . Context , arg EnqueueNotificationMessageParams ) error
2025-09-02 09:38:43 +01:00
// Firstly, collect api_keys owned by the prebuilds user that correlate
// to workspaces no longer owned by the prebuilds user.
// Next, collect api_keys that belong to the prebuilds user but have no token name.
// These were most likely created via 'coder login' as the prebuilds user.
ExpirePrebuildsAPIKeys ( ctx context . Context , now time . Time ) error
2024-01-24 13:39:19 +00:00
FavoriteWorkspace ( ctx context . Context , id uuid . UUID ) error
2025-02-04 18:45:33 +01:00
FetchMemoryResourceMonitorsByAgentID ( ctx context . Context , agentID uuid . UUID ) ( WorkspaceAgentMemoryResourceMonitor , error )
2025-03-03 18:41:01 +01:00
FetchMemoryResourceMonitorsUpdatedAfter ( ctx context . Context , updatedAt time . Time ) ([] WorkspaceAgentMemoryResourceMonitor , error )
2024-06-28 11:21:25 +02:00
// This is used to build up the notification_message's JSON payload.
FetchNewMessageMetadata ( ctx context . Context , arg FetchNewMessageMetadataParams ) ( FetchNewMessageMetadataRow , error )
2025-02-04 18:45:33 +01:00
FetchVolumesResourceMonitorsByAgentID ( ctx context . Context , agentID uuid . UUID ) ([] WorkspaceAgentVolumeResourceMonitor , error )
2025-03-03 18:41:01 +01:00
FetchVolumesResourceMonitorsUpdatedAfter ( ctx context . Context , updatedAt time . Time ) ([] WorkspaceAgentVolumeResourceMonitor , error )
2025-08-20 11:02:53 +02:00
// FindMatchingPresetID finds a preset ID that is the largest exact subset of the provided parameters.
// It returns the preset ID if a match is found, or NULL if no match is found.
// The query finds presets where all preset parameters are present in the provided parameters,
// and returns the preset with the most parameters (largest subset).
FindMatchingPresetID ( ctx context . Context , arg FindMatchingPresetIDParams ) ( uuid . UUID , error )
2025-09-16 21:31:17 +02:00
GetAIBridgeInterceptionByID ( ctx context . Context , id uuid . UUID ) ( AIBridgeInterception , error )
2026-03-03 21:04:41 +02:00
// Look up the parent interception and the root of the thread by finding
// which interception recorded a tool usage with the given tool call ID.
// COALESCE ensures that if the parent has no thread_root_id (i.e. it IS
// the root), we return its own ID as the root.
GetAIBridgeInterceptionLineageByToolCallID ( ctx context . Context , toolCallID string ) ( GetAIBridgeInterceptionLineageByToolCallIDRow , error )
2025-09-25 16:37:28 +02:00
GetAIBridgeInterceptions ( ctx context . Context ) ([] AIBridgeInterception , error )
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 )
2022-01-20 07:46:51 -06:00
GetAPIKeyByID ( ctx context . Context , id string ) ( APIKey , error )
2023-03-02 09:39:38 -08:00
// there is no unique constraint on empty token names
GetAPIKeyByName ( ctx context . Context , arg GetAPIKeyByNameParams ) ( APIKey , error )
2026-02-24 16:27:03 +01:00
GetAPIKeysByLoginType ( ctx context . Context , arg GetAPIKeysByLoginTypeParams ) ([] APIKey , error )
2023-02-23 07:00:27 -08:00
GetAPIKeysByUserID ( ctx context . Context , arg GetAPIKeysByUserIDParams ) ([] APIKey , error )
2022-06-17 00:26:40 -05:00
GetAPIKeysLastUsedAfter ( ctx context . Context , lastUsed time . Time ) ([] APIKey , error )
2025-06-19 11:08:48 -04:00
GetActivePresetPrebuildSchedules ( ctx context . Context ) ([] TemplateVersionPresetPrebuildSchedule , error )
2025-03-25 14:18:06 +02:00
GetActiveUserCount ( ctx context . Context , includeSystem bool ) ( int64 , error )
2023-08-14 14:16:47 -07:00
GetActiveWorkspaceBuildsByTemplateID ( ctx context . Context , templateID uuid . UUID ) ([] WorkspaceBuild , error )
2023-11-28 20:19:32 +04:00
// For PG Coordinator HTMLDebug
GetAllTailnetCoordinators ( ctx context . Context ) ([] TailnetCoordinator , error )
GetAllTailnetPeers ( ctx context . Context ) ([] TailnetPeer , error )
GetAllTailnetTunnels ( ctx context . Context ) ([] TailnetTunnel , error )
2026-02-06 09:52:17 -07:00
// Atomic read+delete prevents replicas that flush between a separate read and
// reset from having their data deleted before the next snapshot. Uses a common
// table expression with DELETE...RETURNING so the rows we sum are exactly the
// rows we delete. Stale rows are excluded from the sum but still deleted.
GetAndResetBoundaryUsageSummary ( ctx context . Context , maxStalenessMs int64 ) ( GetAndResetBoundaryUsageSummaryRow , error )
2024-05-31 10:59:28 -06:00
GetAnnouncementBanners ( ctx context . Context ) ( string , error )
2023-09-27 17:02:18 +02:00
GetApplicationName ( ctx context . Context ) ( string , error )
2022-09-07 11:38:19 -05:00
// GetAuditLogsBefore retrieves `row_limit` number of audit logs before the provided
2022-05-02 14:30:46 -05:00
// ID.
2022-09-07 11:38:19 -05:00
GetAuditLogsOffset ( ctx context . Context , arg GetAuditLogsOffsetParams ) ([] GetAuditLogsOffsetRow , error )
2026-01-21 15:18:43 +02:00
// GetAuthenticatedWorkspaceAgentAndBuildByAuthToken returns an authenticated
// workspace agent and its associated build. During normal operation, this is
// the latest build. During shutdown, this may be the previous START build while
// the STOP build is executing, allowing shutdown scripts to authenticate (see
// issue #19467).
GetAuthenticatedWorkspaceAgentAndBuildByAuthToken ( ctx context . Context , authToken uuid . UUID ) ( GetAuthenticatedWorkspaceAgentAndBuildByAuthTokenRow , error )
2022-06-01 09:07:50 -05:00
// This function returns roles for authorization purposes. Implied member roles
// are included.
GetAuthorizationUserRoles ( ctx context . Context , userID uuid . UUID ) ( GetAuthorizationUserRolesRow , error )
2026-02-27 11:50:56 -05:00
GetChatByID ( ctx context . Context , id uuid . UUID ) ( Chat , error )
GetChatByIDForUpdate ( ctx context . Context , id uuid . UUID ) ( Chat , error )
2026-03-13 18:30:49 +01:00
// Per-root-chat cost breakdown for a single user within a date range.
// Groups by root_chat_id so forked chats roll up under their root.
// Only counts assistant-role messages.
GetChatCostPerChat ( ctx context . Context , arg GetChatCostPerChatParams ) ([] GetChatCostPerChatRow , error )
// Per-model cost breakdown for a single user within a date range.
// Only counts assistant-role messages that have a model_config_id.
GetChatCostPerModel ( ctx context . Context , arg GetChatCostPerModelParams ) ([] GetChatCostPerModelRow , error )
// Deployment-wide per-user cost rollup within a date range.
// Only counts assistant-role messages.
GetChatCostPerUser ( ctx context . Context , arg GetChatCostPerUserParams ) ([] GetChatCostPerUserRow , error )
// Aggregate cost summary for a single user within a date range.
// Only counts assistant-role messages.
GetChatCostSummary ( ctx context . Context , arg GetChatCostSummaryParams ) ( GetChatCostSummaryRow , error )
2026-02-27 11:50:56 -05:00
GetChatDiffStatusByChatID ( ctx context . Context , chatID uuid . UUID ) ( ChatDiffStatus , error )
GetChatDiffStatusesByChatIDs ( ctx context . Context , chatIds [] uuid . UUID ) ([] ChatDiffStatus , error )
2026-03-06 21:05:26 +02:00
GetChatFileByID ( ctx context . Context , id uuid . UUID ) ( ChatFile , error )
GetChatFilesByIDs ( ctx context . Context , ids [] uuid . UUID ) ([] ChatFile , error )
2026-02-27 11:50:56 -05:00
GetChatMessageByID ( ctx context . Context , id int64 ) ( ChatMessage , error )
2026-03-02 16:31:04 -05:00
GetChatMessagesByChatID ( ctx context . Context , arg GetChatMessagesByChatIDParams ) ([] ChatMessage , error )
2026-02-27 11:50:56 -05:00
GetChatMessagesForPromptByChatID ( ctx context . Context , chatID uuid . UUID ) ([] ChatMessage , error )
GetChatModelConfigByID ( ctx context . Context , id uuid . UUID ) ( ChatModelConfig , error )
GetChatModelConfigs ( ctx context . Context ) ([] ChatModelConfig , error )
GetChatProviderByID ( ctx context . Context , id uuid . UUID ) ( ChatProvider , error )
GetChatProviderByProvider ( ctx context . Context , provider string ) ( ChatProvider , error )
GetChatProviders ( ctx context . Context ) ([] ChatProvider , error )
GetChatQueuedMessages ( ctx context . Context , chatID uuid . UUID ) ([] ChatQueuedMessage , error )
2026-03-10 11:46:53 +00:00
GetChatSystemPrompt ( ctx context . Context ) ( string , error )
2026-03-03 20:39:19 +00:00
GetChatsByOwnerID ( ctx context . Context , arg GetChatsByOwnerIDParams ) ([] Chat , error )
2025-07-15 14:36:06 +10:00
GetConnectionLogsOffset ( ctx context . Context , arg GetConnectionLogsOffsetParams ) ([] GetConnectionLogsOffsetRow , error )
2024-09-17 18:08:18 +01:00
GetCryptoKeyByFeatureAndSequence ( ctx context . Context , arg GetCryptoKeyByFeatureAndSequenceParams ) ( CryptoKey , error )
GetCryptoKeys ( ctx context . Context ) ([] CryptoKey , error )
2024-09-26 21:01:49 +01:00
GetCryptoKeysByFeature ( ctx context . Context , feature CryptoKeyFeature ) ([] CryptoKey , error )
2023-09-06 12:06:26 +01:00
GetDBCryptKeys ( ctx context . Context ) ([] DBCryptKey , error )
2022-10-17 08:43:30 -05:00
GetDERPMeshKey ( ctx context . Context ) ( string , error )
2026-02-27 11:50:56 -05:00
GetDefaultChatModelConfig ( ctx context . Context ) ( ChatModelConfig , error )
2024-02-16 08:28:36 -06:00
GetDefaultOrganization ( ctx context . Context ) ( Organization , error )
2023-06-08 10:30:15 -05:00
GetDefaultProxyConfig ( ctx context . Context ) ( GetDefaultProxyConfigRow , error )
2022-06-17 00:26:40 -05:00
GetDeploymentID ( ctx context . Context ) ( string , error )
2023-03-08 21:05:45 -06:00
GetDeploymentWorkspaceAgentStats ( ctx context . Context , createdAt time . Time ) ( GetDeploymentWorkspaceAgentStatsRow , error )
2024-09-19 11:52:14 -04:00
GetDeploymentWorkspaceAgentUsageStats ( ctx context . Context , createdAt time . Time ) ( GetDeploymentWorkspaceAgentUsageStatsRow , error )
2023-03-08 21:05:45 -06:00
GetDeploymentWorkspaceStats ( ctx context . Context ) ( GetDeploymentWorkspaceStatsRow , error )
2024-12-11 13:38:13 +02:00
GetEligibleProvisionerDaemonsByProvisionerJobIDs ( ctx context . Context , provisionerJobIds [] uuid . UUID ) ([] GetEligibleProvisionerDaemonsByProvisionerJobIDsRow , error )
2026-02-27 11:50:56 -05:00
GetEnabledChatModelConfigs ( ctx context . Context ) ([] ChatModelConfig , error )
GetEnabledChatProviders ( ctx context . Context ) ([] ChatProvider , error )
2023-09-29 14:13:20 -05:00
GetExternalAuthLink ( ctx context . Context , arg GetExternalAuthLinkParams ) ( ExternalAuthLink , error )
GetExternalAuthLinksByUserID ( ctx context . Context , userID uuid . UUID ) ([] ExternalAuthLink , error )
2024-09-18 09:11:44 +02:00
GetFailedWorkspaceBuildsByTemplateID ( ctx context . Context , arg GetFailedWorkspaceBuildsByTemplateIDParams ) ([] GetFailedWorkspaceBuildsByTemplateIDRow , error )
2022-10-13 18:02:52 -05:00
GetFileByHashAndCreator ( ctx context . Context , arg GetFileByHashAndCreatorParams ) ( File , error )
GetFileByID ( ctx context . Context , id uuid . UUID ) ( File , error )
2023-03-27 09:21:41 -05:00
// Get all templates that use a file.
GetFileTemplates ( ctx context . Context , fileID uuid . UUID ) ([] GetFileTemplatesRow , error )
2025-03-03 10:12:48 +01:00
// Fetches inbox notifications for a user filtered by templates and targets
// param user_id: The user ID
// param templates: The template IDs to filter by - the template_id = ANY(@templates::UUID[]) condition checks if the template_id is in the @templates array
// param targets: The target IDs to filter by - the targets @> COALESCE(@targets, ARRAY[]::UUID[]) condition checks if the targets array (from the DB) contains all the elements in the @targets array
// param read_status: The read status to filter by - can be any of 'ALL', 'UNREAD', 'READ'
// param created_at_opt: The created_at timestamp to filter by. This parameter is usd for pagination - it fetches notifications created before the specified timestamp if it is not the zero value
// param limit_opt: The limit of notifications to fetch. If the limit is not specified, it defaults to 25
GetFilteredInboxNotificationsByUserID ( ctx context . Context , arg GetFilteredInboxNotificationsByUserIDParams ) ([] InboxNotification , error )
2022-04-05 19:18:26 -05:00
GetGitSSHKey ( ctx context . Context , userID uuid . UUID ) ( GitSSHKey , error )
2022-10-10 15:37:06 -05:00
GetGroupByID ( ctx context . Context , id uuid . UUID ) ( Group , error )
GetGroupByOrgAndName ( ctx context . Context , arg GetGroupByOrgAndNameParams ) ( Group , error )
2025-03-25 14:18:06 +02:00
GetGroupMembers ( ctx context . Context , includeSystem bool ) ([] GroupMember , error )
GetGroupMembersByGroupID ( ctx context . Context , arg GetGroupMembersByGroupIDParams ) ([] GroupMember , error )
2024-08-13 16:20:24 +02:00
// Returns the total count of members in a group. Shows the total
// count even if the caller does not have read access to ResourceGroupMember.
// They only need ResourceGroup read access.
2025-03-25 14:18:06 +02:00
GetGroupMembersCountByGroupID ( ctx context . Context , arg GetGroupMembersCountByGroupIDParams ) ( int64 , error )
2024-08-29 10:55:00 -06:00
GetGroups ( ctx context . Context , arg GetGroupsParams ) ([] GetGroupsRow , error )
2023-11-23 17:18:12 +01:00
GetHealthSettings ( ctx context . Context ) ( string , error )
2025-03-03 10:12:48 +01:00
GetInboxNotificationByID ( ctx context . Context , id uuid . UUID ) ( InboxNotification , error )
// Fetches inbox notifications for a user filtered by templates and targets
// param user_id: The user ID
// param read_status: The read status to filter by - can be any of 'ALL', 'UNREAD', 'READ'
// param created_at_opt: The created_at timestamp to filter by. This parameter is usd for pagination - it fetches notifications created before the specified timestamp if it is not the zero value
// param limit_opt: The limit of notifications to fetch. If the limit is not specified, it defaults to 25
GetInboxNotificationsByUserID ( ctx context . Context , arg GetInboxNotificationsByUserIDParams ) ([] InboxNotification , error )
2026-03-10 15:14:15 +00:00
GetLastChatMessageByRole ( ctx context . Context , arg GetLastChatMessageByRoleParams ) ( ChatMessage , error )
2022-12-01 19:43:28 +02:00
GetLastUpdateCheck ( ctx context . Context ) ( string , error )
2024-09-17 18:08:18 +01:00
GetLatestCryptoKeyByFeature ( ctx context . Context , feature CryptoKeyFeature ) ( CryptoKey , error )
2025-11-25 16:56:42 +02:00
GetLatestWorkspaceAppStatusByAppID ( ctx context . Context , appID uuid . UUID ) ( WorkspaceAppStatus , error )
2025-03-31 10:55:44 -04:00
GetLatestWorkspaceAppStatusesByWorkspaceIDs ( ctx context . Context , ids [] uuid . UUID ) ([] WorkspaceAppStatus , error )
2023-03-10 10:39:02 -06:00
GetLatestWorkspaceBuildByWorkspaceID ( ctx context . Context , workspaceID uuid . UUID ) ( WorkspaceBuild , error )
GetLatestWorkspaceBuildsByWorkspaceIDs ( ctx context . Context , ids [] uuid . UUID ) ([] WorkspaceBuild , error )
2023-02-14 08:27:06 -06:00
GetLicenseByID ( ctx context . Context , id int32 ) ( License , error )
2022-08-24 11:44:22 -07:00
GetLicenses ( ctx context . Context ) ([] License , error )
2023-01-04 15:31:45 -06:00
GetLogoURL ( ctx context . Context ) ( string , error )
2024-07-08 15:38:50 +02:00
GetNotificationMessagesByStatus ( ctx context . Context , arg GetNotificationMessagesByStatusParams ) ([] NotificationMessage , error )
2024-09-18 09:11:44 +02:00
// Fetch the notification report generator log indicating recent activity.
GetNotificationReportGeneratorLogByTemplate ( ctx context . Context , templateID uuid . UUID ) ( NotificationReportGeneratorLog , error )
2024-08-05 16:18:45 +02:00
GetNotificationTemplateByID ( ctx context . Context , id uuid . UUID ) ( NotificationTemplate , error )
GetNotificationTemplatesByKind ( ctx context . Context , kind NotificationTemplateKind ) ([] NotificationTemplate , error )
2024-07-10 16:15:06 +02:00
GetNotificationsSettings ( ctx context . Context ) ( string , error )
2025-02-25 16:31:33 +01:00
GetOAuth2GithubDefaultEligible ( ctx context . Context ) ( bool , error )
2025-07-03 18:33:47 +02:00
// RFC 7591/7592 Dynamic Client Registration queries
GetOAuth2ProviderAppByClientID ( ctx context . Context , id uuid . UUID ) ( OAuth2ProviderApp , error )
2023-12-21 12:38:42 -09:00
GetOAuth2ProviderAppByID ( ctx context . Context , id uuid . UUID ) ( OAuth2ProviderApp , error )
2024-02-20 15:58:43 -08:00
GetOAuth2ProviderAppCodeByID ( ctx context . Context , id uuid . UUID ) ( OAuth2ProviderAppCode , error )
GetOAuth2ProviderAppCodeByPrefix ( ctx context . Context , secretPrefix [] byte ) ( OAuth2ProviderAppCode , error )
2023-12-21 12:38:42 -09:00
GetOAuth2ProviderAppSecretByID ( ctx context . Context , id uuid . UUID ) ( OAuth2ProviderAppSecret , error )
2024-02-20 15:58:43 -08:00
GetOAuth2ProviderAppSecretByPrefix ( ctx context . Context , secretPrefix [] byte ) ( OAuth2ProviderAppSecret , error )
2023-12-21 12:38:42 -09:00
GetOAuth2ProviderAppSecretsByAppID ( ctx context . Context , appID uuid . UUID ) ([] OAuth2ProviderAppSecret , error )
2025-07-02 17:49:00 +02:00
GetOAuth2ProviderAppTokenByAPIKeyID ( ctx context . Context , apiKeyID string ) ( OAuth2ProviderAppToken , error )
2024-02-20 15:58:43 -08:00
GetOAuth2ProviderAppTokenByPrefix ( ctx context . Context , hashPrefix [] byte ) ( OAuth2ProviderAppToken , error )
2023-12-21 12:38:42 -09:00
GetOAuth2ProviderApps ( ctx context . Context ) ([] OAuth2ProviderApp , error )
2024-02-20 15:58:43 -08:00
GetOAuth2ProviderAppsByUserID ( ctx context . Context , userID uuid . UUID ) ([] GetOAuth2ProviderAppsByUserIDRow , error )
2022-04-01 14:42:36 -05:00
GetOrganizationByID ( ctx context . Context , id uuid . UUID ) ( Organization , error )
2025-02-24 17:59:41 +00:00
GetOrganizationByName ( ctx context . Context , arg GetOrganizationByNameParams ) ( Organization , error )
2022-04-28 09:10:17 -05:00
GetOrganizationIDsByMemberIDs ( ctx context . Context , ids [] uuid . UUID ) ([] GetOrganizationIDsByMemberIDsRow , error )
2025-03-25 15:31:24 -04:00
GetOrganizationResourceCountByID ( ctx context . Context , organizationID uuid . UUID ) ( GetOrganizationResourceCountByIDRow , error )
2024-08-28 13:24:28 -05:00
GetOrganizations ( ctx context . Context , arg GetOrganizationsParams ) ([] Organization , error )
2025-02-24 17:59:41 +00:00
GetOrganizationsByUserID ( ctx context . Context , arg GetOrganizationsByUserIDParams ) ([] Organization , error )
2025-10-29 14:24:29 +00:00
// GetOrganizationsWithPrebuildStatus returns organizations with prebuilds configured and their
// membership status for the prebuilds system user (org membership, group existence, group membership).
GetOrganizationsWithPrebuildStatus ( ctx context . Context , arg GetOrganizationsWithPrebuildStatusParams ) ([] GetOrganizationsWithPrebuildStatusRow , error )
2022-02-08 12:00:44 -06:00
GetParameterSchemasByJobID ( ctx context . Context , jobID uuid . UUID ) ([] ParameterSchema , error )
2025-04-03 10:58:30 +02:00
GetPrebuildMetrics ( ctx context . Context ) ([] GetPrebuildMetricsRow , error )
2025-07-02 17:05:42 +02:00
GetPrebuildsSettings ( ctx context . Context ) ( string , error )
2025-04-03 10:58:30 +02:00
GetPresetByID ( ctx context . Context , presetID uuid . UUID ) ( GetPresetByIDRow , error )
2025-02-11 13:55:09 +02:00
GetPresetByWorkspaceBuildID ( ctx context . Context , workspaceBuildID uuid . UUID ) ( TemplateVersionPreset , error )
2025-04-07 10:35:28 +02:00
GetPresetParametersByPresetID ( ctx context . Context , presetID uuid . UUID ) ([] TemplateVersionPresetParameter , error )
2025-02-11 13:55:09 +02:00
GetPresetParametersByTemplateVersionID ( ctx context . Context , templateVersionID uuid . UUID ) ([] TemplateVersionPresetParameter , error )
2025-05-21 15:16:38 -04:00
// GetPresetsAtFailureLimit groups workspace builds by preset ID.
// Each preset is associated with exactly one template version ID.
// For each preset, the query checks the last hard_limit builds.
// If all of them failed, the preset is considered to have hit the hard failure limit.
// The query returns a list of preset IDs that have reached this failure threshold.
// Only active template versions with configured presets are considered.
// For each preset, check the last hard_limit builds.
// If all of them failed, the preset is considered to have hit the hard failure limit.
GetPresetsAtFailureLimit ( ctx context . Context , hardLimit int64 ) ([] GetPresetsAtFailureLimitRow , error )
2025-04-03 10:58:30 +02:00
// GetPresetsBackoff groups workspace builds by preset ID.
// Each preset is associated with exactly one template version ID.
// For each group, the query checks up to N of the most recent jobs that occurred within the
// lookback period, where N equals the number of desired instances for the corresponding preset.
// If at least one of the job within a group has failed, we should backoff on the corresponding preset ID.
// Query returns a list of preset IDs for which we should backoff.
// Only active template versions with configured presets are considered.
// We also return the number of failed workspace builds that occurred during the lookback period.
//
// NOTE:
// - To **decide whether to back off**, we look at up to the N most recent builds (within the defined lookback period).
// - To **calculate the number of failed builds**, we consider all builds within the defined lookback period.
//
// The number of failed builds is used downstream to determine the backoff duration.
GetPresetsBackoff ( ctx context . Context , lookback time . Time ) ([] GetPresetsBackoffRow , error )
2025-02-11 13:55:09 +02:00
GetPresetsByTemplateVersionID ( ctx context . Context , templateVersionID uuid . UUID ) ([] TemplateVersionPreset , error )
2022-12-06 11:15:03 -03:00
GetPreviousTemplateVersion ( ctx context . Context , arg GetPreviousTemplateVersionParams ) ( TemplateVersion , error )
2022-01-31 23:36:15 -06:00
GetProvisionerDaemons ( ctx context . Context ) ([] ProvisionerDaemon , error )
2024-11-15 11:33:22 +02:00
GetProvisionerDaemonsByOrganization ( ctx context . Context , arg GetProvisionerDaemonsByOrganizationParams ) ([] ProvisionerDaemon , error )
2025-02-14 17:26:46 +02:00
// Current job information.
// Previous job information.
2025-01-14 18:40:26 +02:00
GetProvisionerDaemonsWithStatusByOrganization ( ctx context . Context , arg GetProvisionerDaemonsWithStatusByOrganizationParams ) ([] GetProvisionerDaemonsWithStatusByOrganizationRow , error )
2022-01-29 17:38:32 -06:00
GetProvisionerJobByID ( ctx context . Context , id uuid . UUID ) ( ProvisionerJob , error )
2025-05-20 15:22:44 +02:00
// Gets a single provisioner job by ID for update.
// This is used to securely reap jobs that have been hung/pending for a long time.
GetProvisionerJobByIDForUpdate ( ctx context . Context , id uuid . UUID ) ( ProvisionerJob , error )
2025-09-08 15:40:14 +02:00
// Gets a provisioner job by ID with exclusive lock.
// Blocks until the row is available for update.
GetProvisionerJobByIDWithLock ( ctx context . Context , id uuid . UUID ) ( ProvisionerJob , error )
2024-09-16 16:31:05 -03:00
GetProvisionerJobTimingsByJobID ( ctx context . Context , jobID uuid . UUID ) ([] ProvisionerJobTiming , error )
2025-05-28 08:21:16 -04:00
GetProvisionerJobsByIDsWithQueuePosition ( ctx context . Context , arg GetProvisionerJobsByIDsWithQueuePositionParams ) ([] GetProvisionerJobsByIDsWithQueuePositionRow , error )
2025-01-20 11:18:53 +02:00
GetProvisionerJobsByOrganizationAndStatusWithQueuePositionAndProvisioner ( ctx context . Context , arg GetProvisionerJobsByOrganizationAndStatusWithQueuePositionAndProvisionerParams ) ([] GetProvisionerJobsByOrganizationAndStatusWithQueuePositionAndProvisionerRow , error )
2022-06-17 00:26:40 -05:00
GetProvisionerJobsCreatedAfter ( ctx context . Context , createdAt time . Time ) ([] ProvisionerJob , error )
2025-05-20 15:22:44 +02:00
// To avoid repeatedly attempting to reap the same jobs, we randomly order and limit to @max_jobs.
GetProvisionerJobsToBeReaped ( ctx context . Context , arg GetProvisionerJobsToBeReapedParams ) ([] ProvisionerJob , error )
2024-07-25 17:08:12 -04:00
GetProvisionerKeyByHashedSecret ( ctx context . Context , hashedSecret [] byte ) ( ProvisionerKey , error )
2024-07-16 13:27:12 -04:00
GetProvisionerKeyByID ( ctx context . Context , id uuid . UUID ) ( ProvisionerKey , error )
GetProvisionerKeyByName ( ctx context . Context , arg GetProvisionerKeyByNameParams ) ( ProvisionerKey , error )
2023-03-23 14:09:13 -05:00
GetProvisionerLogsAfterID ( ctx context . Context , arg GetProvisionerLogsAfterIDParams ) ([] ProvisionerJobLog , error )
2024-08-21 09:25:20 -05:00
GetQuotaAllowanceForUser ( ctx context . Context , arg GetQuotaAllowanceForUserParams ) ( int64 , error )
GetQuotaConsumedForUser ( ctx context . Context , arg GetQuotaConsumedForUserParams ) ( int64 , error )
2025-08-28 15:00:26 +01:00
// Count regular workspaces: only those whose first successful 'start' build
// was not initiated by the prebuild system user.
GetRegularWorkspaceCreateMetrics ( ctx context . Context ) ([] GetRegularWorkspaceCreateMetricsRow , error )
2023-07-26 09:21:04 -07:00
GetReplicaByID ( ctx context . Context , id uuid . UUID ) ( Replica , error )
2022-10-17 08:43:30 -05:00
GetReplicasUpdatedAfter ( ctx context . Context , updatedAt time . Time ) ([] Replica , error )
2025-04-03 10:58:30 +02:00
GetRunningPrebuiltWorkspaces ( ctx context . Context ) ([] GetRunningPrebuiltWorkspacesRow , error )
2024-09-09 14:14:52 -05:00
GetRuntimeConfig ( ctx context . Context , key string ) ( string , error )
2026-02-27 11:50:56 -05:00
// Find chats that appear stuck (running but heartbeat has expired).
// Used for recovery after coderd crashes or long hangs.
GetStaleChats ( ctx context . Context , staleThreshold time . Time ) ([] Chat , error )
2023-11-15 10:13:27 +04:00
GetTailnetPeers ( ctx context . Context , id uuid . UUID ) ([] TailnetPeer , error )
GetTailnetTunnelPeerBindings ( ctx context . Context , srcID uuid . UUID ) ([] GetTailnetTunnelPeerBindingsRow , error )
GetTailnetTunnelPeerIDs ( ctx context . Context , srcID uuid . UUID ) ([] GetTailnetTunnelPeerIDsRow , error )
2025-10-13 12:25:58 +03:00
GetTaskByID ( ctx context . Context , id uuid . UUID ) ( Task , error )
2025-11-05 14:28:34 +00:00
GetTaskByOwnerIDAndName ( ctx context . Context , arg GetTaskByOwnerIDAndNameParams ) ( Task , error )
2025-10-13 12:25:58 +03:00
GetTaskByWorkspaceID ( ctx context . Context , workspaceID uuid . UUID ) ( Task , error )
2026-01-27 11:09:24 +02:00
GetTaskSnapshot ( ctx context . Context , taskID uuid . UUID ) ( TaskSnapshot , error )
2025-01-31 13:55:46 +01:00
GetTelemetryItem ( ctx context . Context , key string ) ( TelemetryItem , error )
GetTelemetryItems ( ctx context . Context ) ([] TelemetryItem , error )
2026-02-24 17:04:42 +00:00
// Returns all data needed to build task lifecycle events for telemetry
// in a single round-trip. For each task whose workspace is in the
// given set, fetches:
// - the latest workspace app binding (task_workspace_apps)
// - the most recent stop and start builds (workspace_builds)
// - the last "working" app status (workspace_app_statuses)
// - the first app status after resume, for active workspaces
//
// Assumptions:
// - 1:1 relationship between tasks and workspaces. All builds on the
// workspace are considered task-related.
// - Idle duration approximation: If the agent reports "working", does
// work, then reports "done", we miss that working time.
// - lws and active_dur join across all historical app IDs for the task,
// because each resume cycle provisions a new app ID. This ensures
// pre-pause statuses contribute to idle duration and active duration.
GetTelemetryTaskEvents ( ctx context . Context , arg GetTelemetryTaskEventsParams ) ([] GetTelemetryTaskEventsRow , error )
2023-08-21 15:08:58 +03:00
// GetTemplateAppInsights returns the aggregate usage of each app in a given
// timeframe. The result can be filtered on template_ids, meaning only user data
// from workspaces based on those templates will be included.
GetTemplateAppInsights ( ctx context . Context , arg GetTemplateAppInsightsParams ) ([] GetTemplateAppInsightsRow , error )
2024-03-25 17:42:02 +02:00
// GetTemplateAppInsightsByTemplate is used for Prometheus metrics. Keep
// in sync with GetTemplateAppInsights and UpsertTemplateUsageStats.
2023-11-07 17:14:59 +01:00
GetTemplateAppInsightsByTemplate ( ctx context . Context , arg GetTemplateAppInsightsByTemplateParams ) ([] GetTemplateAppInsightsByTemplateRow , error )
2025-09-01 09:31:21 -07:00
GetTemplateAverageBuildTime ( ctx context . Context , templateID uuid . NullUUID ) ( GetTemplateAverageBuildTimeRow , error )
2022-04-06 12:42:40 -05:00
GetTemplateByID ( ctx context . Context , id uuid . UUID ) ( Template , error )
GetTemplateByOrganizationAndName ( ctx context . Context , arg GetTemplateByOrganizationAndNameParams ) ( Template , error )
2024-03-25 15:33:31 +02:00
// GetTemplateInsights returns the aggregate user-produced usage of all
// workspaces in a given timeframe. The template IDs, active users, and
// usage_seconds all reflect any usage in the template, including apps.
//
// When combining data from multiple templates, we must make a guess at
// how the user behaved for the 30 minute interval. In this case we make
// the assumption that if the user used two workspaces for 15 minutes,
// they did so sequentially, thus we sum the usage up to a maximum of
// 30 minutes with LEAST(SUM(n), 30).
2023-07-21 21:00:19 +03:00
GetTemplateInsights ( ctx context . Context , arg GetTemplateInsightsParams ) ( GetTemplateInsightsRow , error )
2023-09-15 14:01:00 +02:00
// GetTemplateInsightsByInterval returns all intervals between start and end
// time, if end time is a partial interval, it will be included in the results and
// that interval will be shorter than a full one. If there is no data for a selected
// interval/template, it will be included in the results with 0 active users.
GetTemplateInsightsByInterval ( ctx context . Context , arg GetTemplateInsightsByIntervalParams ) ([] GetTemplateInsightsByIntervalRow , error )
2024-03-25 17:42:02 +02:00
// GetTemplateInsightsByTemplate is used for Prometheus metrics. Keep
// in sync with GetTemplateInsights and UpsertTemplateUsageStats.
2023-10-19 10:45:12 +02:00
GetTemplateInsightsByTemplate ( ctx context . Context , arg GetTemplateInsightsByTemplateParams ) ([] GetTemplateInsightsByTemplateRow , error )
2023-08-03 17:43:23 +03:00
// GetTemplateParameterInsights does for each template in a given timeframe,
// look for the latest workspace build (for every workspace) that has been
// created in the timeframe and return the aggregate usage counts of parameter
// values.
GetTemplateParameterInsights ( ctx context . Context , arg GetTemplateParameterInsightsParams ) ([] GetTemplateParameterInsightsRow , error )
2025-04-03 10:58:30 +02:00
// GetTemplatePresetsWithPrebuilds retrieves template versions with configured presets and prebuilds.
// It also returns the number of desired instances for each preset.
// If template_id is specified, only template versions associated with that template will be returned.
GetTemplatePresetsWithPrebuilds ( ctx context . Context , templateID uuid . NullUUID ) ([] GetTemplatePresetsWithPrebuildsRow , error )
2024-03-22 18:33:34 +02:00
GetTemplateUsageStats ( ctx context . Context , arg GetTemplateUsageStatsParams ) ([] TemplateUsageStat , error )
2022-04-06 12:42:40 -05:00
GetTemplateVersionByID ( ctx context . Context , id uuid . UUID ) ( TemplateVersion , error )
GetTemplateVersionByJobID ( ctx context . Context , jobID uuid . UUID ) ( TemplateVersion , error )
GetTemplateVersionByTemplateIDAndName ( ctx context . Context , arg GetTemplateVersionByTemplateIDAndNameParams ) ( TemplateVersion , error )
2023-01-17 11:22:11 +01:00
GetTemplateVersionParameters ( ctx context . Context , templateVersionID uuid . UUID ) ([] TemplateVersionParameter , error )
2025-04-01 14:47:30 -07:00
GetTemplateVersionTerraformValues ( ctx context . Context , templateVersionID uuid . UUID ) ( TemplateVersionTerraformValue , error )
2023-02-15 18:24:15 +01:00
GetTemplateVersionVariables ( ctx context . Context , templateVersionID uuid . UUID ) ([] TemplateVersionVariable , error )
2024-05-20 15:30:19 +02:00
GetTemplateVersionWorkspaceTags ( ctx context . Context , templateVersionID uuid . UUID ) ([] TemplateVersionWorkspaceTag , error )
2022-11-28 16:53:56 -03:00
GetTemplateVersionsByIDs ( ctx context . Context , ids [] uuid . UUID ) ([] TemplateVersion , error )
2022-05-10 10:44:09 +03:00
GetTemplateVersionsByTemplateID ( ctx context . Context , arg GetTemplateVersionsByTemplateIDParams ) ([] TemplateVersion , error )
2022-06-17 00:26:40 -05:00
GetTemplateVersionsCreatedAfter ( ctx context . Context , createdAt time . Time ) ([] TemplateVersion , error )
GetTemplates ( ctx context . Context ) ([] Template , error )
2022-06-14 08:46:33 -05:00
GetTemplatesWithFilter ( ctx context . Context , arg GetTemplatesWithFilterParams ) ([] Template , error )
2025-08-30 03:39:37 +10:00
// Gets the total number of managed agents created between two dates. Uses the
// aggregate table to avoid large scans or a complex index on the usage_events
// table.
//
// This has the trade off that we can't count accurately between two exact
// timestamps. The provided timestamps will be converted to UTC and truncated to
// the events that happened on and between the two dates. Both dates are
// inclusive.
GetTotalUsageDCManagedAgentsV1 ( ctx context . Context , arg GetTotalUsageDCManagedAgentsV1Params ) ( int64 , error )
2022-08-29 16:45:40 -07:00
GetUnexpiredLicenses ( ctx context . Context ) ([] License , error )
2023-09-26 18:42:16 +02:00
// GetUserActivityInsights returns the ranking with top active users.
2024-03-25 16:16:41 +02:00
// The result can be filtered on template_ids, meaning only user data
// from workspaces based on those templates will be included.
// Note: The usage_seconds and usage_seconds_cumulative differ only when
// requesting deployment-wide (or multiple template) data. Cumulative
// produces a bloated value if a user has used multiple templates
2023-09-26 18:42:16 +02:00
// simultaneously.
GetUserActivityInsights ( ctx context . Context , arg GetUserActivityInsightsParams ) ([] GetUserActivityInsightsRow , error )
2022-01-20 07:46:51 -06:00
GetUserByEmailOrUsername ( ctx context . Context , arg GetUserByEmailOrUsernameParams ) ( User , error )
2022-04-01 14:42:36 -05:00
GetUserByID ( ctx context . Context , id uuid . UUID ) ( User , error )
2026-03-10 08:17:52 -07:00
GetUserChatCustomPrompt ( ctx context . Context , userID uuid . UUID ) ( string , error )
2025-03-25 14:18:06 +02:00
GetUserCount ( ctx context . Context , includeSystem bool ) ( int64 , error )
2023-07-21 21:00:19 +03:00
// GetUserLatencyInsights returns the median and 95th percentile connection
// latency that users have experienced. The result can be filtered on
// template_ids, meaning only user data from workspaces based on those templates
// will be included.
GetUserLatencyInsights ( ctx context . Context , arg GetUserLatencyInsightsParams ) ([] GetUserLatencyInsightsRow , error )
2022-08-17 18:00:53 -05:00
GetUserLinkByLinkedID ( ctx context . Context , linkedID string ) ( UserLink , error )
GetUserLinkByUserIDLoginType ( ctx context . Context , arg GetUserLinkByUserIDLoginTypeParams ) ( UserLink , error )
2023-09-06 12:06:26 +01:00
GetUserLinksByUserID ( ctx context . Context , userID uuid . UUID ) ([] UserLink , error )
2024-08-05 16:18:45 +02:00
GetUserNotificationPreferences ( ctx context . Context , userID uuid . UUID ) ([] NotificationPreference , error )
2025-08-07 15:58:59 -04:00
GetUserSecret ( ctx context . Context , id uuid . UUID ) ( UserSecret , error )
GetUserSecretByUserIDAndName ( ctx context . Context , arg GetUserSecretByUserIDAndNameParams ) ( UserSecret , error )
2025-01-13 13:08:16 +02:00
// GetUserStatusCounts returns the count of users in each status over time.
// The time range is inclusively defined by the start_time and end_time parameters.
GetUserStatusCounts ( ctx context . Context , arg GetUserStatusCountsParams ) ([] GetUserStatusCountsRow , error )
2025-11-28 16:50:59 +00:00
GetUserTaskNotificationAlertDismissed ( ctx context . Context , userID uuid . UUID ) ( bool , error )
2025-04-07 14:30:10 +02:00
GetUserTerminalFont ( ctx context . Context , userID uuid . UUID ) ( string , error )
GetUserThemePreference ( ctx context . Context , userID uuid . UUID ) ( string , error )
2024-01-30 16:02:21 -06:00
GetUserWorkspaceBuildParameters ( ctx context . Context , arg GetUserWorkspaceBuildParametersParams ) ([] GetUserWorkspaceBuildParametersRow , error )
2022-12-16 01:04:24 +10:00
// This will never return deleted users.
2022-11-14 17:22:57 -05:00
GetUsers ( ctx context . Context , arg GetUsersParams ) ([] GetUsersRow , error )
2022-10-10 13:03:54 -05:00
// This shouldn't check for deleted, because it's frequently used
// to look up references to actions. eg. a user could build a workspace
// for another user, then be deleted... we still want them to appear!
GetUsersByIDs ( ctx context . Context , ids [] uuid . UUID ) ([] User , error )
2025-03-27 10:03:53 +00:00
GetWebpushSubscriptionsByUserID ( ctx context . Context , userID uuid . UUID ) ([] WebpushSubscription , error )
GetWebpushVAPIDKeys ( ctx context . Context ) ( GetWebpushVAPIDKeysRow , error )
2025-08-25 06:11:18 -06:00
GetWorkspaceACLByID ( ctx context . Context , id uuid . UUID ) ( GetWorkspaceACLByIDRow , error )
2026-01-19 12:36:33 +00:00
GetWorkspaceAgentAndWorkspaceByID ( ctx context . Context , id uuid . UUID ) ( GetWorkspaceAgentAndWorkspaceByIDRow , error )
2022-04-11 16:06:15 -05:00
GetWorkspaceAgentByID ( ctx context . Context , id uuid . UUID ) ( WorkspaceAgent , error )
2022-03-07 11:40:54 -06:00
GetWorkspaceAgentByInstanceID ( ctx context . Context , authInstanceID string ) ( WorkspaceAgent , error )
2025-03-20 19:09:39 +02:00
GetWorkspaceAgentDevcontainersByAgentID ( ctx context . Context , workspaceAgentID uuid . UUID ) ([] WorkspaceAgentDevcontainer , error )
2023-06-20 14:41:55 +03:00
GetWorkspaceAgentLifecycleStateByID ( ctx context . Context , id uuid . UUID ) ( GetWorkspaceAgentLifecycleStateByIDRow , error )
2023-09-25 16:47:17 -05:00
GetWorkspaceAgentLogSourcesByAgentIDs ( ctx context . Context , ids [] uuid . UUID ) ([] WorkspaceAgentLogSource , error )
2023-07-28 09:57:23 -06:00
GetWorkspaceAgentLogsAfter ( ctx context . Context , arg GetWorkspaceAgentLogsAfterParams ) ([] WorkspaceAgentLog , error )
2023-10-13 16:37:55 +03:00
GetWorkspaceAgentMetadata ( ctx context . Context , arg GetWorkspaceAgentMetadataParams ) ([] WorkspaceAgentMetadatum , error )
2024-02-13 09:31:20 -05:00
GetWorkspaceAgentPortShare ( ctx context . Context , arg GetWorkspaceAgentPortShareParams ) ( WorkspaceAgentPortShare , error )
2024-10-14 09:31:03 -03:00
GetWorkspaceAgentScriptTimingsByBuildID ( ctx context . Context , id uuid . UUID ) ([] GetWorkspaceAgentScriptTimingsByBuildIDRow , error )
2023-09-25 16:47:17 -05:00
GetWorkspaceAgentScriptsByAgentIDs ( ctx context . Context , ids [] uuid . UUID ) ([] WorkspaceAgentScript , error )
2023-03-13 14:16:54 -05:00
GetWorkspaceAgentStats ( ctx context . Context , createdAt time . Time ) ([] GetWorkspaceAgentStatsRow , error )
2023-04-14 16:14:52 +02:00
GetWorkspaceAgentStatsAndLabels ( ctx context . Context , createdAt time . Time ) ([] GetWorkspaceAgentStatsAndLabelsRow , error )
2024-09-19 11:52:14 -04:00
// `minute_buckets` could return 0 rows if there are no usage stats since `created_at`.
GetWorkspaceAgentUsageStats ( ctx context . Context , createdAt time . Time ) ([] GetWorkspaceAgentUsageStatsRow , error )
GetWorkspaceAgentUsageStatsAndLabels ( ctx context . Context , createdAt time . Time ) ([] GetWorkspaceAgentUsageStatsAndLabelsRow , error )
2025-05-29 12:15:47 +01:00
GetWorkspaceAgentsByParentID ( ctx context . Context , parentID uuid . UUID ) ([] WorkspaceAgent , error )
2022-04-11 16:06:15 -05:00
GetWorkspaceAgentsByResourceIDs ( ctx context . Context , ids [] uuid . UUID ) ([] WorkspaceAgent , error )
2025-05-14 14:15:36 +02:00
GetWorkspaceAgentsByWorkspaceAndBuildNumber ( ctx context . Context , arg GetWorkspaceAgentsByWorkspaceAndBuildNumberParams ) ([] WorkspaceAgent , error )
2022-06-17 00:26:40 -05:00
GetWorkspaceAgentsCreatedAfter ( ctx context . Context , createdAt time . Time ) ([] WorkspaceAgent , error )
2025-10-17 13:40:10 -07:00
GetWorkspaceAgentsForMetrics ( ctx context . Context ) ([] GetWorkspaceAgentsForMetricsRow , error )
2023-03-31 00:24:51 +11:00
GetWorkspaceAgentsInLatestBuildByWorkspaceID ( ctx context . Context , workspaceID uuid . UUID ) ([] WorkspaceAgent , error )
2022-10-29 03:41:31 +10:00
GetWorkspaceAppByAgentIDAndSlug ( ctx context . Context , arg GetWorkspaceAppByAgentIDAndSlugParams ) ( WorkspaceApp , error )
2025-03-31 10:55:44 -04:00
GetWorkspaceAppStatusesByAppIDs ( ctx context . Context , ids [] uuid . UUID ) ([] WorkspaceAppStatus , error )
2022-06-04 15:13:37 -05:00
GetWorkspaceAppsByAgentID ( ctx context . Context , agentID uuid . UUID ) ([] WorkspaceApp , error )
GetWorkspaceAppsByAgentIDs ( ctx context . Context , ids [] uuid . UUID ) ([] WorkspaceApp , error )
2022-06-17 00:26:40 -05:00
GetWorkspaceAppsCreatedAfter ( ctx context . Context , createdAt time . Time ) ([] WorkspaceApp , error )
2023-03-10 10:39:02 -06:00
GetWorkspaceBuildByID ( ctx context . Context , id uuid . UUID ) ( WorkspaceBuild , error )
GetWorkspaceBuildByJobID ( ctx context . Context , jobID uuid . UUID ) ( WorkspaceBuild , error )
GetWorkspaceBuildByWorkspaceIDAndBuildNumber ( ctx context . Context , arg GetWorkspaceBuildByWorkspaceIDAndBuildNumberParams ) ( WorkspaceBuild , error )
2026-02-06 16:26:02 -06:00
// Returns build metadata for e2e workspace build duration metrics.
// Also checks if all agents are ready and returns the worst status.
GetWorkspaceBuildMetricsByResourceID ( ctx context . Context , id uuid . UUID ) ( GetWorkspaceBuildMetricsByResourceIDRow , error )
2023-01-17 11:22:11 +01:00
GetWorkspaceBuildParameters ( ctx context . Context , workspaceBuildID uuid . UUID ) ([] WorkspaceBuildParameter , error )
2026-02-23 22:46:17 -06:00
// Fetches the provisioner state of a workspace build, joined through to the
// template so that dbauthz can enforce policy.ActionUpdate on the template.
// Provisioner state contains sensitive Terraform state and should only be
// accessible to template administrators.
GetWorkspaceBuildProvisionerStateByID ( ctx context . Context , workspaceBuildID uuid . UUID ) ( GetWorkspaceBuildProvisionerStateByIDRow , error )
2024-09-18 09:11:44 +02:00
GetWorkspaceBuildStatsByTemplates ( ctx context . Context , since time . Time ) ([] GetWorkspaceBuildStatsByTemplatesRow , error )
2023-03-10 10:39:02 -06:00
GetWorkspaceBuildsByWorkspaceID ( ctx context . Context , arg GetWorkspaceBuildsByWorkspaceIDParams ) ([] WorkspaceBuild , error )
GetWorkspaceBuildsCreatedAfter ( ctx context . Context , createdAt time . Time ) ([] WorkspaceBuild , error )
2024-10-22 09:20:54 -05:00
GetWorkspaceByAgentID ( ctx context . Context , agentID uuid . UUID ) ( Workspace , error )
2022-01-29 17:38:32 -06:00
GetWorkspaceByID ( ctx context . Context , id uuid . UUID ) ( Workspace , error )
2022-04-25 16:11:03 -05:00
GetWorkspaceByOwnerIDAndName ( ctx context . Context , arg GetWorkspaceByOwnerIDAndNameParams ) ( Workspace , error )
2025-05-20 21:20:56 +01:00
GetWorkspaceByResourceID ( ctx context . Context , resourceID uuid . UUID ) ( Workspace , error )
2023-02-14 08:27:06 -06:00
GetWorkspaceByWorkspaceAppID ( ctx context . Context , workspaceAppID uuid . UUID ) ( Workspace , error )
2024-11-16 21:56:19 +01:00
GetWorkspaceModulesByJobID ( ctx context . Context , jobID uuid . UUID ) ([] WorkspaceModule , error )
GetWorkspaceModulesCreatedAfter ( ctx context . Context , createdAt time . Time ) ([] WorkspaceModule , error )
2023-04-04 15:07:29 -05:00
GetWorkspaceProxies ( ctx context . Context ) ([] WorkspaceProxy , error )
2023-04-17 14:57:21 -05:00
// Finds a workspace proxy that has an access URL or app hostname that matches
// the provided hostname. This is to check if a hostname matches any workspace
// proxy.
//
// The hostname must be sanitized to only contain [a-zA-Z0-9.-] before calling
// this query. The scheme, port and path should be stripped.
//
2023-04-20 16:59:45 -07:00
GetWorkspaceProxyByHostname ( ctx context . Context , arg GetWorkspaceProxyByHostnameParams ) ( WorkspaceProxy , error )
2023-04-04 15:07:29 -05:00
GetWorkspaceProxyByID ( ctx context . Context , id uuid . UUID ) ( WorkspaceProxy , error )
2023-04-20 09:48:47 -05:00
GetWorkspaceProxyByName ( ctx context . Context , name string ) ( WorkspaceProxy , error )
2022-03-07 11:40:54 -06:00
GetWorkspaceResourceByID ( ctx context . Context , id uuid . UUID ) ( WorkspaceResource , error )
2022-08-01 16:53:05 -05:00
GetWorkspaceResourceMetadataByResourceIDs ( ctx context . Context , ids [] uuid . UUID ) ([] WorkspaceResourceMetadatum , error )
2022-08-18 10:57:46 -05:00
GetWorkspaceResourceMetadataCreatedAfter ( ctx context . Context , createdAt time . Time ) ([] WorkspaceResourceMetadatum , error )
2022-03-07 11:40:54 -06:00
GetWorkspaceResourcesByJobID ( ctx context . Context , jobID uuid . UUID ) ([] WorkspaceResource , error )
2022-09-16 14:54:23 -04:00
GetWorkspaceResourcesByJobIDs ( ctx context . Context , ids [] uuid . UUID ) ([] WorkspaceResource , error )
2022-06-17 00:26:40 -05:00
GetWorkspaceResourcesCreatedAfter ( ctx context . Context , createdAt time . Time ) ([] WorkspaceResource , error )
2023-12-07 10:53:15 -05:00
GetWorkspaceUniqueOwnerCountByTemplateIDs ( ctx context . Context , templateIds [] uuid . UUID ) ([] GetWorkspaceUniqueOwnerCountByTemplateIDsRow , error )
2024-03-22 14:22:47 -05:00
// build_params is used to filter by build parameters if present.
// It has to be a CTE because the set returning function 'unnest' cannot
// be used in a WHERE clause.
2022-11-16 10:16:37 -05:00
GetWorkspaces ( ctx context . Context , arg GetWorkspacesParams ) ([] GetWorkspacesRow , error )
2024-11-01 14:36:12 +11:00
GetWorkspacesAndAgentsByOwnerID ( ctx context . Context , ownerID uuid . UUID ) ([] GetWorkspacesAndAgentsByOwnerIDRow , error )
2024-12-02 21:02:36 +00:00
GetWorkspacesByTemplateID ( ctx context . Context , templateID uuid . UUID ) ([] WorkspaceTable , error )
2024-11-13 10:24:20 +00:00
GetWorkspacesEligibleForTransition ( ctx context . Context , now time . Time ) ([] GetWorkspacesEligibleForTransitionRow , error )
2025-10-17 13:40:10 -07:00
GetWorkspacesForWorkspaceMetrics ( ctx context . Context ) ([] GetWorkspacesForWorkspaceMetricsRow , error )
2025-09-16 21:31:17 +02:00
InsertAIBridgeInterception ( ctx context . Context , arg InsertAIBridgeInterceptionParams ) ( AIBridgeInterception , error )
2025-09-26 16:20:33 +02:00
InsertAIBridgeTokenUsage ( ctx context . Context , arg InsertAIBridgeTokenUsageParams ) ( AIBridgeTokenUsage , error )
InsertAIBridgeToolUsage ( ctx context . Context , arg InsertAIBridgeToolUsageParams ) ( AIBridgeToolUsage , error )
InsertAIBridgeUserPrompt ( ctx context . Context , arg InsertAIBridgeUserPromptParams ) ( AIBridgeUserPrompt , error )
2022-01-20 07:46:51 -06:00
InsertAPIKey ( ctx context . Context , arg InsertAPIKeyParams ) ( APIKey , error )
2022-10-10 15:37:06 -05:00
// We use the organization_id as the id
// for simplicity since all users is
// every member of the org.
InsertAllUsersGroup ( ctx context . Context , organizationID uuid . UUID ) ( Group , error )
2022-05-02 14:30:46 -05:00
InsertAuditLog ( ctx context . Context , arg InsertAuditLogParams ) ( AuditLog , error )
2026-02-27 11:50:56 -05:00
InsertChat ( ctx context . Context , arg InsertChatParams ) ( Chat , error )
2026-03-06 21:05:26 +02:00
InsertChatFile ( ctx context . Context , arg InsertChatFileParams ) ( InsertChatFileRow , error )
2026-02-27 11:50:56 -05:00
InsertChatMessage ( ctx context . Context , arg InsertChatMessageParams ) ( ChatMessage , error )
InsertChatModelConfig ( ctx context . Context , arg InsertChatModelConfigParams ) ( ChatModelConfig , error )
InsertChatProvider ( ctx context . Context , arg InsertChatProviderParams ) ( ChatProvider , error )
InsertChatQueuedMessage ( ctx context . Context , arg InsertChatQueuedMessageParams ) ( ChatQueuedMessage , error )
2024-09-17 18:08:18 +01:00
InsertCryptoKey ( ctx context . Context , arg InsertCryptoKeyParams ) ( CryptoKey , error )
2024-08-13 12:53:47 -05:00
InsertCustomRole ( ctx context . Context , arg InsertCustomRoleParams ) ( CustomRole , error )
2023-09-06 12:06:26 +01:00
InsertDBCryptKey ( ctx context . Context , arg InsertDBCryptKeyParams ) error
2022-10-17 08:43:30 -05:00
InsertDERPMeshKey ( ctx context . Context , value string ) error
2022-06-17 00:26:40 -05:00
InsertDeploymentID ( ctx context . Context , value string ) error
2023-09-29 14:13:20 -05:00
InsertExternalAuthLink ( ctx context . Context , arg InsertExternalAuthLinkParams ) ( ExternalAuthLink , error )
2022-02-07 15:32:37 -06:00
InsertFile ( ctx context . Context , arg InsertFileParams ) ( File , error )
2022-04-05 19:18:26 -05:00
InsertGitSSHKey ( ctx context . Context , arg InsertGitSSHKeyParams ) ( GitSSHKey , error )
2022-10-10 15:37:06 -05:00
InsertGroup ( ctx context . Context , arg InsertGroupParams ) ( Group , error )
InsertGroupMember ( ctx context . Context , arg InsertGroupMemberParams ) error
2025-03-03 10:12:48 +01:00
InsertInboxNotification ( ctx context . Context , arg InsertInboxNotificationParams ) ( InboxNotification , error )
2022-08-22 15:02:50 -07:00
InsertLicense ( ctx context . Context , arg InsertLicenseParams ) ( License , error )
2025-02-04 18:45:33 +01:00
InsertMemoryResourceMonitor ( ctx context . Context , arg InsertMemoryResourceMonitorParams ) ( WorkspaceAgentMemoryResourceMonitor , error )
2023-08-08 11:37:49 -05:00
// Inserts any group by name that does not exist. All new groups are given
// a random uuid, are inserted into the same organization. They have the default
// values for avatar, display name, and quota allowance (all zero values).
// If the name conflicts, do nothing.
InsertMissingGroups ( ctx context . Context , arg InsertMissingGroupsParams ) ([] Group , error )
2023-12-21 12:38:42 -09:00
InsertOAuth2ProviderApp ( ctx context . Context , arg InsertOAuth2ProviderAppParams ) ( OAuth2ProviderApp , error )
2024-02-20 15:58:43 -08:00
InsertOAuth2ProviderAppCode ( ctx context . Context , arg InsertOAuth2ProviderAppCodeParams ) ( OAuth2ProviderAppCode , error )
2023-12-21 12:38:42 -09:00
InsertOAuth2ProviderAppSecret ( ctx context . Context , arg InsertOAuth2ProviderAppSecretParams ) ( OAuth2ProviderAppSecret , error )
2024-02-20 15:58:43 -08:00
InsertOAuth2ProviderAppToken ( ctx context . Context , arg InsertOAuth2ProviderAppTokenParams ) ( OAuth2ProviderAppToken , error )
2022-01-22 23:58:10 -06:00
InsertOrganization ( ctx context . Context , arg InsertOrganizationParams ) ( Organization , error )
InsertOrganizationMember ( ctx context . Context , arg InsertOrganizationMemberParams ) ( OrganizationMember , error )
2025-02-11 13:55:09 +02:00
InsertPreset ( ctx context . Context , arg InsertPresetParams ) ( TemplateVersionPreset , error )
InsertPresetParameters ( ctx context . Context , arg InsertPresetParametersParams ) ([] TemplateVersionPresetParameter , error )
2025-06-19 11:08:48 -04:00
InsertPresetPrebuildSchedule ( ctx context . Context , arg InsertPresetPrebuildScheduleParams ) ( TemplateVersionPresetPrebuildSchedule , error )
2022-01-29 17:38:32 -06:00
InsertProvisionerJob ( ctx context . Context , arg InsertProvisionerJobParams ) ( ProvisionerJob , error )
2022-02-07 15:32:37 -06:00
InsertProvisionerJobLogs ( ctx context . Context , arg InsertProvisionerJobLogsParams ) ([] ProvisionerJobLog , error )
2024-08-21 14:18:58 +02:00
InsertProvisionerJobTimings ( ctx context . Context , arg InsertProvisionerJobTimingsParams ) ([] ProvisionerJobTiming , error )
2024-07-16 13:27:12 -04:00
InsertProvisionerKey ( ctx context . Context , arg InsertProvisionerKeyParams ) ( ProvisionerKey , error )
2022-10-17 08:43:30 -05:00
InsertReplica ( ctx context . Context , arg InsertReplicaParams ) ( Replica , error )
2025-10-13 12:25:58 +03:00
InsertTask ( ctx context . Context , arg InsertTaskParams ) ( TaskTable , error )
2025-01-31 13:55:46 +01:00
InsertTelemetryItemIfNotExists ( ctx context . Context , arg InsertTelemetryItemIfNotExistsParams ) error
2025-10-28 03:16:41 +11:00
// Inserts a new lock row into the telemetry_locks table. Replicas should call
// this function prior to attempting to generate or publish a heartbeat event to
// the telemetry service.
// If the query returns a duplicate primary key error, the replica should not
// attempt to generate or publish the event to the telemetry service.
InsertTelemetryLock ( ctx context . Context , arg InsertTelemetryLockParams ) error
2023-07-19 16:07:33 -04:00
InsertTemplate ( ctx context . Context , arg InsertTemplateParams ) error
2023-07-25 09:14:38 -04:00
InsertTemplateVersion ( ctx context . Context , arg InsertTemplateVersionParams ) error
2023-01-17 11:22:11 +01:00
InsertTemplateVersionParameter ( ctx context . Context , arg InsertTemplateVersionParameterParams ) ( TemplateVersionParameter , error )
2025-03-24 10:01:50 -06:00
InsertTemplateVersionTerraformValuesByJobID ( ctx context . Context , arg InsertTemplateVersionTerraformValuesByJobIDParams ) error
2023-02-15 18:24:15 +01:00
InsertTemplateVersionVariable ( ctx context . Context , arg InsertTemplateVersionVariableParams ) ( TemplateVersionVariable , error )
2024-05-20 15:30:19 +02:00
InsertTemplateVersionWorkspaceTag ( ctx context . Context , arg InsertTemplateVersionWorkspaceTagParams ) ( TemplateVersionWorkspaceTag , error )
2025-08-16 01:31:00 +10:00
// Duplicate events are ignored intentionally to allow for multiple replicas to
// publish heartbeat events.
InsertUsageEvent ( ctx context . Context , arg InsertUsageEventParams ) error
2022-01-20 07:46:51 -06:00
InsertUser ( ctx context . Context , arg InsertUserParams ) ( User , error )
2024-09-11 13:43:50 -05:00
// InsertUserGroupsByID adds a user to all provided groups, if they exist.
// If there is a conflict, the user is already a member
InsertUserGroupsByID ( ctx context . Context , arg InsertUserGroupsByIDParams ) ([] uuid . UUID , error )
2022-08-17 18:00:53 -05:00
InsertUserLink ( ctx context . Context , arg InsertUserLinkParams ) ( UserLink , error )
2025-02-04 18:45:33 +01:00
InsertVolumeResourceMonitor ( ctx context . Context , arg InsertVolumeResourceMonitorParams ) ( WorkspaceAgentVolumeResourceMonitor , error )
2025-03-27 10:03:53 +00:00
InsertWebpushSubscription ( ctx context . Context , arg InsertWebpushSubscriptionParams ) ( WebpushSubscription , error )
2024-10-22 09:20:54 -05:00
InsertWorkspace ( ctx context . Context , arg InsertWorkspaceParams ) ( WorkspaceTable , error )
2022-03-07 11:40:54 -06:00
InsertWorkspaceAgent ( ctx context . Context , arg InsertWorkspaceAgentParams ) ( WorkspaceAgent , error )
2025-03-20 19:09:39 +02:00
InsertWorkspaceAgentDevcontainers ( ctx context . Context , arg InsertWorkspaceAgentDevcontainersParams ) ([] WorkspaceAgentDevcontainer , error )
2023-09-25 16:47:17 -05:00
InsertWorkspaceAgentLogSources ( ctx context . Context , arg InsertWorkspaceAgentLogSourcesParams ) ([] WorkspaceAgentLogSource , error )
2023-07-28 09:57:23 -06:00
InsertWorkspaceAgentLogs ( ctx context . Context , arg InsertWorkspaceAgentLogsParams ) ([] WorkspaceAgentLog , error )
2023-03-31 15:26:19 -05:00
InsertWorkspaceAgentMetadata ( ctx context . Context , arg InsertWorkspaceAgentMetadataParams ) error
2024-10-14 09:31:03 -03:00
InsertWorkspaceAgentScriptTimings ( ctx context . Context , arg InsertWorkspaceAgentScriptTimingsParams ) ( WorkspaceAgentScriptTiming , error )
2023-09-25 16:47:17 -05:00
InsertWorkspaceAgentScripts ( ctx context . Context , arg InsertWorkspaceAgentScriptsParams ) ([] WorkspaceAgentScript , error )
2023-08-04 17:00:42 +01:00
InsertWorkspaceAgentStats ( ctx context . Context , arg InsertWorkspaceAgentStatsParams ) error
2023-08-16 15:22:00 +03:00
InsertWorkspaceAppStats ( ctx context . Context , arg InsertWorkspaceAppStatsParams ) error
2025-03-31 10:55:44 -04:00
InsertWorkspaceAppStatus ( ctx context . Context , arg InsertWorkspaceAppStatusParams ) ( WorkspaceAppStatus , error )
2023-07-25 09:14:38 -04:00
InsertWorkspaceBuild ( ctx context . Context , arg InsertWorkspaceBuildParams ) error
2023-01-17 11:22:11 +01:00
InsertWorkspaceBuildParameters ( ctx context . Context , arg InsertWorkspaceBuildParametersParams ) error
2024-11-16 21:56:19 +01:00
InsertWorkspaceModule ( ctx context . Context , arg InsertWorkspaceModuleParams ) ( WorkspaceModule , error )
2023-04-04 15:07:29 -05:00
InsertWorkspaceProxy ( ctx context . Context , arg InsertWorkspaceProxyParams ) ( WorkspaceProxy , error )
2022-03-07 11:40:54 -06:00
InsertWorkspaceResource ( ctx context . Context , arg InsertWorkspaceResourceParams ) ( WorkspaceResource , error )
2022-12-14 13:08:22 -06:00
InsertWorkspaceResourceMetadata ( ctx context . Context , arg InsertWorkspaceResourceMetadataParams ) ([] WorkspaceResourceMetadatum , error )
2025-10-22 16:18:31 +11:00
ListAIBridgeInterceptions ( ctx context . Context , arg ListAIBridgeInterceptionsParams ) ([] ListAIBridgeInterceptionsRow , error )
2025-11-24 18:09:04 +05:00
// Finds all unique AI Bridge interception telemetry summaries combinations
2025-10-28 03:16:41 +11:00
// (provider, model, client) in the given timeframe for telemetry reporting.
ListAIBridgeInterceptionsTelemetrySummaries ( ctx context . Context , arg ListAIBridgeInterceptionsTelemetrySummariesParams ) ([] ListAIBridgeInterceptionsTelemetrySummariesRow , error )
2026-02-26 02:40:45 +11:00
ListAIBridgeModels ( ctx context . Context , arg ListAIBridgeModelsParams ) ([] string , error )
2025-09-26 16:20:33 +02:00
ListAIBridgeTokenUsagesByInterceptionIDs ( ctx context . Context , interceptionIds [] uuid . UUID ) ([] AIBridgeTokenUsage , error )
ListAIBridgeToolUsagesByInterceptionIDs ( ctx context . Context , interceptionIds [] uuid . UUID ) ([] AIBridgeToolUsage , error )
ListAIBridgeUserPromptsByInterceptionIDs ( ctx context . Context , interceptionIds [] uuid . UUID ) ([] AIBridgeUserPrompt , error )
2024-07-16 13:27:12 -04:00
ListProvisionerKeysByOrganization ( ctx context . Context , organizationID uuid . UUID ) ([] ProvisionerKey , error )
2024-09-16 16:02:08 -04:00
ListProvisionerKeysByOrganizationExcludeReserved ( ctx context . Context , organizationID uuid . UUID ) ([] ProvisionerKey , error )
2025-10-14 17:33:30 +01:00
ListTasks ( ctx context . Context , arg ListTasksParams ) ([] Task , error )
2025-08-07 15:58:59 -04:00
ListUserSecrets ( ctx context . Context , userID uuid . UUID ) ([] UserSecret , error )
2024-02-13 09:31:20 -05:00
ListWorkspaceAgentPortShares ( ctx context . Context , workspaceID uuid . UUID ) ([] WorkspaceAgentPortShare , error )
2025-03-20 13:41:54 +01:00
MarkAllInboxNotificationsAsRead ( ctx context . Context , arg MarkAllInboxNotificationsAsReadParams ) error
2024-11-21 13:04:00 -06:00
OIDCClaimFieldValues ( ctx context . Context , arg OIDCClaimFieldValuesParams ) ([] string , error )
2024-11-18 14:31:39 -06:00
// OIDCClaimFields returns a list of distinct keys in the the merged_claims fields.
// This query is used to generate the list of available sync fields for idp sync settings.
OIDCClaimFields ( ctx context . Context , organizationID uuid . UUID ) ([] string , error )
2024-06-12 09:23:48 -10:00
// Arguments are optional with uuid.Nil to ignore.
// - Use just 'organization_id' to get all members of an org
// - Use just 'user_id' to get all orgs a user is a member of
// - Use both to get a specific org member row
OrganizationMembers ( ctx context . Context , arg OrganizationMembersParams ) ([] OrganizationMembersRow , error )
2025-03-10 14:42:07 -04:00
PaginatedOrganizationMembers ( ctx context . Context , arg PaginatedOrganizationMembersParams ) ([] PaginatedOrganizationMembersRow , error )
2026-02-27 11:50:56 -05:00
PopNextQueuedMessage ( ctx context . Context , chatID uuid . UUID ) ( ChatQueuedMessage , error )
2024-03-05 13:47:01 -05:00
ReduceWorkspaceAgentShareLevelToAuthenticatedByTemplate ( ctx context . Context , templateID uuid . UUID ) error
2023-04-20 09:48:47 -05:00
RegisterWorkspaceProxy ( ctx context . Context , arg RegisterWorkspaceProxyParams ) ( WorkspaceProxy , error )
2024-09-11 13:43:50 -05:00
RemoveUserFromGroups ( ctx context . Context , arg RemoveUserFromGroupsParams ) ([] uuid . UUID , error )
2023-09-06 12:06:26 +01:00
RevokeDBCryptKey ( ctx context . Context , activeKeyDigest string ) error
2025-08-16 01:31:00 +10:00
// Note that this selects from the CTE, not the original table. The CTE is named
// the same as the original table to trick sqlc into reusing the existing struct
// for the table.
// The CTE and the reorder is required because UPDATE doesn't guarantee order.
SelectUsageEventsForPublishing ( ctx context . Context , now time . Time ) ([] UsageEvent , error )
2023-03-08 06:38:11 +11:00
// Non blocking lock. Returns true if the lock was acquired, false otherwise.
//
// This must be called from within a transaction. The lock will be automatically
// released when the transaction ends.
TryAcquireLock ( ctx context . Context , pgTryAdvisoryXactLock int64 ) ( bool , error )
2026-02-27 16:46:19 -05:00
UnarchiveChatByID ( ctx context . Context , id uuid . UUID ) error
2023-10-10 10:52:42 -05:00
// This will always work regardless of the current state of the template version.
UnarchiveTemplateVersion ( ctx context . Context , arg UnarchiveTemplateVersionParams ) error
2024-01-24 13:39:19 +00:00
UnfavoriteWorkspace ( ctx context . Context , id uuid . UUID ) error
2026-02-27 11:50:56 -05:00
UnsetDefaultChatModelConfigs ( ctx context . Context ) error
2025-10-27 09:51:37 +01:00
UpdateAIBridgeInterceptionEnded ( ctx context . Context , arg UpdateAIBridgeInterceptionEndedParams ) ( AIBridgeInterception , error )
2022-01-20 07:46:51 -06:00
UpdateAPIKeyByID ( ctx context . Context , arg UpdateAPIKeyByIDParams ) error
2026-02-27 11:50:56 -05:00
UpdateChatByID ( ctx context . Context , arg UpdateChatByIDParams ) ( Chat , error )
// Bumps the heartbeat timestamp for a running chat so that other
// replicas know the worker is still alive.
UpdateChatHeartbeat ( ctx context . Context , arg UpdateChatHeartbeatParams ) ( int64 , error )
UpdateChatMessageByID ( ctx context . Context , arg UpdateChatMessageByIDParams ) ( ChatMessage , error )
UpdateChatModelConfig ( ctx context . Context , arg UpdateChatModelConfigParams ) ( ChatModelConfig , error )
UpdateChatProvider ( ctx context . Context , arg UpdateChatProviderParams ) ( ChatProvider , error )
UpdateChatStatus ( ctx context . Context , arg UpdateChatStatusParams ) ( Chat , error )
UpdateChatWorkspace ( ctx context . Context , arg UpdateChatWorkspaceParams ) ( Chat , error )
2024-09-17 18:08:18 +01:00
UpdateCryptoKeyDeletesAt ( ctx context . Context , arg UpdateCryptoKeyDeletesAtParams ) ( CryptoKey , error )
2024-08-13 12:53:47 -05:00
UpdateCustomRole ( ctx context . Context , arg UpdateCustomRoleParams ) ( CustomRole , error )
2023-09-29 14:13:20 -05:00
UpdateExternalAuthLink ( ctx context . Context , arg UpdateExternalAuthLinkParams ) ( ExternalAuthLink , error )
2026-03-10 10:52:55 -07:00
// Optimistic lock: only update the row if the refresh token in the database
// still matches the one we read before attempting the refresh. This prevents
// a concurrent caller that lost a token-refresh race from overwriting a valid
// token stored by the winner.
2024-12-03 19:26:31 +00:00
UpdateExternalAuthLinkRefreshToken ( ctx context . Context , arg UpdateExternalAuthLinkRefreshTokenParams ) error
2022-10-14 16:25:46 -05:00
UpdateGitSSHKey ( ctx context . Context , arg UpdateGitSSHKeyParams ) ( GitSSHKey , error )
2022-10-10 15:37:06 -05:00
UpdateGroupByID ( ctx context . Context , arg UpdateGroupByIDParams ) ( Group , error )
2023-08-02 16:31:25 +02:00
UpdateInactiveUsersToDormant ( ctx context . Context , arg UpdateInactiveUsersToDormantParams ) ([] UpdateInactiveUsersToDormantRow , error )
2025-03-03 10:12:48 +01:00
UpdateInboxNotificationReadStatus ( ctx context . Context , arg UpdateInboxNotificationReadStatusParams ) error
2022-04-29 09:04:19 -05:00
UpdateMemberRoles ( ctx context . Context , arg UpdateMemberRolesParams ) ( OrganizationMember , error )
2025-02-17 16:56:52 +00:00
UpdateMemoryResourceMonitor ( ctx context . Context , arg UpdateMemoryResourceMonitorParams ) error
2024-08-05 16:18:45 +02:00
UpdateNotificationTemplateMethodByID ( ctx context . Context , arg UpdateNotificationTemplateMethodByIDParams ) ( NotificationTemplate , error )
2025-07-03 18:33:47 +02:00
UpdateOAuth2ProviderAppByClientID ( ctx context . Context , arg UpdateOAuth2ProviderAppByClientIDParams ) ( OAuth2ProviderApp , error )
2023-12-21 12:38:42 -09:00
UpdateOAuth2ProviderAppByID ( ctx context . Context , arg UpdateOAuth2ProviderAppByIDParams ) ( OAuth2ProviderApp , error )
2024-05-21 12:46:31 -06:00
UpdateOrganization ( ctx context . Context , arg UpdateOrganizationParams ) ( Organization , error )
2025-02-24 17:59:41 +00:00
UpdateOrganizationDeletedByID ( ctx context . Context , arg UpdateOrganizationDeletedByIDParams ) error
2026-01-14 09:47:50 -08:00
UpdateOrganizationWorkspaceSharingSettings ( ctx context . Context , arg UpdateOrganizationWorkspaceSharingSettingsParams ) ( Organization , error )
2025-10-24 15:27:49 +01:00
// Cancels all pending provisioner jobs for prebuilt workspaces on a specific preset from an
// inactive template version.
// This is an optimization to clean up stale pending jobs.
2025-10-29 10:37:28 +00:00
UpdatePrebuildProvisionerJobWithCancel ( ctx context . Context , arg UpdatePrebuildProvisionerJobWithCancelParams ) ([] UpdatePrebuildProvisionerJobWithCancelRow , error )
2025-05-21 15:16:38 -04:00
UpdatePresetPrebuildStatus ( ctx context . Context , arg UpdatePresetPrebuildStatusParams ) error
2025-11-20 17:12:25 +01:00
UpdatePresetsLastInvalidatedAt ( ctx context . Context , arg UpdatePresetsLastInvalidatedAtParams ) ([] UpdatePresetsLastInvalidatedAtRow , error )
2023-12-18 16:44:52 +00:00
UpdateProvisionerDaemonLastSeenAt ( ctx context . Context , arg UpdateProvisionerDaemonLastSeenAtParams ) error
2022-01-29 17:38:32 -06:00
UpdateProvisionerJobByID ( ctx context . Context , arg UpdateProvisionerJobByIDParams ) error
2025-07-30 19:09:53 -05:00
UpdateProvisionerJobLogsLength ( ctx context . Context , arg UpdateProvisionerJobLogsLengthParams ) error
UpdateProvisionerJobLogsOverflowed ( ctx context . Context , arg UpdateProvisionerJobLogsOverflowedParams ) error
2022-03-22 13:17:50 -06:00
UpdateProvisionerJobWithCancelByID ( ctx context . Context , arg UpdateProvisionerJobWithCancelByIDParams ) error
2022-02-03 19:13:22 -06:00
UpdateProvisionerJobWithCompleteByID ( ctx context . Context , arg UpdateProvisionerJobWithCompleteByIDParams ) error
2025-05-20 15:22:44 +02:00
UpdateProvisionerJobWithCompleteWithStartedAtByID ( ctx context . Context , arg UpdateProvisionerJobWithCompleteWithStartedAtByIDParams ) error
2022-10-17 08:43:30 -05:00
UpdateReplica ( ctx context . Context , arg UpdateReplicaParams ) ( Replica , error )
2024-08-14 15:16:08 -04:00
UpdateTailnetPeerStatusByCoordinator ( ctx context . Context , arg UpdateTailnetPeerStatusByCoordinatorParams ) error
2025-11-25 11:13:32 +00:00
UpdateTaskPrompt ( ctx context . Context , arg UpdateTaskPromptParams ) ( TaskTable , error )
2025-10-23 19:12:09 +03:00
UpdateTaskWorkspaceID ( ctx context . Context , arg UpdateTaskWorkspaceIDParams ) ( TaskTable , error )
2023-07-19 16:07:33 -04:00
UpdateTemplateACLByID ( ctx context . Context , arg UpdateTemplateACLByIDParams ) error
2023-10-18 17:07:21 -05:00
UpdateTemplateAccessControlByID ( ctx context . Context , arg UpdateTemplateAccessControlByIDParams ) error
2022-04-06 12:42:40 -05:00
UpdateTemplateActiveVersionByID ( ctx context . Context , arg UpdateTemplateActiveVersionByIDParams ) error
UpdateTemplateDeletedByID ( ctx context . Context , arg UpdateTemplateDeletedByIDParams ) error
2023-07-19 16:07:33 -04:00
UpdateTemplateMetaByID ( ctx context . Context , arg UpdateTemplateMetaByIDParams ) error
UpdateTemplateScheduleByID ( ctx context . Context , arg UpdateTemplateScheduleByIDParams ) error
2023-07-25 09:14:38 -04:00
UpdateTemplateVersionByID ( ctx context . Context , arg UpdateTemplateVersionByIDParams ) error
2022-05-17 15:00:48 -05:00
UpdateTemplateVersionDescriptionByJobID ( ctx context . Context , arg UpdateTemplateVersionDescriptionByJobIDParams ) error
2023-09-29 14:13:20 -05:00
UpdateTemplateVersionExternalAuthProvidersByJobID ( ctx context . Context , arg UpdateTemplateVersionExternalAuthProvidersByJobIDParams ) error
2025-08-19 10:29:51 +02:00
UpdateTemplateVersionFlagsByJobID ( ctx context . Context , arg UpdateTemplateVersionFlagsByJobIDParams ) error
2023-08-22 15:15:13 -05:00
UpdateTemplateWorkspacesLastUsedAt ( ctx context . Context , arg UpdateTemplateWorkspacesLastUsedAtParams ) error
2025-08-16 01:31:00 +10:00
UpdateUsageEventsPostPublish ( ctx context . Context , arg UpdateUsageEventsPostPublishParams ) error
2026-03-10 08:17:52 -07:00
UpdateUserChatCustomPrompt ( ctx context . Context , arg UpdateUserChatCustomPromptParams ) ( UserConfig , error )
2024-02-20 13:19:38 -06:00
UpdateUserDeletedByID ( ctx context . Context , id uuid . UUID ) error
2024-08-02 11:49:36 -05:00
UpdateUserGithubComUserID ( ctx context . Context , arg UpdateUserGithubComUserIDParams ) error
2024-10-04 11:53:25 +01:00
UpdateUserHashedOneTimePasscode ( ctx context . Context , arg UpdateUserHashedOneTimePasscodeParams ) error
2022-05-06 09:20:08 -05:00
UpdateUserHashedPassword ( ctx context . Context , arg UpdateUserHashedPasswordParams ) error
2022-09-26 10:31:03 -05:00
UpdateUserLastSeenAt ( ctx context . Context , arg UpdateUserLastSeenAtParams ) ( User , error )
2022-08-17 18:00:53 -05:00
UpdateUserLink ( ctx context . Context , arg UpdateUserLinkParams ) ( UserLink , error )
2023-06-30 08:38:48 -04:00
UpdateUserLoginType ( ctx context . Context , arg UpdateUserLoginTypeParams ) ( User , error )
2024-08-05 16:18:45 +02:00
UpdateUserNotificationPreferences ( ctx context . Context , arg UpdateUserNotificationPreferencesParams ) ( int64 , error )
2022-04-12 11:05:21 -03:00
UpdateUserProfile ( ctx context . Context , arg UpdateUserProfileParams ) ( User , error )
2023-07-20 06:35:41 -07:00
UpdateUserQuietHoursSchedule ( ctx context . Context , arg UpdateUserQuietHoursScheduleParams ) ( User , error )
2022-04-29 09:04:19 -05:00
UpdateUserRoles ( ctx context . Context , arg UpdateUserRolesParams ) ( User , error )
2025-08-07 15:58:59 -04:00
UpdateUserSecret ( ctx context . Context , arg UpdateUserSecretParams ) ( UserSecret , error )
2022-04-26 09:00:07 -05:00
UpdateUserStatus ( ctx context . Context , arg UpdateUserStatusParams ) ( User , error )
2025-11-28 16:50:59 +00:00
UpdateUserTaskNotificationAlertDismissed ( ctx context . Context , arg UpdateUserTaskNotificationAlertDismissedParams ) ( bool , error )
2025-04-07 14:30:10 +02:00
UpdateUserTerminalFont ( ctx context . Context , arg UpdateUserTerminalFontParams ) ( UserConfig , error )
UpdateUserThemePreference ( ctx context . Context , arg UpdateUserThemePreferenceParams ) ( UserConfig , error )
2025-02-17 16:56:52 +00:00
UpdateVolumeResourceMonitor ( ctx context . Context , arg UpdateVolumeResourceMonitorParams ) error
2024-10-22 09:20:54 -05:00
UpdateWorkspace ( ctx context . Context , arg UpdateWorkspaceParams ) ( WorkspaceTable , error )
2025-07-31 09:05:09 -06:00
UpdateWorkspaceACLByID ( ctx context . Context , arg UpdateWorkspaceACLByIDParams ) error
2022-03-22 13:17:50 -06:00
UpdateWorkspaceAgentConnectionByID ( ctx context . Context , arg UpdateWorkspaceAgentConnectionByIDParams ) error
2026-02-04 15:33:48 +00:00
UpdateWorkspaceAgentDisplayAppsByID ( ctx context . Context , arg UpdateWorkspaceAgentDisplayAppsByIDParams ) error
2023-01-24 14:24:27 +02:00
UpdateWorkspaceAgentLifecycleStateByID ( ctx context . Context , arg UpdateWorkspaceAgentLifecycleStateByIDParams ) error
2023-07-28 09:57:23 -06:00
UpdateWorkspaceAgentLogOverflowByID ( ctx context . Context , arg UpdateWorkspaceAgentLogOverflowByIDParams ) error
2023-03-31 15:26:19 -05:00
UpdateWorkspaceAgentMetadata ( ctx context . Context , arg UpdateWorkspaceAgentMetadataParams ) error
2023-02-07 15:35:09 -06:00
UpdateWorkspaceAgentStartupByID ( ctx context . Context , arg UpdateWorkspaceAgentStartupByIDParams ) error
2022-09-23 15:51:04 -04:00
UpdateWorkspaceAppHealthByID ( ctx context . Context , arg UpdateWorkspaceAppHealthByIDParams ) error
2023-10-06 13:27:12 +04:00
UpdateWorkspaceAutomaticUpdates ( ctx context . Context , arg UpdateWorkspaceAutomaticUpdatesParams ) error
2022-04-07 10:03:35 +01:00
UpdateWorkspaceAutostart ( ctx context . Context , arg UpdateWorkspaceAutostartParams ) error
2023-07-25 09:14:38 -04:00
UpdateWorkspaceBuildCostByID ( ctx context . Context , arg UpdateWorkspaceBuildCostByIDParams ) error
2023-09-22 16:22:07 +01:00
UpdateWorkspaceBuildDeadlineByID ( ctx context . Context , arg UpdateWorkspaceBuildDeadlineByIDParams ) error
2025-08-19 10:29:51 +02:00
UpdateWorkspaceBuildFlagsByID ( ctx context . Context , arg UpdateWorkspaceBuildFlagsByIDParams ) error
2023-09-22 16:22:07 +01:00
UpdateWorkspaceBuildProvisionerStateByID ( ctx context . Context , arg UpdateWorkspaceBuildProvisionerStateByIDParams ) error
2022-03-22 13:17:50 -06:00
UpdateWorkspaceDeletedByID ( ctx context . Context , arg UpdateWorkspaceDeletedByIDParams ) error
2024-10-22 09:20:54 -05:00
UpdateWorkspaceDormantDeletingAt ( ctx context . Context , arg UpdateWorkspaceDormantDeletingAtParams ) ( WorkspaceTable , error )
2022-09-01 19:08:51 -05:00
UpdateWorkspaceLastUsedAt ( ctx context . Context , arg UpdateWorkspaceLastUsedAtParams ) error
2024-12-02 21:02:36 +00:00
UpdateWorkspaceNextStartAt ( ctx context . Context , arg UpdateWorkspaceNextStartAtParams ) error
2023-05-09 13:46:50 -05:00
// This allows editing the properties of a workspace proxy.
UpdateWorkspaceProxy ( ctx context . Context , arg UpdateWorkspaceProxyParams ) ( WorkspaceProxy , error )
2023-04-04 15:07:29 -05:00
UpdateWorkspaceProxyDeleted ( ctx context . Context , arg UpdateWorkspaceProxyDeletedParams ) error
2022-05-19 20:09:27 +01:00
UpdateWorkspaceTTL ( ctx context . Context , arg UpdateWorkspaceTTLParams ) error
2024-10-22 09:20:54 -05:00
UpdateWorkspacesDormantDeletingAtByTemplateID ( ctx context . Context , arg UpdateWorkspacesDormantDeletingAtByTemplateIDParams ) ([] WorkspaceTable , error )
2024-12-06 11:01:39 +00:00
UpdateWorkspacesTTLByTemplateID ( ctx context . Context , arg UpdateWorkspacesTTLByTemplateIDParams ) error
2024-05-31 10:59:28 -06:00
UpsertAnnouncementBanners ( ctx context . Context , value string ) error
2023-09-27 17:02:18 +02:00
UpsertApplicationName ( ctx context . Context , value string ) error
2026-02-02 09:11:54 -07:00
// Upserts boundary usage statistics for a replica. On INSERT (new period), uses
// delta values for unique counts (only data since last flush). On UPDATE, uses
// cumulative values for unique counts (accurate period totals). Request counts
// are always deltas, accumulated in DB. Returns true if insert, false if update.
2026-01-27 13:29:21 -07:00
UpsertBoundaryUsageStats ( ctx context . Context , arg UpsertBoundaryUsageStatsParams ) ( bool , error )
2026-02-27 11:50:56 -05:00
UpsertChatDiffStatus ( ctx context . Context , arg UpsertChatDiffStatusParams ) ( ChatDiffStatus , error )
UpsertChatDiffStatusReference ( ctx context . Context , arg UpsertChatDiffStatusReferenceParams ) ( ChatDiffStatus , error )
2026-03-10 11:46:53 +00:00
UpsertChatSystemPrompt ( ctx context . Context , value string ) error
2025-07-15 14:36:06 +10:00
UpsertConnectionLog ( ctx context . Context , arg UpsertConnectionLogParams ) ( ConnectionLog , error )
2023-06-08 10:30:15 -05:00
// The default proxy is implied and not actually stored in the database.
// So we need to store it's configuration here for display purposes.
// The functional values are immutable and controlled implicitly.
UpsertDefaultProxy ( ctx context . Context , arg UpsertDefaultProxyParams ) error
2023-11-23 17:18:12 +01:00
UpsertHealthSettings ( ctx context . Context , value string ) error
2023-03-27 19:55:10 -05:00
UpsertLastUpdateCheck ( ctx context . Context , value string ) error
UpsertLogoURL ( ctx context . Context , value string ) error
2024-09-18 09:11:44 +02:00
// Insert or update notification report generator logs with recent activity.
UpsertNotificationReportGeneratorLog ( ctx context . Context , arg UpsertNotificationReportGeneratorLogParams ) error
2024-07-10 16:15:06 +02:00
UpsertNotificationsSettings ( ctx context . Context , value string ) error
2025-02-25 16:31:33 +01:00
UpsertOAuth2GithubDefaultEligible ( ctx context . Context , eligible bool ) error
2025-07-02 17:05:42 +02:00
UpsertPrebuildsSettings ( ctx context . Context , value string ) error
2023-12-13 12:31:40 +00:00
UpsertProvisionerDaemon ( ctx context . Context , arg UpsertProvisionerDaemonParams ) ( ProvisionerDaemon , error )
2024-09-09 14:14:52 -05:00
UpsertRuntimeConfig ( ctx context . Context , arg UpsertRuntimeConfigParams ) error
2023-06-21 16:20:58 +04:00
UpsertTailnetCoordinator ( ctx context . Context , id uuid . UUID ) ( TailnetCoordinator , error )
2023-11-15 10:13:27 +04:00
UpsertTailnetPeer ( ctx context . Context , arg UpsertTailnetPeerParams ) ( TailnetPeer , error )
UpsertTailnetTunnel ( ctx context . Context , arg UpsertTailnetTunnelParams ) ( TailnetTunnel , error )
2026-01-27 11:09:24 +02:00
UpsertTaskSnapshot ( ctx context . Context , arg UpsertTaskSnapshotParams ) error
2025-10-13 12:25:58 +03:00
UpsertTaskWorkspaceApp ( ctx context . Context , arg UpsertTaskWorkspaceAppParams ) ( TaskWorkspaceApp , error )
2025-01-31 13:55:46 +01:00
UpsertTelemetryItem ( ctx context . Context , arg UpsertTelemetryItemParams ) error
2024-03-22 18:33:34 +02:00
// This query aggregates the workspace_agent_stats and workspace_app_stats data
// into a single table for efficient storage and querying. Half-hour buckets are
// used to store the data, and the minutes are summed for each user and template
// combination. The result is stored in the template_usage_stats table.
UpsertTemplateUsageStats ( ctx context . Context ) error
2025-03-27 10:03:53 +00:00
UpsertWebpushVAPIDKeys ( ctx context . Context , arg UpsertWebpushVAPIDKeysParams ) error
2024-02-13 09:31:20 -05:00
UpsertWorkspaceAgentPortShare ( ctx context . Context , arg UpsertWorkspaceAgentPortShareParams ) ( WorkspaceAgentPortShare , error )
2025-06-23 20:50:44 +02:00
UpsertWorkspaceApp ( ctx context . Context , arg UpsertWorkspaceAppParams ) ( WorkspaceApp , error )
2025-03-18 13:50:52 +02:00
//
2025-03-20 16:10:45 +02:00
// The returned boolean, new_or_stale, can be used to deduce if a new session
// was started. This means that a new row was inserted (no previous session) or
// the updated_at is older than stale interval.
UpsertWorkspaceAppAuditSession ( ctx context . Context , arg UpsertWorkspaceAppAuditSessionParams ) ( bool , error )
2025-08-07 10:14:58 -06:00
ValidateGroupIDs ( ctx context . Context , groupIds [] uuid . UUID ) ( ValidateGroupIDsRow , error )
ValidateUserIDs ( ctx context . Context , userIds [] uuid . UUID ) ( ValidateUserIDsRow , error )
2022-01-05 09:20:56 -06:00
}
2022-10-10 15:37:06 -05:00
var _ sqlcQuerier = ( * sqlQuerier )( nil )