platform

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActorFrom

func ActorFrom(ctx context.Context) string

ActorFrom returns the acting user id previously set with WithActor, or "".

func WithActor

func WithActor(ctx context.Context, userID string) context.Context

WithActor attaches the acting platform user id to ctx for domain event emission.

Types

type AuthFeatures

type AuthFeatures struct {
	SignupEnabled        bool `json:"signup_enabled"`
	PasswordResetEnabled bool `json:"password_reset_enabled"`
}

AuthFeatures describes public auth capabilities for the login UI.

type AuthService

type AuthService struct {
	Users         identity.UserRepository
	Identities    identity.ExternalIdentityRepository
	Resets        identity.PasswordResetRepository
	Tokens        identity.TokenIssuer
	Passwords     identity.PasswordHasher
	States        identity.SSOStateStore
	Providers     map[string]identity.FederationProvider
	SSOEnabled    bool
	SignupEnabled bool
	// PublicBaseURL is the control-plane base URL used for OAuth callbacks.
	PublicBaseURL string
	// AppBaseURL is the web UI base URL used after SSO callback redirect.
	AppBaseURL string
	NewUserID  func() string
	NewLinkID  func() string
	NewResetID func() string
	Now        func() time.Time
}

AuthService orchestrates password and SSO platform AuthN.

func (*AuthService) AppSSOCallbackURL

func (a *AuthService) AppSSOCallbackURL(token, returnTo, errMsg string) string

AppSSOCallbackURL builds the web UI URL that receives the session token.

func (*AuthService) BeginSSO

func (a *AuthService) BeginSSO(ctx context.Context, providerID, returnTo string) (authURL string, err error)

BeginSSO starts an OAuth/OIDC/SAML login and returns the IdP redirect URL.

func (*AuthService) CompleteSSO

func (a *AuthService) CompleteSSO(ctx context.Context, providerID, code, state string) (*CompleteSSOResult, error)

CompleteSSO finishes OAuth/OIDC/SAML login, JIT-provisions the user, and issues a JWT.

func (*AuthService) ConfirmPasswordReset

func (a *AuthService) ConfirmPasswordReset(ctx context.Context, rawToken, password string) (token string, user *identity.User, err error)

ConfirmPasswordReset consumes a reset token, sets the new password, and issues a JWT.

func (*AuthService) Features

func (a *AuthService) Features() AuthFeatures

Features returns public auth capability flags for the UI.

func (*AuthService) ListSSOProviders

func (a *AuthService) ListSSOProviders() []SSOProviderInfo

ListSSOProviders returns enabled SSO providers for the login UI.

func (*AuthService) LoginWithPassword

func (a *AuthService) LoginWithPassword(ctx context.Context, email, password string) (string, error)

LoginWithPassword authenticates a local user and returns a session JWT.

func (*AuthService) Register

func (a *AuthService) Register(ctx context.Context, email, name, password string) (token string, user *identity.User, err error)

Register creates a local password user and returns a session JWT.

func (*AuthService) RequestPasswordReset

func (a *AuthService) RequestPasswordReset(ctx context.Context, email string) (rawToken string, err error)

RequestPasswordReset creates a reset token for the user when the email exists. Returns an empty rawToken (and nil error) when the email is unknown — anti-enumeration.

func (*AuthService) SSOMetadataXML

func (a *AuthService) SSOMetadataXML(providerID string) ([]byte, error)

SSOMetadataXML returns SP metadata for a SAML provider, or ErrUnknownProvider / not supported.

type Bus

type Bus struct {
	// contains filtered or unexported fields
}

Bus is an in-process pub/sub domain event bus. It implements EventRecorder and fans each event to matching subscribers.

func NewBus

func NewBus() *Bus

NewBus creates an empty event bus.

func (*Bus) OnPanic

func (b *Bus) OnPanic(fn func(recovered any, e Event))

OnPanic sets an optional callback when a subscriber panics.

func (*Bus) Record

func (b *Bus) Record(ctx context.Context, e Event)

Record publishes an event to matching subscribers (specific name + EventAll). Subscriber panics are recovered so one bad handler cannot break the bus.

func (*Bus) Subscribe

func (b *Bus) Subscribe(name EventName, h Handler)

Subscribe registers a handler for a specific event name. Use EventAll to receive every event.

func (*Bus) SubscribeAll

func (b *Bus) SubscribeAll(h Handler)

SubscribeAll is shorthand for Subscribe(EventAll, h).

type CompleteSSOResult

type CompleteSSOResult struct {
	Token    string
	ReturnTo string
}

CompleteSSOResult is returned after a successful federated login.

type ConfigAPI

