feat(store): let regions and agents belong to the platform or one organization
Regions are identified by id so organizations can reuse keys. Triggers keep agents in regions of the same owner and monitors in platform or own regions. Platform admins are a user flag. Refs #52 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
7bb4afa04a
commit
607798d742
10 files changed
+442
-99
No files matched your search
@@ -31,11 +31,12 @@ type Querier interface {
|
||||
CreateInvitation(ctx context.Context, arg CreateInvitationParams) (Invitation, error)
|
||||
CreateMonitor(ctx context.Context, arg CreateMonitorParams) (Monitor, error)
|
||||
CreateOrg(ctx context.Context, arg CreateOrgParams) (Org, error)
|
||||
CreateRegion(ctx context.Context, arg CreateRegionParams) (Region, error)
|
||||
CreateRole(ctx context.Context, arg CreateRoleParams) (Role, error)
|
||||
CreateSSOProvider(ctx context.Context, arg CreateSSOProviderParams) (SsoProvider, error)
|
||||
CreateUser(ctx context.Context, arg CreateUserParams) (User, error)
|
||||
DeleteAPIToken(ctx context.Context, id uuid.UUID) (int64, error)
|
||||
DeleteAgent(ctx context.Context, id uuid.UUID) (int64, error)
|
||||
DeleteAgent(ctx context.Context, arg DeleteAgentParams) (int64, error)
|
||||
DeleteAssignment(ctx context.Context, id uuid.UUID) (int64, error)
|
||||
DeleteChannel(ctx context.Context, id uuid.UUID) (int64, error)
|
||||
DeleteInvitation(ctx context.Context, id uuid.UUID) (int64, error)
|
||||
@@ -43,15 +44,19 @@ type Querier interface {
|
||||
DeleteMonitorRegions(ctx context.Context, monitorID uuid.UUID) error
|
||||
DeleteOrg(ctx context.Context, id uuid.UUID) (int64, error)
|
||||
DeleteRecoveryCodes(ctx context.Context, userID uuid.UUID) error
|
||||
DeleteRegion(ctx context.Context, id uuid.UUID) (int64, error)
|
||||
DeleteRole(ctx context.Context, id uuid.UUID) (int64, error)
|
||||
DeleteSSOProvider(ctx context.Context, id uuid.UUID) (int64, error)
|
||||
DeleteUser(ctx context.Context, id uuid.UUID) (int64, error)
|
||||
DisableTOTP(ctx context.Context, id uuid.UUID) error
|
||||
EnableTOTP(ctx context.Context, arg EnableTOTPParams) error
|
||||
EnqueueNotification(ctx context.Context, arg EnqueueNotificationParams) error
|
||||
// An empty name names a new region after its key and keeps an existing name.
|
||||
EnsurePlatformRegion(ctx context.Context, arg EnsurePlatformRegionParams) (Region, error)
|
||||
GetAPIToken(ctx context.Context, id uuid.UUID) (ApiToken, error)
|
||||
GetAPITokenByHash(ctx context.Context, tokenHash []byte) (ApiToken, error)
|
||||
GetAgentByHash(ctx context.Context, tokenHash []byte) (Agent, error)
|
||||
// System scope.
|
||||
GetAgentByHash(ctx context.Context, tokenHash []byte) (GetAgentByHashRow, error)
|
||||
GetAssignment(ctx context.Context, id uuid.UUID) (RoleAssignment, error)
|
||||
GetChannel(ctx context.Context, id uuid.UUID) (NotificationChannel, error)
|
||||
GetIdentity(ctx context.Context, arg GetIdentityParams) (UserIdentity, error)
|
||||
@@ -61,6 +66,7 @@ type Querier interface {
|
||||
GetMonitor(ctx context.Context, id uuid.UUID) (Monitor, error)
|
||||
GetOrg(ctx context.Context, id uuid.UUID) (Org, error)
|
||||
GetOrgBySlug(ctx context.Context, slug string) (Org, error)
|
||||
GetRegion(ctx context.Context, id uuid.UUID) (Region, error)
|
||||
GetRole(ctx context.Context, id uuid.UUID) (Role, error)
|
||||
GetSSOProvider(ctx context.Context, id uuid.UUID) (SsoProvider, error)
|
||||
GetUser(ctx context.Context, id uuid.UUID) (User, error)
|
||||
@@ -75,7 +81,8 @@ type Querier interface {
|
||||
LatestResults(ctx context.Context, orgID uuid.UUID) ([]LatestResultsRow, error)
|
||||
LatestResultsForMonitor(ctx context.Context, arg LatestResultsForMonitorParams) ([]LatestResultsForMonitorRow, error)
|
||||
ListAPITokens(ctx context.Context, arg ListAPITokensParams) ([]ListAPITokensRow, error)
|
||||
ListAgents(ctx context.Context) ([]Agent, error)
|
||||
// Agents owned by org, or platform agents when org is NULL.
|
||||
ListAgents(ctx context.Context, orgID *uuid.UUID) ([]ListAgentsRow, error)
|
||||
ListAssignments(ctx context.Context, orgID uuid.UUID) ([]ListAssignmentsRow, error)
|
||||
ListChannels(ctx context.Context) ([]NotificationChannel, error)
|
||||
ListEnabledChannelIDs(ctx context.Context, orgID uuid.UUID) ([]uuid.UUID, error)
|
||||
@@ -88,19 +95,24 @@ type Querier interface {
|
||||
ListOrgMembers(ctx context.Context, orgID uuid.UUID) ([]ListOrgMembersRow, error)
|
||||
ListOrgs(ctx context.Context) ([]Org, error)
|
||||
ListPendingInvitations(ctx context.Context) ([]ListPendingInvitationsRow, error)
|
||||
ListRegions(ctx context.Context) ([]Region, error)
|
||||
ListPlatformRegions(ctx context.Context) ([]Region, error)
|
||||
ListRoles(ctx context.Context) ([]Role, error)
|
||||
ListSSOProviders(ctx context.Context) ([]SsoProvider, error)
|
||||
ListUserIdentitiesInOrg(ctx context.Context, userID uuid.UUID) ([]ListUserIdentitiesInOrgRow, error)
|
||||
ListUserOrgs(ctx context.Context, userID uuid.UUID) ([]ListUserOrgsRow, error)
|
||||
// Row-level security limits this to platform regions and the scope's org;
|
||||
// the org's own regions come first.
|
||||
ListVisibleRegions(ctx context.Context) ([]Region, error)
|
||||
MakeAdmin(ctx context.Context, id uuid.UUID) error
|
||||
MarkInvitationAccepted(ctx context.Context, id uuid.UUID) (int64, error)
|
||||
MarkNotificationFailed(ctx context.Context, arg MarkNotificationFailedParams) error
|
||||
MarkNotificationSent(ctx context.Context, id uuid.UUID) error
|
||||
// Every role a member holds, with the scope it applies to.
|
||||
MemberGrants(ctx context.Context, arg MemberGrantsParams) ([]MemberGrantsRow, error)
|
||||
MonitorRegions(ctx context.Context, monitorID uuid.UUID) ([]string, error)
|
||||
MonitorRegions(ctx context.Context, monitorID uuid.UUID) ([]uuid.UUID, error)
|
||||
// System scope: monitors to hand to a checker of region, skipping ones that
|
||||
// were disabled, deleted or moved out of the region since dispatch.
|
||||
// were disabled, deleted or moved out of the region since dispatch. An
|
||||
// org-owned checker only ever sees its org's monitors.
|
||||
MonitorsForJobs(ctx context.Context, arg MonitorsForJobsParams) ([]Monitor, error)
|
||||
// System scope: monitors a checker of region may report, with every region
|
||||
// they are assigned to, for evaluation.
|
||||
@@ -113,6 +125,7 @@ type Querier interface {
|
||||
RemoveMembership(ctx context.Context, arg RemoveMembershipParams) (int64, error)
|
||||
ResolveIncident(ctx context.Context, arg ResolveIncidentParams) (Incident, error)
|
||||
SetPasswordHash(ctx context.Context, arg SetPasswordHashParams) error
|
||||
SetUserAdmin(ctx context.Context, arg SetUserAdminParams) (int64, error)
|
||||
SetUserLocale(ctx context.Context, arg SetUserLocaleParams) error
|
||||
TouchAPIToken(ctx context.Context, id uuid.UUID) error
|
||||
TouchAgent(ctx context.Context, arg TouchAgentParams) error
|
||||
@@ -122,8 +135,6 @@ type Querier interface {
|
||||
UpdateOrgPolicy(ctx context.Context, arg UpdateOrgPolicyParams) (Org, error)
|
||||
UpdateRole(ctx context.Context, arg UpdateRoleParams) (Role, error)
|
||||
UpdateSSOProvider(ctx context.Context, arg UpdateSSOProviderParams) (SsoProvider, error)
|
||||
// An empty name names a new region after its key and keeps an existing name.
|
||||
UpsertRegion(ctx context.Context, arg UpsertRegionParams) (Region, error)
|
||||
// Uptime per monitor from the hourly aggregate, including the not yet
|
||||
// materialized most recent hours (real-time aggregation).
|
||||
UptimeSince(ctx context.Context, arg UptimeSinceParams) ([]UptimeSinceRow, error)
|
||||
|
||||
Reference in new issue
Block a user