Documentation
¶
Overview ¶
Package api provides shared helpers for the Connect-RPC API layer, including error mapping, pagination, and time conversion utilities.
Index ¶
- Constants
- Variables
- func BoundedFanOut[T any](ctx context.Context, in <-chan T, bufSize int) (<-chan T, <-chan error)
- func ClampPageSize(n uint32) uint32
- func EncodeCursor(c Cursor) (string, error)
- func GoTime(ts *timestamppb.Timestamp) time.Time
- func MCPAuthMiddleware(bearer *authn.Bearer, next http.Handler) http.Handler
- func MCPInterceptor(m *observability.Metrics) connect.Interceptor
- func NewAuthenticate(chain auth.Authenticator, bearer *authn.Bearer, tokens *credentials.Tokens) connect.UnaryInterceptorFunc
- func NewAuthorize(rt *policy.Runtime, catalog ProcedureCatalog, recorder *audit.Recorder, ...) connect.UnaryInterceptorFunc
- func NewWebhookHandler(router WebhookRouter, app WebhookAppender, m WebhookMetrics) http.Handler
- func ProtoTime(t time.Time) *timestamppb.Timestamp
- func SetStreamConfig(c StreamConfig)
- func SourceFromContext(ctx context.Context) (string, bool)
- func SourceInterceptor() connect.Interceptor
- func ToConnect(ctx context.Context, err error, reason string) error
- func WithHTTPRequest(ctx context.Context, r *http.Request) context.Context
- func WithResponseWriter(ctx context.Context, w http.ResponseWriter) context.Context
- func WithSource(ctx context.Context, source string) context.Context
- type AppendedWebhook
- type Area
- type AreaReader
- type AreaService
- type AuthDeps
- type AuthService
- func (s *AuthService) ChangePassword(ctx context.Context, req *connect.Request[authpb.ChangePasswordRequest]) (*connect.Response[authpb.ChangePasswordResponse], error)
- func (s *AuthService) CreateToken(ctx context.Context, req *connect.Request[authpb.CreateTokenRequest]) (*connect.Response[authpb.CreateTokenResponse], error)
- func (s *AuthService) CurrentUser(ctx context.Context, _ *connect.Request[authpb.CurrentUserRequest]) (*connect.Response[authpb.CurrentUserResponse], error)
- func (s *AuthService) ExplainAuthorization(ctx context.Context, req *connect.Request[authpb.ExplainAuthorizationRequest]) (*connect.Response[authpb.ExplainAuthorizationResponse], error)
- func (s *AuthService) ListUsers(ctx context.Context, _ *connect.Request[authpb.ListUsersRequest]) (*connect.Response[authpb.ListUsersResponse], error)
- func (s *AuthService) Login(ctx context.Context, req *connect.Request[authpb.LoginRequest]) (*connect.Response[authpb.LoginResponse], error)
- func (s *AuthService) Logout(ctx context.Context, _ *connect.Request[authpb.LogoutRequest]) (*connect.Response[authpb.LogoutResponse], error)
- func (s *AuthService) MintEnrollmentToken(ctx context.Context, req *connect.Request[authpb.MintEnrollmentTokenRequest]) (*connect.Response[authpb.MintEnrollmentTokenResponse], error)
- func (s *AuthService) RedeemEnrollmentToken(ctx context.Context, req *connect.Request[authpb.RedeemEnrollmentTokenRequest]) (*connect.Response[authpb.RedeemEnrollmentTokenResponse], error)
- func (s *AuthService) Refresh(ctx context.Context, _ *connect.Request[authpb.RefreshRequest]) (*connect.Response[authpb.RefreshResponse], error)
- func (s *AuthService) RegisterPasskey(ctx context.Context, _ *connect.Request[authpb.RegisterPasskeyRequest]) (*connect.Response[authpb.RegisterPasskeyResponse], error)
- func (s *AuthService) RevokeToken(ctx context.Context, req *connect.Request[authpb.RevokeTokenRequest]) (*connect.Response[authpb.RevokeTokenResponse], error)
- func (s *AuthService) StartWebAuthnChallenge(ctx context.Context, _ *connect.Request[authpb.StartWebAuthnChallengeRequest]) (*connect.Response[authpb.StartWebAuthnChallengeResponse], error)
- type Automation
- type AutomationControl
- type AutomationService
- func (s *AutomationService) Disable(ctx context.Context, req *connect.Request[v1.DisableAutomationRequest]) (*connect.Response[v1.DisableAutomationResponse], error)
- func (s *AutomationService) Enable(ctx context.Context, req *connect.Request[v1.EnableAutomationRequest]) (*connect.Response[v1.EnableAutomationResponse], error)
- func (s *AutomationService) Get(ctx context.Context, req *connect.Request[v1.GetAutomationRequest]) (*connect.Response[v1.GetAutomationResponse], error)
- func (s *AutomationService) List(ctx context.Context, req *connect.Request[v1.ListAutomationsRequest]) (*connect.Response[v1.ListAutomationsResponse], error)
- func (s *AutomationService) Trace(ctx context.Context, req *connect.Request[v1.TraceAutomationRequest], ...) error
- func (s *AutomationService) Trigger(ctx context.Context, req *connect.Request[v1.TriggerAutomationRequest]) (*connect.Response[v1.TriggerAutomationResponse], error)
- type CapabilityCaller
- type ConfigApplier
- type ConfigApplyResult
- type ConfigDiff
- type ConfigService
- func (s *ConfigService) Apply(ctx context.Context, req *connect.Request[v1.ApplyConfigRequest]) (*connect.Response[v1.ApplyConfigResponse], error)
- func (s *ConfigService) EvalCompute(ctx context.Context, req *connect.Request[v1.EvalComputeRequest]) (*connect.Response[v1.EvalComputeResponse], error)
- func (s *ConfigService) GetArtifact(ctx context.Context, _ *connect.Request[v1.GetConfigArtifactRequest]) (*connect.Response[v1.GetConfigArtifactResponse], error)
- func (s *ConfigService) Reload(ctx context.Context, _ *connect.Request[v1.ReloadConfigRequest]) (*connect.Response[v1.ReloadConfigResponse], error)
- func (s *ConfigService) Validate(ctx context.Context, req *connect.Request[v1.ValidateConfigRequest]) (*connect.Response[v1.ValidateConfigResponse], error)
- type Cursor
- type DashboardService
- func (*DashboardService) Create(ctx context.Context, _ *connect.Request[v1.CreateDashboardRequest]) (*connect.Response[v1.CreateDashboardResponse], error)
- func (*DashboardService) Delete(ctx context.Context, _ *connect.Request[v1.DeleteDashboardRequest]) (*connect.Response[v1.DeleteDashboardResponse], error)
- func (*DashboardService) Get(ctx context.Context, _ *connect.Request[v1.GetDashboardRequest]) (*connect.Response[v1.GetDashboardResponse], error)
- func (*DashboardService) GetWidgetCatalog(ctx context.Context, _ *connect.Request[v1.GetWidgetCatalogRequest]) (*connect.Response[v1.GetWidgetCatalogResponse], error)
- func (*DashboardService) List(ctx context.Context, _ *connect.Request[v1.ListDashboardsRequest]) (*connect.Response[v1.ListDashboardsResponse], error)
- func (*DashboardService) SaveLayout(ctx context.Context, _ *connect.Request[v1.SaveDashboardLayoutRequest]) (*connect.Response[v1.SaveDashboardLayoutResponse], error)
- type Device
- type DeviceReader
- type DeviceService
- func (s *DeviceService) Get(ctx context.Context, req *connect.Request[v1.GetDeviceRequest]) (*connect.Response[v1.GetDeviceResponse], error)
- func (s *DeviceService) List(ctx context.Context, req *connect.Request[v1.ListDevicesRequest]) (*connect.Response[v1.ListDevicesResponse], error)
- func (s *DeviceService) Reassign(ctx context.Context, req *connect.Request[v1.ReassignDeviceRequest]) (*connect.Response[v1.ReassignDeviceResponse], error)
- func (s *DeviceService) Rename(ctx context.Context, req *connect.Request[v1.RenameDeviceRequest]) (*connect.Response[v1.RenameDeviceResponse], error)
- type DeviceWriter
- type Driver
- type DriverControl
- type DriverInstance
- type DriverService
- func (s *DriverService) InstanceHealth(ctx context.Context, req *connect.Request[v1.InstanceHealthRequest]) (*connect.Response[v1.InstanceHealthResponse], error)
- func (s *DriverService) ListDrivers(ctx context.Context, req *connect.Request[v1.ListDriversRequest]) (*connect.Response[v1.ListDriversResponse], error)
- func (s *DriverService) ListInstances(ctx context.Context, req *connect.Request[v1.ListInstancesRequest]) (*connect.Response[v1.ListInstancesResponse], error)
- func (s *DriverService) RestartInstance(ctx context.Context, req *connect.Request[v1.RestartInstanceRequest]) (*connect.Response[v1.RestartInstanceResponse], error)
- type Entity
- type EntityChange
- type EntityFilter
- type EntityReader
- type EntitySelector
- type EntityService
- func (s *EntityService) CallCapability(ctx context.Context, req *connect.Request[v1.CallCapabilityRequest]) (*connect.Response[v1.CallCapabilityResponse], error)
- func (s *EntityService) Get(ctx context.Context, req *connect.Request[v1.GetEntityRequest]) (*connect.Response[v1.GetEntityResponse], error)
- func (s *EntityService) List(ctx context.Context, req *connect.Request[v1.ListEntitiesRequest]) (*connect.Response[v1.ListEntitiesResponse], error)
- func (s *EntityService) SetPolicyRuntime(rt *policy.Runtime)
- func (s *EntityService) SetStreamSource(src EntityStreamSource)
- func (s *EntityService) Subscribe(ctx context.Context, req *connect.Request[v1.SubscribeEntitiesRequest], ...) error
- type EntityStreamSource
- type Event
- type EventAppender
- type EventFilter
- type EventService
- type EventSource
- type HeartbeatTicker
- type MCPCapsProvider
- type MCPConfig
- type PageReq
- type ProcedureCatalog
- type SceneService
- func (*SceneService) Apply(ctx context.Context, _ *connect.Request[v1.ApplySceneRequest]) (*connect.Response[v1.ApplySceneResponse], error)
- func (*SceneService) List(ctx context.Context, _ *connect.Request[v1.ListScenesRequest]) (*connect.Response[v1.ListScenesResponse], error)
- func (*SceneService) Preview(ctx context.Context, _ *connect.Request[v1.PreviewSceneRequest]) (*connect.Response[v1.PreviewSceneResponse], error)
- type Script
- type ScriptRunResult
- type ScriptRunner
- type ScriptService
- func (s *ScriptService) Cancel(ctx context.Context, req *connect.Request[v1.CancelScriptRequest]) (*connect.Response[v1.CancelScriptResponse], error)
- func (s *ScriptService) Eval(ctx context.Context, req *connect.Request[v1.EvalScriptRequest]) (*connect.Response[v1.EvalScriptResponse], error)
- func (s *ScriptService) List(ctx context.Context, req *connect.Request[v1.ListScriptsRequest]) (*connect.Response[v1.ListScriptsResponse], error)
- func (s *ScriptService) Run(ctx context.Context, req *connect.Request[v1.RunScriptRequest]) (*connect.Response[v1.RunScriptResponse], error)
- func (s *ScriptService) RunTests(ctx context.Context, req *connect.Request[v1.RunTestsRequest], ...) error
- type StarlarkTestEvent
- type StreamConfig
- type SubsystemHealth
- type SystemBackend
- type SystemService
- func (s *SystemService) CreateSnapshot(ctx context.Context, req *connect.Request[systemv1.CreateSnapshotRequest]) (*connect.Response[systemv1.CreateSnapshotResponse], error)
- func (s *SystemService) Diagnostics(ctx context.Context, _ *connect.Request[systemv1.DiagnosticsRequest]) (*connect.Response[systemv1.DiagnosticsResponse], error)
- func (s *SystemService) GetConfigDir(ctx context.Context, _ *connect.Request[systemv1.GetConfigDirRequest]) (*connect.Response[systemv1.GetConfigDirResponse], error)
- func (s *SystemService) GetMCPConfig(ctx context.Context, _ *connect.Request[systemv1.GetMCPConfigRequest]) (*connect.Response[systemv1.GetMCPConfigResponse], error)
- func (s *SystemService) Health(ctx context.Context, _ *connect.Request[systemv1.HealthRequest]) (*connect.Response[systemv1.HealthResponse], error)
- func (s *SystemService) Metrics(ctx context.Context, _ *connect.Request[systemv1.MetricsRequest]) (*connect.Response[systemv1.MetricsResponse], error)
- func (s *SystemService) RecordConfigFileEdit(ctx context.Context, ...) (*connect.Response[systemv1.RecordConfigFileEditResponse], error)
- func (s *SystemService) Version(_ context.Context, _ *connect.Request[systemv1.VersionRequest]) (*connect.Response[systemv1.VersionResponse], error)
- type TraceEvent
- type VersionInfo
- type WebhookAppender
- type WebhookMetrics
- type WebhookRouter
- type Zone
- type ZoneReader
- type ZoneService
Constants ¶
const ( DefaultPageSize = 100 MaxPageSize = 1000 )
Variables ¶
var ( ErrEntityNotFound = errors.New("entity not found") ErrDeviceNotFound = errors.New("device not found") ErrAreaNotFound = errors.New("area not found") ErrZoneNotFound = errors.New("zone not found") ErrDriverNotFound = errors.New("driver not found") ErrInstanceNotFound = errors.New("driver instance not found") ErrAutomationNotFound = errors.New("automation not found") ErrScriptNotFound = errors.New("script not found") ErrAutomationDisabled = errors.New("automation disabled") ErrRunNotFound = errors.New("run not found") ErrRunAlreadyFinished = errors.New("run already finished") ErrCapabilityUnknown = errors.New("capability unknown") ErrSubscriptionOverflow = errors.New("subscription overflow") ErrValidationFailed = errors.New("validation failed") ErrNotImplemented = errors.New("not implemented") ErrPathEscape = errors.New("path escapes config dir") )
Functions ¶
func BoundedFanOut ¶
BoundedFanOut reads from in and forwards to an output channel of size bufSize. If the output channel is full, it closes the output channel and sends ErrSubscriptionOverflow on the done channel. When in is closed or ctx is cancelled, done receives nil (or ctx.Err()).
func ClampPageSize ¶
func EncodeCursor ¶
func MCPAuthMiddleware ¶
MCPAuthMiddleware wraps an http.Handler with bearer-token authentication. It calls the Bearer authenticator; on success it stashes the principal on the context. On failure or missing header it passes through without setting the principal — the MCP handler decides whether to require authentication.
func MCPInterceptor ¶
func MCPInterceptor(m *observability.Metrics) connect.Interceptor
MCPInterceptor emits gohome_mcp_* metrics for MCP-sourced requests.
func NewAuthenticate ¶
func NewAuthenticate(chain auth.Authenticator, bearer *authn.Bearer, tokens *credentials.Tokens) connect.UnaryInterceptorFunc
NewAuthenticate returns the C9 authenticate interceptor. Wraps the supplied authenticator chain, attaches Principal + (if applicable) compiled token scope to the request context.
func NewAuthorize ¶
func NewAuthorize(rt *policy.Runtime, catalog ProcedureCatalog, recorder *audit.Recorder, metrics *observability.Metrics) connect.UnaryInterceptorFunc
NewAuthorize returns the C9 authorize interceptor. When rt is nil the interceptor passes all requests through (daemon bring-up before the policy runtime is loaded). metrics is optional; pass nil to disable metric emission.
func NewWebhookHandler ¶
func NewWebhookHandler(router WebhookRouter, app WebhookAppender, m WebhookMetrics) http.Handler
NewWebhookHandler returns an http.Handler mounted at /webhooks/.
func SetStreamConfig ¶
func SetStreamConfig(c StreamConfig)
SetStreamConfig replaces the global stream config. Intended for tests.
func SourceFromContext ¶
SourceFromContext returns the source. Returns ("cli", false) if not set.
func SourceInterceptor ¶
func SourceInterceptor() connect.Interceptor
SourceInterceptor reads x-gohome-source header and puts it on context.
func WithHTTPRequest ¶
WithHTTPRequest stores an *http.Request on the context so Connect handlers can read incoming cookies (e.g. for session refresh).
func WithResponseWriter ¶
WithResponseWriter stores an http.ResponseWriter on the context so Connect handlers can write cookies.
Types ¶
type AppendedWebhook ¶
AppendedWebhook is the parsed and verified inbound webhook payload.
type AreaReader ¶
type AreaService ¶
type AreaService struct {
// contains filtered or unexported fields
}
func NewAreaService ¶
func NewAreaService(be AreaReader) *AreaService
func (*AreaService) Get ¶
func (s *AreaService) Get(ctx context.Context, req *connect.Request[v1.GetAreaRequest]) (*connect.Response[v1.GetAreaResponse], error)
func (*AreaService) List ¶
func (s *AreaService) List(ctx context.Context, req *connect.Request[v1.ListAreasRequest]) (*connect.Response[v1.ListAreasResponse], error)
type AuthDeps ¶
type AuthDeps struct {
Identity *identity.Store
Password *credentials.Password
Tokens *credentials.Tokens
Sessions *sessions.Store
Enrollment *credentials.Enrollment
Throttle *throttle.Throttle
Audit *audit.Recorder
Policy *policy.Runtime
Metrics *observability.Metrics
}
AuthDeps holds the dependencies required by the real AuthService.
type AuthService ¶
type AuthService struct {
// contains filtered or unexported fields
}
AuthService implements AuthServiceHandler with real auth logic.
func NewAuthService ¶
func NewAuthService(d AuthDeps) *AuthService
NewAuthService constructs an AuthService with the supplied dependencies.
func (*AuthService) ChangePassword ¶
func (s *AuthService) ChangePassword(ctx context.Context, req *connect.Request[authpb.ChangePasswordRequest]) (*connect.Response[authpb.ChangePasswordResponse], error)
ChangePassword verifies the old password and sets a new one.
func (*AuthService) CreateToken ¶
func (s *AuthService) CreateToken(ctx context.Context, req *connect.Request[authpb.CreateTokenRequest]) (*connect.Response[authpb.CreateTokenResponse], error)
CreateToken issues a new bearer token for the authenticated user.
func (*AuthService) CurrentUser ¶
func (s *AuthService) CurrentUser(ctx context.Context, _ *connect.Request[authpb.CurrentUserRequest]) (*connect.Response[authpb.CurrentUserResponse], error)
CurrentUser returns the authenticated principal's user record.
func (*AuthService) ExplainAuthorization ¶
func (s *AuthService) ExplainAuthorization(ctx context.Context, req *connect.Request[authpb.ExplainAuthorizationRequest]) (*connect.Response[authpb.ExplainAuthorizationResponse], error)
ExplainAuthorization evaluates and explains a policy decision for a given user and action.
func (*AuthService) ListUsers ¶
func (s *AuthService) ListUsers(ctx context.Context, _ *connect.Request[authpb.ListUsersRequest]) (*connect.Response[authpb.ListUsersResponse], error)
ListUsers returns all users in the identity store.
func (*AuthService) Login ¶
func (s *AuthService) Login(ctx context.Context, req *connect.Request[authpb.LoginRequest]) (*connect.Response[authpb.LoginResponse], error)
Login authenticates a user with username + password and issues a session cookie.
func (*AuthService) Logout ¶
func (s *AuthService) Logout(ctx context.Context, _ *connect.Request[authpb.LogoutRequest]) (*connect.Response[authpb.LogoutResponse], error)
Logout destroys the current session and clears cookies.
func (*AuthService) MintEnrollmentToken ¶
func (s *AuthService) MintEnrollmentToken(ctx context.Context, req *connect.Request[authpb.MintEnrollmentTokenRequest]) (*connect.Response[authpb.MintEnrollmentTokenResponse], error)
MintEnrollmentToken issues a one-time enrollment token for a user.
func (*AuthService) RedeemEnrollmentToken ¶
func (s *AuthService) RedeemEnrollmentToken(ctx context.Context, req *connect.Request[authpb.RedeemEnrollmentTokenRequest]) (*connect.Response[authpb.RedeemEnrollmentTokenResponse], error)
RedeemEnrollmentToken validates and consumes a one-time enrollment token.
func (*AuthService) Refresh ¶
func (s *AuthService) Refresh(ctx context.Context, _ *connect.Request[authpb.RefreshRequest]) (*connect.Response[authpb.RefreshResponse], error)
Refresh rotates session cookies using the refresh cookie in the request.
func (*AuthService) RegisterPasskey ¶
func (s *AuthService) RegisterPasskey(ctx context.Context, _ *connect.Request[authpb.RegisterPasskeyRequest]) (*connect.Response[authpb.RegisterPasskeyResponse], error)
RegisterPasskey is not yet implemented.
func (*AuthService) RevokeToken ¶
func (s *AuthService) RevokeToken(ctx context.Context, req *connect.Request[authpb.RevokeTokenRequest]) (*connect.Response[authpb.RevokeTokenResponse], error)
RevokeToken revokes a token by ID.
func (*AuthService) StartWebAuthnChallenge ¶
func (s *AuthService) StartWebAuthnChallenge(ctx context.Context, _ *connect.Request[authpb.StartWebAuthnChallengeRequest]) (*connect.Response[authpb.StartWebAuthnChallengeResponse], error)
StartWebAuthnChallenge is not yet implemented.
type Automation ¶
type AutomationControl ¶
type AutomationControl interface {
List(ctx context.Context, page PageReq) ([]Automation, Cursor, error)
Get(ctx context.Context, id string) (Automation, error)
SetEnabled(ctx context.Context, id string, enabled bool, actor string) (Automation, error)
Trigger(ctx context.Context, id, actor string) (runID string, err error)
Trace(ctx context.Context, automationID, runID string, fromCursor uint64) (<-chan TraceEvent, func(), error)
}
type AutomationService ¶
type AutomationService struct {
// contains filtered or unexported fields
}
func NewAutomationService ¶
func NewAutomationService(be AutomationControl) *AutomationService
func (*AutomationService) Disable ¶
func (s *AutomationService) Disable(ctx context.Context, req *connect.Request[v1.DisableAutomationRequest]) (*connect.Response[v1.DisableAutomationResponse], error)
func (*AutomationService) Enable ¶
func (s *AutomationService) Enable(ctx context.Context, req *connect.Request[v1.EnableAutomationRequest]) (*connect.Response[v1.EnableAutomationResponse], error)
func (*AutomationService) Get ¶
func (s *AutomationService) Get(ctx context.Context, req *connect.Request[v1.GetAutomationRequest]) (*connect.Response[v1.GetAutomationResponse], error)
func (*AutomationService) List ¶
func (s *AutomationService) List(ctx context.Context, req *connect.Request[v1.ListAutomationsRequest]) (*connect.Response[v1.ListAutomationsResponse], error)
func (*AutomationService) Trace ¶
func (s *AutomationService) Trace(ctx context.Context, req *connect.Request[v1.TraceAutomationRequest], stream *connect.ServerStream[v1.TraceAutomationResponse]) error
func (*AutomationService) Trigger ¶
func (s *AutomationService) Trigger(ctx context.Context, req *connect.Request[v1.TriggerAutomationRequest]) (*connect.Response[v1.TriggerAutomationResponse], error)
type CapabilityCaller ¶
type CapabilityCaller interface {
// Call dispatches the capability invocation through the carport supervisor;
// blocks until the driver acks or ctx is cancelled. Returns the command's
// correlation id (the CommandIssued event id) on success.
Call(ctx context.Context, entityID, capability string, params map[string]any) (correlationID string, err error)
}
type ConfigApplier ¶
type ConfigApplier interface {
Validate(ctx context.Context, pklBundle []byte) (valid bool, errs []string, diff ConfigDiff, hash string, err error)
Apply(ctx context.Context, pklBundle []byte, message, expectedHash string, dryRun, strict bool, actor string) (ConfigApplyResult, error)
Reload(ctx context.Context, actor string) (diff ConfigDiff, correlationID string, err error)
CurrentArtifact(ctx context.Context) (*configv1.ConfigSnapshot, error)
}
type ConfigApplyResult ¶
type ConfigApplyResult struct {
Applied bool
Diff ConfigDiff
CorrelationID string
BundleHash string
Errors []string
}
type ConfigDiff ¶
type ConfigService ¶
type ConfigService struct {
// contains filtered or unexported fields
}
func NewConfigService ¶
func NewConfigService(be ConfigApplier) *ConfigService
func (*ConfigService) Apply ¶
func (s *ConfigService) Apply(ctx context.Context, req *connect.Request[v1.ApplyConfigRequest]) (*connect.Response[v1.ApplyConfigResponse], error)
func (*ConfigService) EvalCompute ¶
func (s *ConfigService) EvalCompute(ctx context.Context, req *connect.Request[v1.EvalComputeRequest]) (*connect.Response[v1.EvalComputeResponse], error)
func (*ConfigService) GetArtifact ¶
func (s *ConfigService) GetArtifact(ctx context.Context, _ *connect.Request[v1.GetConfigArtifactRequest]) (*connect.Response[v1.GetConfigArtifactResponse], error)
func (*ConfigService) Reload ¶
func (s *ConfigService) Reload(ctx context.Context, _ *connect.Request[v1.ReloadConfigRequest]) (*connect.Response[v1.ReloadConfigResponse], error)
func (*ConfigService) Validate ¶
func (s *ConfigService) Validate(ctx context.Context, req *connect.Request[v1.ValidateConfigRequest]) (*connect.Response[v1.ValidateConfigResponse], error)
type Cursor ¶
func DecodeCursor ¶
type DashboardService ¶
type DashboardService struct{}
DashboardService stub.
func NewDashboardService ¶
func NewDashboardService() *DashboardService
func (*DashboardService) Create ¶
func (*DashboardService) Create(ctx context.Context, _ *connect.Request[v1.CreateDashboardRequest]) (*connect.Response[v1.CreateDashboardResponse], error)
func (*DashboardService) Delete ¶
func (*DashboardService) Delete(ctx context.Context, _ *connect.Request[v1.DeleteDashboardRequest]) (*connect.Response[v1.DeleteDashboardResponse], error)
func (*DashboardService) Get ¶
func (*DashboardService) Get(ctx context.Context, _ *connect.Request[v1.GetDashboardRequest]) (*connect.Response[v1.GetDashboardResponse], error)
func (*DashboardService) GetWidgetCatalog ¶
func (*DashboardService) GetWidgetCatalog(ctx context.Context, _ *connect.Request[v1.GetWidgetCatalogRequest]) (*connect.Response[v1.GetWidgetCatalogResponse], error)
func (*DashboardService) List ¶
func (*DashboardService) List(ctx context.Context, _ *connect.Request[v1.ListDashboardsRequest]) (*connect.Response[v1.ListDashboardsResponse], error)
func (*DashboardService) SaveLayout ¶
func (*DashboardService) SaveLayout(ctx context.Context, _ *connect.Request[v1.SaveDashboardLayoutRequest]) (*connect.Response[v1.SaveDashboardLayoutResponse], error)
type DeviceReader ¶
type DeviceService ¶
type DeviceService struct {
// contains filtered or unexported fields
}
func NewDeviceService ¶
func NewDeviceService(r DeviceReader, w DeviceWriter) *DeviceService
func (*DeviceService) Get ¶
func (s *DeviceService) Get(ctx context.Context, req *connect.Request[v1.GetDeviceRequest]) (*connect.Response[v1.GetDeviceResponse], error)
func (*DeviceService) List ¶
func (s *DeviceService) List(ctx context.Context, req *connect.Request[v1.ListDevicesRequest]) (*connect.Response[v1.ListDevicesResponse], error)
func (*DeviceService) Reassign ¶
func (s *DeviceService) Reassign(ctx context.Context, req *connect.Request[v1.ReassignDeviceRequest]) (*connect.Response[v1.ReassignDeviceResponse], error)
func (*DeviceService) Rename ¶
func (s *DeviceService) Rename(ctx context.Context, req *connect.Request[v1.RenameDeviceRequest]) (*connect.Response[v1.RenameDeviceResponse], error)
type DeviceWriter ¶
type DeviceWriter interface {
RenameDevice(ctx context.Context, id, newName, actor string) (Device, error)
ReassignDevice(ctx context.Context, id, newAreaID, actor string) (Device, error)
}
DeviceWriter mutates devices and emits the corresponding registry-mutation events (DeviceRenamed, DeviceReassigned). actor is the principal id of the caller; empty string means "system".
type DriverControl ¶
type DriverControl interface {
ListDrivers(ctx context.Context, page PageReq) ([]Driver, Cursor, error)
ListInstances(ctx context.Context, page PageReq) ([]DriverInstance, Cursor, error)
InstanceHealth(ctx context.Context, instanceID string) (ok bool, detail string, err error)
RestartInstance(ctx context.Context, instanceID, reason, actor string) error
}
type DriverInstance ¶
type DriverService ¶
type DriverService struct {
// contains filtered or unexported fields
}
func NewDriverService ¶
func NewDriverService(be DriverControl) *DriverService
func (*DriverService) InstanceHealth ¶
func (s *DriverService) InstanceHealth(ctx context.Context, req *connect.Request[v1.InstanceHealthRequest]) (*connect.Response[v1.InstanceHealthResponse], error)
func (*DriverService) ListDrivers ¶
func (s *DriverService) ListDrivers(ctx context.Context, req *connect.Request[v1.ListDriversRequest]) (*connect.Response[v1.ListDriversResponse], error)
func (*DriverService) ListInstances ¶
func (s *DriverService) ListInstances(ctx context.Context, req *connect.Request[v1.ListInstancesRequest]) (*connect.Response[v1.ListInstancesResponse], error)
func (*DriverService) RestartInstance ¶
func (s *DriverService) RestartInstance(ctx context.Context, req *connect.Request[v1.RestartInstanceRequest]) (*connect.Response[v1.RestartInstanceResponse], error)
type Entity ¶
type Entity struct {
ID, Type, DeviceID, AreaID, ZoneID, FriendlyName string
State *entityv1.Attributes
Capabilities *entityv1.Attributes
}
type EntityChange ¶
type EntityFilter ¶
type EntityFilter struct {
// contains filtered or unexported fields
}
func NewEntityFilter ¶
func NewEntityFilter(rt *policy.Runtime, mode commonpb.PolicyMode) *EntityFilter
func (*EntityFilter) AllowsEntity ¶
func (*EntityFilter) Preflight ¶
func (f *EntityFilter) Preflight(ctx context.Context, p auth.Principal, candidates []policy.Target) ([]policy.Target, error)
Preflight evaluates candidates at subscription open. In STRICT mode, returns CodePermissionDenied if any entity is denied. In FILTER mode, returns the narrowed list silently. Nil rt allows all.
type EntityReader ¶
type EntitySelector ¶
type EntityService ¶
type EntityService struct {
// contains filtered or unexported fields
}
func NewEntityService ¶
func NewEntityService(r EntityReader, caller CapabilityCaller) *EntityService
func (*EntityService) CallCapability ¶
func (s *EntityService) CallCapability(ctx context.Context, req *connect.Request[v1.CallCapabilityRequest]) (*connect.Response[v1.CallCapabilityResponse], error)
func (*EntityService) Get ¶
func (s *EntityService) Get(ctx context.Context, req *connect.Request[v1.GetEntityRequest]) (*connect.Response[v1.GetEntityResponse], error)
func (*EntityService) List ¶
func (s *EntityService) List(ctx context.Context, req *connect.Request[v1.ListEntitiesRequest]) (*connect.Response[v1.ListEntitiesResponse], error)
func (*EntityService) SetPolicyRuntime ¶
func (s *EntityService) SetPolicyRuntime(rt *policy.Runtime)
SetPolicyRuntime wires the policy runtime after construction.
func (*EntityService) SetStreamSource ¶
func (s *EntityService) SetStreamSource(src EntityStreamSource)
SetStreamSource wires the live subscription source after construction (used by Task 17 to avoid breaking the constructor signature).
func (*EntityService) Subscribe ¶
func (s *EntityService) Subscribe(ctx context.Context, req *connect.Request[v1.SubscribeEntitiesRequest], stream *connect.ServerStream[v1.SubscribeEntitiesResponse]) error
type EntityStreamSource ¶
type EntityStreamSource interface {
// Subscribe returns a channel of EntityChange events filtered by sel,
// optionally replaying from fromCursor. The returned cancel func MUST be
// called to release server-side resources.
Subscribe(ctx context.Context, sel EntitySelector, fromCursor uint64) (<-chan EntityChange, func(), error)
}
EntityStreamSource is implemented in Task 17. Declared here so the field type compiles; concrete impl is added later.
type EventAppender ¶
type EventAppender interface {
Append(ctx context.Context, payload *eventv1.Payload) (uint64, error)
}
EventAppender appends a raw event payload to the event store.
type EventFilter ¶
type EventService ¶
type EventService struct {
// contains filtered or unexported fields
}
func NewEventService ¶
func NewEventService(be EventSource) *EventService
func (*EventService) Query ¶
func (s *EventService) Query(ctx context.Context, req *connect.Request[v1.QueryEventsRequest]) (*connect.Response[v1.QueryEventsResponse], error)
func (*EventService) Tail ¶
func (s *EventService) Tail(ctx context.Context, req *connect.Request[v1.TailEventsRequest], stream *connect.ServerStream[v1.TailEventsResponse]) error
type EventSource ¶
type HeartbeatTicker ¶
type HeartbeatTicker struct {
// contains filtered or unexported fields
}
func NewHeartbeatTicker ¶
func NewHeartbeatTicker(ctx context.Context, interval time.Duration) *HeartbeatTicker
func (*HeartbeatTicker) C ¶
func (t *HeartbeatTicker) C() <-chan time.Time
func (*HeartbeatTicker) NotePayloadSent ¶
func (t *HeartbeatTicker) NotePayloadSent()
func (*HeartbeatTicker) Stop ¶
func (t *HeartbeatTicker) Stop()
type MCPCapsProvider ¶
MCPCapsProvider returns the current MCP capability caps.
type ProcedureCatalog ¶
type ProcedureCatalog interface {
Resolve(procedure string, requestAny any) (auth.Action, auth.Target, bool)
}
ProcedureCatalog resolves a Connect procedure name and request body to the corresponding auth.Action and auth.Target.
type SceneService ¶
type SceneService struct{}
SceneService stub.
func NewSceneService ¶
func NewSceneService() *SceneService
func (*SceneService) Apply ¶
func (*SceneService) Apply(ctx context.Context, _ *connect.Request[v1.ApplySceneRequest]) (*connect.Response[v1.ApplySceneResponse], error)
func (*SceneService) List ¶
func (*SceneService) List(ctx context.Context, _ *connect.Request[v1.ListScenesRequest]) (*connect.Response[v1.ListScenesResponse], error)
func (*SceneService) Preview ¶
func (*SceneService) Preview(ctx context.Context, _ *connect.Request[v1.PreviewSceneRequest]) (*connect.Response[v1.PreviewSceneResponse], error)
type ScriptRunResult ¶
type ScriptRunner ¶
type ScriptRunner interface {
List(ctx context.Context, page PageReq) ([]Script, Cursor, error)
Run(ctx context.Context, name string, args map[string]any, actor string) (ScriptRunResult, error)
Cancel(ctx context.Context, runID string) error
Eval(ctx context.Context, expr string, actor string) (result *structpb.Value, stdout string, err error)
RunTests(ctx context.Context, path string) (<-chan StarlarkTestEvent, func(), error)
}
type ScriptService ¶
type ScriptService struct {
// contains filtered or unexported fields
}
func NewScriptService ¶
func NewScriptService(be ScriptRunner, events EventAppender, caps MCPCapsProvider) *ScriptService
func (*ScriptService) Cancel ¶
func (s *ScriptService) Cancel(ctx context.Context, req *connect.Request[v1.CancelScriptRequest]) (*connect.Response[v1.CancelScriptResponse], error)
func (*ScriptService) Eval ¶
func (s *ScriptService) Eval(ctx context.Context, req *connect.Request[v1.EvalScriptRequest]) (*connect.Response[v1.EvalScriptResponse], error)
func (*ScriptService) List ¶
func (s *ScriptService) List(ctx context.Context, req *connect.Request[v1.ListScriptsRequest]) (*connect.Response[v1.ListScriptsResponse], error)
func (*ScriptService) Run ¶
func (s *ScriptService) Run(ctx context.Context, req *connect.Request[v1.RunScriptRequest]) (*connect.Response[v1.RunScriptResponse], error)
func (*ScriptService) RunTests ¶
func (s *ScriptService) RunTests(ctx context.Context, req *connect.Request[v1.RunTestsRequest], stream *connect.ServerStream[v1.RunTestsResponse]) error
type StarlarkTestEvent ¶
type StreamConfig ¶
StreamConfig holds tunables for streaming RPCs.
func DefaultStreamConfig ¶
func DefaultStreamConfig() StreamConfig
DefaultStreamConfig returns the production defaults.
type SubsystemHealth ¶
type SystemBackend ¶
type SystemBackend interface {
Version() VersionInfo
Health(ctx context.Context) (ok bool, summary string, sub []SubsystemHealth)
MetricsText() (string, error)
Diagnostics(ctx context.Context) (bundle []byte, configHash string, generatedAt time.Time, err error)
CreateSnapshot(ctx context.Context, owner, reason string) (cursor uint64, createdAt time.Time, err error)
ConfigDir(ctx context.Context) (string, error)
MCPConfig(ctx context.Context) (MCPConfig, error)
RecordConfigFileEdit(ctx context.Context, p auth.Principal, sessionID, path, sha256Hex string, sizeBytes uint32) (uint64, error)
}
type SystemService ¶
type SystemService struct {
// contains filtered or unexported fields
}
func NewSystemService ¶
func NewSystemService(be SystemBackend) *SystemService
func (*SystemService) CreateSnapshot ¶
func (s *SystemService) CreateSnapshot(ctx context.Context, req *connect.Request[systemv1.CreateSnapshotRequest]) (*connect.Response[systemv1.CreateSnapshotResponse], error)
func (*SystemService) Diagnostics ¶
func (s *SystemService) Diagnostics(ctx context.Context, _ *connect.Request[systemv1.DiagnosticsRequest]) (*connect.Response[systemv1.DiagnosticsResponse], error)
func (*SystemService) GetConfigDir ¶
func (s *SystemService) GetConfigDir(ctx context.Context, _ *connect.Request[systemv1.GetConfigDirRequest]) (*connect.Response[systemv1.GetConfigDirResponse], error)
func (*SystemService) GetMCPConfig ¶
func (s *SystemService) GetMCPConfig(ctx context.Context, _ *connect.Request[systemv1.GetMCPConfigRequest]) (*connect.Response[systemv1.GetMCPConfigResponse], error)
func (*SystemService) Health ¶
func (s *SystemService) Health(ctx context.Context, _ *connect.Request[systemv1.HealthRequest]) (*connect.Response[systemv1.HealthResponse], error)
func (*SystemService) Metrics ¶
func (s *SystemService) Metrics(ctx context.Context, _ *connect.Request[systemv1.MetricsRequest]) (*connect.Response[systemv1.MetricsResponse], error)
func (*SystemService) RecordConfigFileEdit ¶
func (s *SystemService) RecordConfigFileEdit(ctx context.Context, req *connect.Request[systemv1.RecordConfigFileEditRequest]) (*connect.Response[systemv1.RecordConfigFileEditResponse], error)
func (*SystemService) Version ¶
func (s *SystemService) Version(_ context.Context, _ *connect.Request[systemv1.VersionRequest]) (*connect.Response[systemv1.VersionResponse], error)
type TraceEvent ¶
type VersionInfo ¶
type WebhookAppender ¶
type WebhookAppender interface {
AppendWebhook(ctx context.Context, w AppendedWebhook) error
}
WebhookAppender persists the inbound webhook as a WebhookReceived event.
type WebhookMetrics ¶
type WebhookMetrics interface {
Inc(slug, result string)
}
WebhookMetrics is optional; nil is fine in tests.
type WebhookRouter ¶
WebhookRouter knows which slugs are registered and their HMAC secret.
type ZoneReader ¶
type ZoneService ¶
type ZoneService struct {
// contains filtered or unexported fields
}
func NewZoneService ¶
func NewZoneService(be ZoneReader) *ZoneService
func (*ZoneService) Get ¶
func (s *ZoneService) Get(ctx context.Context, req *connect.Request[v1.GetZoneRequest]) (*connect.Response[v1.GetZoneResponse], error)
func (*ZoneService) List ¶
func (s *ZoneService) List(ctx context.Context, req *connect.Request[v1.ListZonesRequest]) (*connect.Response[v1.ListZonesResponse], error)
Source Files
¶
- context.go
- deps.go
- errors.go
- interceptor_authn.go
- interceptor_authz.go
- mcp_auth_middleware.go
- mcp_interceptor.go
- page_helpers.go
- pagination.go
- service_area.go
- service_auth.go
- service_automation.go
- service_config.go
- service_device.go
- service_driver.go
- service_entity.go
- service_event.go
- service_script.go
- service_system.go
- service_unimplemented.go
- service_zone.go
- source.go
- streaming.go
- subscription_filter.go
- time.go
- webhook.go