type ConfigAPI interface {
	ListOrganizationsForUser(ctx context.Context, userID string) ([]tenancy.Organization, error)
	CreateOrganization(ctx context.Context, name, creatorUserID string) (*tenancy.Organization, error)
	ListOrgMembers(ctx context.Context, orgID string) ([]tenancy.OrgMember, error)
	UpdateOrgMemberRole(ctx context.Context, orgID, actorUserID, targetUserID, role string) (*tenancy.OrgMember, error)
	InviteOrgMember(ctx context.Context, orgID, email, invitedByUserID string) (*tenancy.InviteOutcome, string, error)
	ListOrgInvites(ctx context.Context, orgID string) ([]tenancy.OrgInvite, error)
	RevokeOrgInvite(ctx context.Context, orgID, inviteID string) error
	ResendOrgInvite(ctx context.Context, orgID, inviteID string) (*tenancy.OrgInvite, string, error)
	PreviewOrgInvite(ctx context.Context, rawToken string) (*tenancy.InvitePreview, error)
	AcceptOrgInvite(ctx context.Context, rawToken, name, passwordHash string) (*tenancy.OrgMember, *identity.User, error)

	ListTeams(ctx context.Context, orgID, userID string) ([]tenancy.Team, error)
	CreateTeam(ctx context.Context, orgID, name, creatorUserID string) (*tenancy.Team, error)
	GetTeam(ctx context.Context, teamID string) (*tenancy.Team, error)
	ListTeamMembers(ctx context.Context, teamID string) ([]tenancy.TeamMember, error)
	AddTeamMember(ctx context.Context, teamID, userID string) (*tenancy.TeamMember, error)
	UpdateTeamMemberRole(ctx context.Context, teamID, actorUserID, targetUserID, role string) (*tenancy.TeamMember, error)
	RemoveTeamMember(ctx context.Context, teamID, userID string) error
	ListProjects(ctx context.Context, orgID, userID string) ([]tenancy.Project, error)
	CreateProject(ctx context.Context, orgID, teamID, name string) (*tenancy.Project, error)

	ListEnvironments(ctx context.Context, projectID string) ([]tenancy.Environment, error)
	GetEnvironment(ctx context.Context, environmentID string) (*tenancy.Environment, error)
	CreateEnvironment(ctx context.Context, orgID, projectID, name, slug string) (*tenancy.Environment, error)
	DeleteEnvironment(ctx context.Context, environmentID string) error
	GetEnvironmentOrgID(ctx context.Context, environmentID string) (string, error)

	ListAPIKeys(ctx context.Context, projectID string) ([]access.APIKey, error)
	ListOrgAPIKeys(ctx context.Context, orgID string) ([]access.APIKey, error)
	CreateAPIKey(ctx context.Context, orgID, kind, ownerUserID, projectID, environmentID, name, rawKey string) (*access.APIKey, error)
	GetAPIKeyOrgID(ctx context.Context, keyID string) (string, error)
	DeleteAPIKey(ctx context.Context, keyID string) error
	ListSigningKeys(ctx context.Context, orgID string) ([]access.SigningKey, error)
	CreateSigningKey(ctx context.Context, orgID, keyID, projectID, environmentID, name, algorithm, publicKeyPEM string) (*access.SigningKey, error)
	UpdateSigningKey(ctx context.Context, id, name, status string) (*access.SigningKey, error)
	RotateSigningKey(ctx context.Context, id, publicKeyPEM string) (*access.SigningKey, error)
	GetSigningKeyOrgID(ctx context.Context, id string) (string, error)
	DeleteSigningKey(ctx context.Context, id string) error

	ListProviders(ctx context.Context, orgID string) ([]gatewayconfig.Provider, error)
	ListProviderHealth(ctx context.Context, orgID string, from, to time.Time) ([]usage.ProviderHealth, error)
	CreateProvider(ctx context.Context, orgID, name, typ, baseURL, apiKeyEnv string, caps snapshot.ProviderCapabilities, config json.RawMessage) (*gatewayconfig.Provider, error)
	UpdateProvider(ctx context.Context, providerID, name, baseURL, apiKeyEnv string, config *json.RawMessage) (*gatewayconfig.Provider, error)
	GetProviderOrgID(ctx context.Context, providerID string) (string, error)
	DeleteProvider(ctx context.Context, providerID string) error

	ListRoutes(ctx context.Context, orgID string) ([]gatewayconfig.Route, error)
	CreateRoute(ctx context.Context, orgID, model, providerID, targetModel string, fallbacks []gatewayconfig.RouteFallback, retry *gatewayconfig.RetryConfig, strategy string, weight int) (*gatewayconfig.Route, error)
	UpdateRoute(ctx context.Context, routeID, model, providerID, targetModel string, fallbacks []gatewayconfig.RouteFallback, retry *gatewayconfig.RetryConfig, strategy string, weight int) (*gatewayconfig.Route, error)
	GetRouteOrgID(ctx context.Context, routeID string) (string, error)
	DeleteRoute(ctx context.Context, routeID string) error
	GetOrgDefaultRetry(ctx context.Context, orgID string) (*gatewayconfig.RetryConfig, error)
	SetOrgDefaultRetry(ctx context.Context, orgID string, retry *gatewayconfig.RetryConfig) error
	GetOrgObjectStore(ctx context.Context, orgID string) (*gatewayconfig.ObjectStoreConfig, error)
	SetOrgObjectStore(ctx context.Context, orgID string, cfg *gatewayconfig.ObjectStoreConfig) error

	ListUsage(ctx context.Context, orgID string, f usage.Filter) ([]usage.Record, error)
	SummarizeUsage(ctx context.Context, orgID string, f usage.Filter) ([]usage.SummaryBucket, error)
	ListAudit(ctx context.Context, orgID string, f audit.Filter) ([]audit.Record, error)

	ListQuotas(ctx context.Context, orgID string) ([]gatewayconfig.Quota, error)
	CreateQuota(ctx context.Context, orgID, scopeType, scopeID, metric string, limitValue int64, window string) (*gatewayconfig.Quota, error)
	UpdateQuota(ctx context.Context, quotaID string, limitValue int64) (*gatewayconfig.Quota, error)
	GetQuotaOrgID(ctx context.Context, quotaID string) (string, error)
	DeleteQuota(ctx context.Context, quotaID string) error

	ListPolicies(ctx context.Context, orgID string) ([]gatewayconfig.RequestPolicy, error)
	CreatePolicy(ctx context.Context, orgID, name, expression string, actions []gatewayconfig.PolicyAction, enabled bool, priority int) (*gatewayconfig.RequestPolicy, error)
	UpdatePolicy(ctx context.Context, policyID string, name, expression *string, actions []gatewayconfig.PolicyAction, enabled *bool, priority *int) (*gatewayconfig.RequestPolicy, error)
	ReorderPolicies(ctx context.Context, orgID string, items []gatewayconfig.PolicyPriorityUpdate) error
	GetPolicyOrgID(ctx context.Context, policyID string) (string, error)
	DeletePolicy(ctx context.Context, policyID string) error

	ListWasmHooks(ctx context.Context, orgID string) ([]gatewayconfig.WasmHook, error)
	CreateWasmHook(ctx context.Context, orgID, name, phase, moduleURI, digest string, enabled bool, priority int, config []byte) (*gatewayconfig.WasmHook, error)
	UpdateWasmHook(ctx context.Context, id string, name, phase, moduleURI, digest *string, enabled *bool, priority *int, config []byte) (*gatewayconfig.WasmHook, error)
	GetWasmHookOrgID(ctx context.Context, id string) (string, error)
	DeleteWasmHook(ctx context.Context, id string) error

	ListMCPBackends(ctx context.Context, orgID string) ([]gatewayconfig.MCPBackend, error)
	CreateMCPBackend(ctx context.Context, orgID, alias, name, baseURL, apiKeyEnv string, methodAllowlist []byte, enabled bool) (*gatewayconfig.MCPBackend, error)
	UpdateMCPBackend(ctx context.Context, id string, alias, name, baseURL, apiKeyEnv *string, methodAllowlist []byte, enabled *bool) (*gatewayconfig.MCPBackend, error)
	GetMCPBackendOrgID(ctx context.Context, id string) (string, error)
	DeleteMCPBackend(ctx context.Context, id string) error

	ListA2AAgents(ctx context.Context, orgID string) ([]gatewayconfig.A2AAgent, error)
	CreateA2AAgent(ctx context.Context, orgID, alias, name, upstreamURL, cardURL, apiKeyEnv, authScheme string, cardCache []byte, enabled bool) (*gatewayconfig.A2AAgent, error)
	UpdateA2AAgent(ctx context.Context, id string, alias, name, upstreamURL, cardURL, apiKeyEnv, authScheme *string, cardCache []byte, enabled *bool) (*gatewayconfig.A2AAgent, error)
	GetA2AAgentOrgID(ctx context.Context, id string) (string, error)
	DeleteA2AAgent(ctx context.Context, id string) error

	ListCredentials(ctx context.Context, orgID string) ([]credentials.Credential, error)
	CreateCredential(ctx context.Context, orgID, name, providerType, storageKind, secretRef, secretValue string) (*credentials.Credential, error)
	UpdateCredential(ctx context.Context, credentialID, name, status string) (*credentials.Credential, error)
	RotateCredential(ctx context.Context, credentialID, secretRef, secretValue string) (*credentials.Credential, error)
	GetCredentialOrgID(ctx context.Context, credentialID string) (string, error)
	DeleteCredential(ctx context.Context, credentialID string) error
	ListCredentialAssignments(ctx context.Context, orgID string) ([]credentials.Assignment, error)
	AssignCredential(ctx context.Context, credentialID, scopeType, scopeID, createdBy string) (*credentials.Assignment, error)
	GetCredentialAssignmentOrgID(ctx context.Context, assignmentID string) (string, error)
	DeleteCredentialAssignment(ctx context.Context, assignmentID string) error

	ListRegions(ctx context.Context) ([]regions.Region, error)
	GetRegion(ctx context.Context, regionID string) (*regions.Region, error)
	CreateRegion(ctx context.Context, slug, name string) (*regions.Region, error)
	UpdateRegion(ctx context.Context, regionID, name, status string) (*regions.Region, error)
	ListDeployments(ctx context.Context, regionID string) ([]regions.GatewayDeployment, error)
	GetDeployment(ctx context.Context, deploymentID string) (*regions.GatewayDeployment, error)
	RegisterDeployment(ctx context.Context, regionID, name, publicBaseURL string) (*regions.DeploymentWithToken, error)
	RotateDeploymentJoinToken(ctx context.Context, deploymentID string) (*regions.DeploymentWithToken, error)
	RecordDeploymentHeartbeat(ctx context.Context, deploymentID, joinToken string, snapVersion int64, build string) (*regions.GatewayDeployment, error)
	AuthenticateDeploymentJoinToken(ctx context.Context, rawToken string) (*regions.GatewayDeployment, error)

	ListRegionMemberships(ctx context.Context, regionID string) ([]regions.OrgRegionMembership, error)
	BindOrgToRegion(ctx context.Context, regionID, orgID, status string) (*regions.OrgRegionMembership, error)
	BindAllOrgsToRegion(ctx context.Context, regionID string) (int, error)
	UnbindOrgFromRegion(ctx context.Context, regionID, orgID string) error
	GetRegionOverlay(ctx context.Context, regionID, orgID string) (*regions.RegionConfigOverlay, error)
	PutRegionOverlay(ctx context.Context, regionID, orgID string, payload regions.OverlayPayload) (*regions.RegionConfigOverlay, error)
	DeleteRegionOverlay(ctx context.Context, regionID, orgID string) error

	ListFederationPeers(ctx context.Context) ([]federation.ControlPlanePeer, error)
	GetFederationPeer(ctx context.Context, peerID string) (*federation.ControlPlanePeer, error)
	RegisterFederationPeer(ctx context.Context, name, regionID, baseURL string) (*federation.PeerWithToken, error)
	UpdateFederationPeer(ctx context.Context, peerID, name, baseURL, status string) (*federation.ControlPlanePeer, error)
	RotateFederationPeerJoinToken(ctx context.Context, peerID string) (*federation.PeerWithToken, error)
	AuthenticateFederationPeerToken(ctx context.Context, rawToken string) (*federation.ControlPlanePeer, error)
	JoinFederationPeer(ctx context.Context, rawToken string) (*federation.ControlPlanePeer, error)
	ExportFederationRegion(ctx context.Context, slug string, since int64, objectPrefix string) (*federation.RegionExport, error)
	RecordFederationPeerSync(ctx context.Context, peerID string, cursor int64, syncErr string) error
	ListFederationUsageReports(ctx context.Context, orgID string, since, until *time.Time, limit int) ([]usage.Record, error)
	OpenFederationPeerJoinToken(ctx context.Context, peerID string) (string, error)
}

ConfigAPI is the persistence surface for platform reads and mutations.

type Event

type Event struct {
	ID             string            `json:"id"`
	Name           EventName         `json:"name"`
	ResourceID     string            `json:"resource_id,omitempty"`
	OrganizationID string            `json:"organization_id,omitempty"`
	ActorUserID    string            `json:"actor_user_id,omitempty"`
	At             time.Time         `json:"at"`
	Meta           map[string]string `json:"meta,omitempty"`
}

Event is a domain event emitted after successful platform work.

type EventEnqueuer

type EventEnqueuer interface {
	Enqueue(ctx context.Context, payload []byte) error
}

EventEnqueuer persists platform events for durable cross-process delivery.

type EventName

type EventName string

EventName identifies a platform domain event.

const (
	EventOrgCreated                 EventName = "org.created"
	EventMemberAdded                EventName = "member.added"
	EventMemberRoleUpdated          EventName = "member.role_updated"
	EventInviteCreated              EventName = "invite.created"
	EventInviteRevoked              EventName = "invite.revoked"
	EventInviteResent               EventName = "invite.resent"
	EventInviteAccepted             EventName = "invite.accepted"
	EventTeamCreated                EventName = "team.created"
	EventTeamMemberAdded            EventName = "team.member_added"
	EventTeamMemberRoleUpdated      EventName = "team.member_role_updated"
	EventTeamMemberRemoved          EventName = "team.member_removed"
	EventProjectCreated             EventName = "project.created"
	EventEnvironmentCreated         EventName = "environment.created"
	EventEnvironmentDeleted         EventName = "environment.deleted"
	EventAPIKeyCreated              EventName = "api_key.created"
	EventAPIKeyDeleted              EventName = "api_key.deleted"
	EventSigningKeyCreated          EventName = "signing_key.created"
	EventSigningKeyUpdated          EventName = "signing_key.updated"
	EventSigningKeyRotated          EventName = "signing_key.rotated"
	EventSigningKeyDeleted          EventName = "signing_key.deleted"
	EventProviderCreated            EventName = "provider.created"
	EventProviderUpdated            EventName = "provider.updated"
	EventProviderDeleted            EventName = "provider.deleted"
	EventRouteCreated               EventName = "route.created"
	EventRouteUpdated               EventName = "route.updated"
	EventRouteDeleted               EventName = "route.deleted"
	EventOrgDefaultRetryUpdated     EventName = "org.default_retry.updated"
	EventOrgObjectStoreUpdated      EventName = "org.object_store.updated"
	EventQuotaCreated               EventName = "quota.created"
	EventQuotaUpdated               EventName = "quota.updated"
	EventQuotaDeleted               EventName = "quota.deleted"
	EventPolicyCreated              EventName = "policy.created"
	EventPolicyUpdated              EventName = "policy.updated"
	EventPolicyDeleted              EventName = "policy.deleted"
	EventWasmHookCreated            EventName = "wasm_hook.created"
	EventWasmHookUpdated            EventName = "wasm_hook.updated"
	EventWasmHookDeleted            EventName = "wasm_hook.deleted"
	EventMCPBackendCreated          EventName = "mcp_backend.created"
	EventMCPBackendUpdated          EventName = "mcp_backend.updated"
	EventMCPBackendDeleted          EventName = "mcp_backend.deleted"
	EventA2AAgentCreated            EventName = "a2a_agent.created"
	EventA2AAgentUpdated            EventName = "a2a_agent.updated"
	EventA2AAgentDeleted            EventName = "a2a_agent.deleted"
	EventCredentialCreated          EventName = "credential.created"
	EventCredentialUpdated          EventName = "credential.updated"
	EventCredentialRotated          EventName = "credential.rotated"
	EventCredentialDeleted          EventName = "credential.deleted"
	EventCredentialAssigned         EventName = "credential.assigned"
	EventCredentialUnassigned       EventName = "credential.unassigned"
	EventSnapshotPublish            EventName = "snapshot.published"
	EventRegionCreated              EventName = "region.created"
	EventRegionUpdated              EventName = "region.updated"
	EventDeploymentRegistered       EventName = "deployment.registered"
	EventDeploymentJoinTokenRotated EventName = "deployment.join_token_rotated"
	EventOrgRegionBound             EventName = "org.region.bound"
	EventOrgRegionUnbound           EventName = "org.region.unbound"
	EventRegionOverlayUpserted      EventName = "region.overlay.upserted"
	EventRegionOverlayDeleted       EventName = "region.overlay.deleted"
)
const EventAll EventName = "*"

EventAll matches every event when used with Bus.Subscribe.

type EventRecorder

type EventRecorder interface {
	Record(ctx context.Context, e Event)
}

EventRecorder receives domain events after successful platform commands.

type Handler

type Handler func(ctx context.Context, e Event)

Handler receives a domain event. Handlers must not panic; the bus recovers panics.

func AuditHandler

func AuditHandler(store audit.Store, log *slog.Logger) Handler

AuditHandler maps domain events onto the audit.Store port. It belongs in the application layer so adapters stay free of the platform Event type.

func OutboxHandler

func OutboxHandler(enq EventEnqueuer, log *slog.Logger) Handler

OutboxHandler returns a bus Handler that enqueues events to a durable outbox. Enqueue failures are logged and do not fail the request path.

func SlogHandler

func SlogHandler(log *slog.Logger) Handler

SlogHandler returns a Handler that logs events at debug level.

type MemoryRecorder

type MemoryRecorder struct {
	// contains filtered or unexported fields
}

MemoryRecorder stores recent events (newest last). Useful in tests and diagnostics.

func NewMemoryRecorder

func NewMemoryRecorder(limit int) *MemoryRecorder

NewMemoryRecorder keeps up to limit events (default 256).

func (*MemoryRecorder) Record

func (m *MemoryRecorder) Record(_ context.Context, e Event)

func (*MemoryRecorder) Snapshot

func (m *MemoryRecorder) Snapshot() []Event

Snapshot returns a copy of recorded events (oldest first).

type MultiRecorder

type MultiRecorder []EventRecorder

MultiRecorder fans events out to multiple recorders.

func (MultiRecorder) Record

func (m MultiRecorder) Record(ctx context.Context, e Event)

type NopRecorder

type NopRecorder struct{}

NopRecorder discards events.

func (NopRecorder) Record

func (NopRecorder) Record(context.Context, Event)

type SSOProviderInfo

type SSOProviderInfo struct {
	ID          string `json:"id"`
	DisplayName string `json:"display_name"`
	Type        string `json:"type"`
}

SSOProviderInfo is a public descriptor for the login UI.

type Service

type Service struct {
	API    ConfigAPI
	Snap   SnapshotPublisher
	Events EventRecorder
}

Service orchestrates platform queries and commands (mutate + publish + events).

func New

func New(api ConfigAPI, snap SnapshotPublisher) *Service

func (*Service) AcceptOrgInvite

func (s *Service) AcceptOrgInvite(ctx context.Context, rawToken, name, passwordHash string) (*tenancy.OrgMember, *identity.User, error)

func (*Service) AddTeamMember

func (s *Service) AddTeamMember(ctx context.Context, teamID, userID string) (*tenancy.TeamMember, error)

func (*Service) AssignCredential

func (s *Service) AssignCredential(ctx context.Context, credentialID, scopeType, scopeID, createdBy string) (*credentials.Assignment, error)

func (*Service) AuthenticateDeploymentJoinToken added in v0.3.0

func (s *Service) AuthenticateDeploymentJoinToken(ctx context.Context, rawToken string) (*regions.GatewayDeployment, error)

func (*Service) AuthenticateFederationPeerToken added in v0.3.0

func (s *Service) AuthenticateFederationPeerToken(ctx context.Context, rawToken string) (*federation.ControlPlanePeer, error)

func (*Service) BindAllOrgsToRegion added in v0.3.0

func (s *Service) BindAllOrgsToRegion(ctx context.Context, regionID string) (int, error)

func (*Service) BindOrgToRegion added in v0.3.0

func (s *Service) BindOrgToRegion(ctx context.Context, regionID, orgID, status string) (*regions.OrgRegionMembership, error)

func (*Service) CreateA2AAgent

func (s *Service) CreateA2AAgent(ctx context.Context, orgID, alias, name, upstreamURL, cardURL, apiKeyEnv, authScheme string, cardCache []byte, enabled bool) (*gatewayconfig.A2AAgent, error)

func (*Service) CreateAPIKey

func (s *Service) CreateAPIKey(ctx context.Context, orgID, kind, ownerUserID, projectID, environmentID, name, rawKey string) (*access.APIKey, error)

func (*Service) CreateCredential

func (s *Service) CreateCredential(ctx context.Context, orgID, name, providerType, storageKind, secretRef, secretValue string) (*credentials.Credential, error)

func (*Service) CreateEnvironment

func (s *Service) CreateEnvironment(ctx context.Context, orgID, projectID, name, slug string) (*tenancy.Environment, error)

func (*Service) CreateMCPBackend

func (s *Service) CreateMCPBackend(ctx context.Context, orgID, alias, name, baseURL, apiKeyEnv string, methodAllowlist []byte, enabled bool) (*gatewayconfig.MCPBackend, error)

func (*Service) CreateOrganization

func (s *Service) CreateOrganization(ctx context.Context, name, creatorUserID string) (*tenancy.Organization, error)

func (*Service) CreatePolicy

func (s *Service) CreatePolicy(ctx context.Context, orgID, name, expression string, actions []gatewayconfig.PolicyAction, enabled bool, priority int) (*gatewayconfig.RequestPolicy, error)

func (*Service) CreateProject

func (s *Service) CreateProject(ctx context.Context, orgID, teamID, name string) (*tenancy.Project, error)

func (*Service) CreateProvider

func (s *Service) CreateProvider(ctx context.Context, orgID, name, typ, baseURL, apiKeyEnv string, caps snapshot.ProviderCapabilities, config json.RawMessage) (*gatewayconfig.Provider, error)

func (*Service) CreateQuota

func (s *Service) CreateQuota(ctx context.Context, orgID, scopeType, scopeID, metric string, limitValue int64, window string) (*gatewayconfig.Quota, error)

func (*Service) CreateRegion added in v0.3.0

func (s *Service) CreateRegion(ctx context.Context, slug, name string) (*regions.Region, error)

func (*Service) CreateRoute

func (s *Service) CreateRoute(ctx context.Context, orgID, model, providerID, targetModel string, fallbacks []gatewayconfig.RouteFallback, retry *gatewayconfig.RetryConfig, strategy string, weight int) (*gatewayconfig.Route, error)

func (*Service) CreateSigningKey added in v0.3.0

func (s *Service) CreateSigningKey(ctx context.Context, orgID, keyID, projectID, environmentID, name, algorithm, publicKeyPEM string) (*access.SigningKey, error)

func (*Service) CreateTeam

func (s *Service) CreateTeam(ctx context.Context, orgID, name, creatorUserID string) (*tenancy.Team, error)

func (*Service) CreateWasmHook

func (s *Service) CreateWasmHook(ctx context.Context, orgID, name, phase, moduleURI, digest string, enabled bool, priority int, config []byte) (*gatewayconfig.WasmHook, error)

func (*Service) DeleteA2AAgent

func (s *Service) DeleteA2AAgent(ctx context.Context, id string) error

func (*Service) DeleteAPIKey

func (s *Service) DeleteAPIKey(ctx context.Context, keyID string) error

func (*Service) DeleteCredential

func (s *Service) DeleteCredential(ctx context.Context, credentialID string) error

func (*Service) DeleteCredentialAssignment

func (s *Service) DeleteCredentialAssignment(ctx context.Context, assignmentID string) error

func (*Service) DeleteEnvironment

func (s *Service) DeleteEnvironment(ctx context.Context, environmentID string) error

func (*Service) DeleteMCPBackend

func (s *Service) DeleteMCPBackend(ctx context.Context, id string) error

func (*Service) DeletePolicy

func (s *Service) DeletePolicy(ctx context.Context, policyID string) error

func (*Service) DeleteProvider

func (s *Service) DeleteProvider(ctx context.Context, providerID string) error

func (*Service) DeleteQuota

func (s *Service) DeleteQuota(ctx context.Context, quotaID string) error

func (*Service) DeleteRegionOverlay added in v0.3.0

func (s *Service) DeleteRegionOverlay(ctx context.Context, regionID, orgID string) error

func (*Service) DeleteRoute

func (s *Service) DeleteRoute(ctx context.Context, routeID string) error

func (*Service) DeleteSigningKey added in v0.3.0

func (s *Service) DeleteSigningKey(ctx context.Context, id string) error

func (*Service) DeleteWasmHook

func (s *Service) DeleteWasmHook(ctx context.Context, id string) error

func (*Service) ExportFederationRegion added in v0.3.0

func (s *Service) ExportFederationRegion(ctx context.Context, slug string, since int64, objectPrefix string) (*federation.RegionExport, error)

func (*Service) GetDeployment added in v0.3.0

func (s *Service) GetDeployment(ctx context.Context, deploymentID string) (*regions.GatewayDeployment, error)

func (*Service) GetEnvironment

func (s *Service) GetEnvironment(ctx context.Context, environmentID string) (*tenancy.Environment, error)

func (*Service) GetFederationPeer added in v0.3.0

func (s *Service) GetFederationPeer(ctx context.Context, peerID string) (*federation.ControlPlanePeer, error)

func (*Service) GetOrgDefaultRetry

func (s *Service) GetOrgDefaultRetry(ctx context.Context, orgID string) (*gatewayconfig.RetryConfig, error)

func (*Service) GetOrgObjectStore

func (s *Service) GetOrgObjectStore(ctx context.Context, orgID string) (*gatewayconfig.ObjectStoreConfig, error)

func (*Service) GetRegion added in v0.3.0

func (s *Service) GetRegion(ctx context.Context, regionID string) (*regions.Region, error)

func (*Service) GetRegionOverlay added in v0.3.0

func (s *Service) GetRegionOverlay(ctx context.Context, regionID, orgID string) (*regions.RegionConfigOverlay, error)

func (*Service) GetTeam

func (s *Service) GetTeam(ctx context.Context, teamID string) (*tenancy.Team, error)

func (*Service) InviteOrgMember

func (s *Service) InviteOrgMember(ctx context.Context, orgID, email, invitedByUserID string) (*tenancy.InviteOutcome, string, error)

func (*Service) JoinFederationPeer added in v0.3.0

func (s *Service) JoinFederationPeer(ctx context.Context, rawToken string) (*federation.ControlPlanePeer, error)

func (*Service) ListA2AAgents

func (s *Service) ListA2AAgents(ctx context.Context, orgID string) ([]gatewayconfig.A2AAgent, error)

func (*Service) ListAPIKeys

func (s *Service) ListAPIKeys(ctx context.Context, projectID string) ([]access.APIKey, error)

func (*Service) ListAudit

func (s *Service) ListAudit(ctx context.Context, orgID string, f audit.Filter) ([]audit.Record, error)

func (*Service) ListCredentialAssignments

func (s *Service) ListCredentialAssignments(ctx context.Context, orgID string) ([]credentials.Assignment, error)

func (*Service) ListCredentials

func (s *Service) ListCredentials(ctx context.Context, orgID string) ([]credentials.Credential, error)

func (*Service) ListDeployments added in v0.3.0

func (s *Service) ListDeployments(ctx context.Context, regionID string) ([]regions.GatewayDeployment, error)

func (*Service) ListEnvironments

func (s *Service) ListEnvironments(ctx context.Context, projectID string) ([]tenancy.Environment, error)

func (*Service) ListFederationPeers added in v0.3.0

func (s *Service) ListFederationPeers(ctx context.Context) ([]federation.ControlPlanePeer, error)

func (*Service) ListFederationUsageReports added in v0.3.0

func (s *Service) ListFederationUsageReports(ctx context.Context, orgID string, since, until *time.Time, limit int) ([]usage.Record, error)

func (*Service) ListMCPBackends

func (s *Service) ListMCPBackends(ctx context.Context, orgID string) ([]gatewayconfig.MCPBackend, error)

func (*Service) ListOrgInvites

func (s *Service) ListOrgInvites(ctx context.Context, orgID string) ([]tenancy.OrgInvite, error)

func (*Service) ListOrgMembers

func (s *Service) ListOrgMembers(ctx context.Context, orgID string) ([]tenancy.OrgMember, error)

func (*Service) ListOrganizationsForUser

func (s *Service) ListOrganizationsForUser(ctx context.Context, userID string) ([]tenancy.Organization, error)

func (*Service) ListPolicies

func (s *Service) ListPolicies(ctx context.Context, orgID string) ([]gatewayconfig.RequestPolicy, error)

func (*Service) ListProjects

func (s *Service) ListProjects(ctx context.Context, orgID, userID string) ([]tenancy.Project, error)

func (*Service) ListProviderHealth

func (s *Service) ListProviderHealth(ctx context.Context, orgID string, from, to time.Time) ([]usage.ProviderHealth, error)

func (*Service) ListProviders

func (s *Service) ListProviders(ctx context.Context, orgID string) ([]gatewayconfig.Provider, error)

func (*Service) ListQuotas

func (s *Service) ListQuotas(ctx context.Context, orgID string) ([]gatewayconfig.Quota, error)

func (*Service) ListRegionMemberships added in v0.3.0

func (s *Service) ListRegionMemberships(ctx context.Context, regionID string) ([]regions.OrgRegionMembership, error)

func (*Service) ListRegions added in v0.3.0

func (s *Service) ListRegions(ctx context.Context) ([]regions.Region, error)

func (*Service) ListRoutes

func (s *Service) ListRoutes(ctx context.Context, orgID string) ([]gatewayconfig.Route, error)

func (*Service) ListSigningKeys added in v0.3.0

func (s *Service) ListSigningKeys(ctx context.Context, orgID string) ([]access.SigningKey, error)

func (*Service) ListTeamMembers

func (s *Service) ListTeamMembers(ctx context.Context, teamID string) ([]tenancy.TeamMember, error)

func (*Service) ListTeams

func (s *Service) ListTeams(ctx context.Context, orgID, userID string) ([]tenancy.Team, error)

func (*Service) ListUsage

func (s *Service) ListUsage(ctx context.Context, orgID string, f usage.Filter) ([]usage.Record, error)

func (*Service) ListVisibleOrgAPIKeys

func (s *Service) ListVisibleOrgAPIKeys(ctx context.Context, orgID, viewerUserID string, viewerIsAdmin bool) ([]access.APIKey, error)

ListVisibleOrgAPIKeys returns org keys filtered for the viewer. Admins see all keys; members see service accounts plus their own personal keys.

func (*Service) ListWasmHooks

func (s *Service) ListWasmHooks(ctx context.Context, orgID string) ([]gatewayconfig.WasmHook, error)

func (*Service) OpenFederationPeerJoinToken added in v0.3.0

func (s *Service) OpenFederationPeerJoinToken(ctx context.Context, peerID string) (string, error)

func (*Service) PreviewOrgInvite

func (s *Service) PreviewOrgInvite(ctx context.Context, rawToken string) (*tenancy.InvitePreview, error)

func (*Service) PublishSnapshot

func (s *Service) PublishSnapshot(ctx context.Context) error

PublishSnapshot republishes the gateway snapshot and emits snapshot.published.

func (*Service) PutRegionOverlay added in v0.3.0

func (s *Service) PutRegionOverlay(ctx context.Context, regionID, orgID string, payload regions.OverlayPayload) (*regions.RegionConfigOverlay, error)

func (*Service) RecordDeploymentHeartbeat added in v0.3.0

func (s *Service) RecordDeploymentHeartbeat(ctx context.Context, deploymentID, joinToken string, snapVersion int64, build string) (*regions.GatewayDeployment, error)

func (*Service) RecordFederationPeerSync added in v0.3.0

func (s *Service) RecordFederationPeerSync(ctx context.Context, peerID string, cursor int64, syncErr string) error

func (*Service) RegisterDeployment added in v0.3.0

func (s *Service) RegisterDeployment(ctx context.Context, regionID, name, publicBaseURL string) (*regions.DeploymentWithToken, error)

func (*Service) RegisterFederationPeer added in v0.3.0

func (s *Service) RegisterFederationPeer(ctx context.Context, name, regionID, baseURL string) (*federation.PeerWithToken, error)

func (*Service) RemoveTeamMember

func (s *Service) RemoveTeamMember(ctx context.Context, teamID, userID string) error

func (*Service) ReorderPolicies

func (s *Service) ReorderPolicies(ctx context.Context, orgID string, items []gatewayconfig.PolicyPriorityUpdate) error

func (*Service) ResendOrgInvite

func (s *Service) ResendOrgInvite(ctx context.Context, orgID, inviteID string) (*tenancy.OrgInvite, string, error)

func (*Service) RevokeOrgInvite

func (s *Service) RevokeOrgInvite(ctx context.Context, orgID, inviteID string) error

func (*Service) RotateCredential

func (s *Service) RotateCredential(ctx context.Context, credentialID, secretRef, secretValue string) (*credentials.Credential, error)

func (*Service) RotateDeploymentJoinToken added in v0.3.0

func (s *Service) RotateDeploymentJoinToken(ctx context.Context, deploymentID string) (*regions.DeploymentWithToken, error)

func (*Service) RotateFederationPeerJoinToken added in v0.3.0

func (s *Service) RotateFederationPeerJoinToken(ctx context.Context, peerID string) (*federation.PeerWithToken, error)

func (*Service) RotateSigningKey added in v0.3.0

func (s *Service) RotateSigningKey(ctx context.Context, id, publicKeyPEM string) (*access.SigningKey, error)

func (*Service) SetOrgDefaultRetry

func (s *Service) SetOrgDefaultRetry(ctx context.Context, orgID string, retry *gatewayconfig.RetryConfig) (*gatewayconfig.RetryConfig, error)

func (*Service) SetOrgObjectStore

func (*Service) SummarizeUsage

func (s *Service) SummarizeUsage(ctx context.Context, orgID string, f usage.Filter) ([]usage.SummaryBucket, error)

func (*Service) UnbindOrgFromRegion added in v0.3.0

func (s *Service) UnbindOrgFromRegion(ctx context.Context, regionID, orgID string) error

func (*Service) UpdateA2AAgent

func (s *Service) UpdateA2AAgent(ctx context.Context, id string, alias, name, upstreamURL, cardURL, apiKeyEnv, authScheme *string, cardCache []byte, enabled *bool) (*gatewayconfig.A2AAgent, error)

func (*Service) UpdateCredential

func (s *Service) UpdateCredential(ctx context.Context, credentialID, name, status string) (*credentials.Credential, error)

func (*Service) UpdateFederationPeer added in v0.3.0

func (s *Service) UpdateFederationPeer(ctx context.Context, peerID, name, baseURL, status string) (*federation.ControlPlanePeer, error)

func (*Service) UpdateMCPBackend

func (s *Service) UpdateMCPBackend(ctx context.Context, id string, alias, name, baseURL, apiKeyEnv *string, methodAllowlist []byte, enabled *bool) (*gatewayconfig.MCPBackend, error)

func (*Service) UpdateOrgMemberRole

func (s *Service) UpdateOrgMemberRole(ctx context.Context, orgID, actorUserID, targetUserID, role string) (*tenancy.OrgMember, error)

func (*Service) UpdatePolicy

func (s *Service) UpdatePolicy(ctx context.Context, policyID string, name, expression *string, actions []gatewayconfig.PolicyAction, enabled *bool, priority *int) (*gatewayconfig.RequestPolicy, error)

func (*Service) UpdateProvider

func (s *Service) UpdateProvider(ctx context.Context, providerID, name, baseURL, apiKeyEnv string, config *json.RawMessage) (*gatewayconfig.Provider, error)

func (*Service) UpdateQuota

func (s *Service) UpdateQuota(ctx context.Context, quotaID string, limitValue int64) (*gatewayconfig.Quota, error)

func (*Service) UpdateRegion added in v0.3.0

func (s *Service) UpdateRegion(ctx context.Context, regionID, name, status string) (*regions.Region, error)

func (*Service) UpdateRoute

func (s *Service) UpdateRoute(ctx context.Context, routeID, model, providerID, targetModel string, fallbacks []gatewayconfig.RouteFallback, retry *gatewayconfig.RetryConfig, strategy string, weight int) (*gatewayconfig.Route, error)

func (*Service) UpdateSigningKey added in v0.3.0

func (s *Service) UpdateSigningKey(ctx context.Context, id, name, status string) (*access.SigningKey, error)

func (*Service) UpdateTeamMemberRole

func (s *Service) UpdateTeamMemberRole(ctx context.Context, teamID, actorUserID, targetUserID, role string) (*tenancy.TeamMember, error)

func (*Service) UpdateWasmHook

func (s *Service) UpdateWasmHook(ctx context.Context, id string, name, phase, moduleURI, digest *string, enabled *bool, priority *int, config []byte) (*gatewayconfig.WasmHook, error)

type SnapshotPublisher

type SnapshotPublisher interface {
	PublishSnapshot(ctx context.Context) error
	// PublishRegionSnapshots puts the global snapshot and only the listed regions' object-store blobs.
	PublishRegionSnapshots(ctx context.Context, regionIDs ...string) error
}

SnapshotPublisher publishes compiled gateway snapshots after config changes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL