Documentation
¶
Index ¶
- Constants
- Variables
- func ClientErr(err error) error
- func ClientErrf(format string, a ...any) error
- type ActiveMedia
- type ActiveMediaResponse
- type AddMappingParams
- type AllMappingsResponse
- type BrowseEntry
- type BrowseParams
- type BrowseResults
- type ClientError
- type ClientResponse
- type ClientsDeleteParams
- type ClientsPairStartResponse
- type ClientsPairedNotification
- type ClientsResponse
- type DeleteClientParams
- type DeleteInboxParams
- type DeleteMappingParams
- type ErrorObject
- type HealthCheckResponse
- type HistoryResponse
- type HistoryResponseEntry
- type InboxMessage
- type InboxResponse
- type IndexingStatusResponse
- type InputGamepadParams
- type InputKeyboardParams
- type LogDownloadResponse
- type MappingResponse
- type MediaControlParams
- type MediaHistoryParams
- type MediaHistoryResponse
- type MediaHistoryResponseEntry
- type MediaHistoryTopEntry
- type MediaHistoryTopParams
- type MediaHistoryTopResponse
- type MediaIndexParams
- type MediaLookupMatch
- type MediaLookupParams
- type MediaLookupResponse
- type MediaResponse
- type MediaStartedParams
- type MediaStoppedParams
- type NewClientParams
- type Notification
- type NotificationObject
- type PaginationInfo
- type PairedClient
- type PlaytimeLimitReachedParams
- type PlaytimeLimitWarningParams
- type PlaytimeLimitsResponse
- type PlaytimeStatusResponse
- type RPCID
- func (id *RPCID) Equal(other RPCID) bool
- func (id *RPCID) IsAbsent() bool
- func (id *RPCID) IsAbsentOrNull() bool
- func (id *RPCID) IsNull() bool
- func (id *RPCID) Key() string
- func (id RPCID) MarshalJSON() ([]byte, error)
- func (id *RPCID) String() string
- func (id *RPCID) UnmarshalJSON(data []byte) error
- type ReaderConnection
- type ReaderInfo
- type ReaderResponse
- type ReaderWriteCancelParams
- type ReaderWriteParams
- type ReadersResponse
- type RequestObject
- type ResponseErrorObject
- type ResponseObject
- type ResponseWithCallback
- type RunParams
- type RunScriptParams
- type ScreenshotResponse
- type SearchParams
- type SearchResultMedia
- type SearchResults
- type SettingsAuthClaimParams
- type SettingsAuthClaimResponse
- type SettingsResponse
- type System
- type SystemsResponse
- type TagsResponse
- type TokenResponse
- type TokensResponse
- type UpdateActiveMediaParams
- type UpdateApplyResponse
- type UpdateCheckResponse
- type UpdateMappingParams
- type UpdatePlaytimeLimitsParams
- type UpdateSettingsParams
- type VersionResponse
Constants ¶
const ( NotificationReadersConnected = "readers.added" NotificationReadersDisconnected = "readers.removed" NotificationRunning = "running" NotificationTokensAdded = "tokens.added" NotificationTokensRemoved = "tokens.removed" NotificationStopped = "media.stopped" NotificationStarted = "media.started" NotificationMediaIndexing = "media.indexing" // TODO: rename to generating NotificationTokensStaged = "tokens.staged" NotificationTokensStagedReady = "tokens.staged.ready" //nolint:gosec // not a credential NotificationPlaytimeLimitReached = "playtime.limit.reached" NotificationPlaytimeLimitWarning = "playtime.limit.warning" NotificationInboxAdded = "inbox.added" NotificationClientsPaired = "clients.paired" )
const ( PlaytimeLimitReasonSession = "session" PlaytimeLimitReasonDaily = "daily" )
const ( MethodLaunch = "launch" // DEPRECATED MethodRun = "run" MethodConfirm = "confirm" MethodRunScript = "run.script" MethodStop = "stop" MethodTokens = "tokens" MethodMedia = "media" MethodMediaGenerate = "media.generate" MethodMediaGenerateCancel = "media.generate.cancel" MethodMediaGenerateResume = "media.generate.resume" MethodMediaIndex = "media.index" // DEPRECATED MethodMediaSearch = "media.search" MethodMediaTags = "media.tags" MethodMediaActive = "media.active" MethodMediaHistory = "media.history" MethodMediaHistoryTop = "media.history.top" MethodMediaLookup = "media.lookup" MethodMediaBrowse = "media.browse" MethodMediaControl = "media.control" MethodMediaActiveUpdate = "media.active.update" MethodSettings = "settings" MethodSettingsUpdate = "settings.update" MethodSettingsReload = "settings.reload" MethodSettingsLogsDownload = "settings.logs.download" MethodPlaytimeLimits = "settings.playtime.limits" MethodPlaytimeLimitsUpdate = "settings.playtime.limits.update" MethodPlaytime = "playtime" MethodClients = "clients" MethodClientsDelete = "clients.delete" MethodClientsPairStart = "clients.pair.start" MethodClientsPairCancel = "clients.pair.cancel" MethodSystems = "systems" MethodLaunchersRefresh = "launchers.refresh" MethodHistory = "tokens.history" MethodMappings = "mappings" MethodMappingsNew = "mappings.new" MethodMappingsDelete = "mappings.delete" MethodMappingsUpdate = "mappings.update" MethodMappingsReload = "mappings.reload" MethodReaders = "readers" MethodReadersWrite = "readers.write" MethodReadersWriteCancel = "readers.write.cancel" MethodVersion = "version" MethodHealthCheck = "health" MethodInbox = "inbox" MethodInboxDelete = "inbox.delete" MethodInboxClear = "inbox.clear" MethodSettingsAuthClaim = "settings.auth.claim" MethodUpdateCheck = "update.check" MethodUpdateApply = "update.apply" MethodInputKeyboard = "input.keyboard" MethodInputGamepad = "input.gamepad" MethodScreenshot = "screenshot" )
Variables ¶
var ErrInvalidRPCID = errors.New("JSON-RPC ID cannot be an object or array")
ErrInvalidRPCID is returned when an ID is an object or array.
var NullRPCID = RPCID{RawMessage: []byte("null")}
NullRPCID represents a null JSON-RPC ID.
Functions ¶
func ClientErrf ¶ added in v2.11.0
ClientErrf creates a new formatted ClientError.
Types ¶
type ActiveMedia ¶
type ActiveMedia struct {
Started time.Time `json:"started"`
LauncherID string `json:"launcherId"`
SystemID string `json:"systemId"`
SystemName string `json:"systemName"`
Path string `json:"mediaPath"`
Name string `json:"mediaName"`
LauncherControls []string `json:"launcherControls,omitempty"`
}
func NewActiveMedia ¶ added in v2.7.0
func NewActiveMedia(systemID, systemName, path, name, launcherID string) *ActiveMedia
NewActiveMedia creates a new ActiveMedia with the current timestamp.
func (*ActiveMedia) Equal ¶
func (a *ActiveMedia) Equal(with *ActiveMedia) bool
type ActiveMediaResponse ¶ added in v2.9.0
type ActiveMediaResponse struct {
ZapScript string `json:"zapScript"`
ActiveMedia
}
ActiveMediaResponse is the API response type for active media, including ZapScript.
type AddMappingParams ¶
type AddMappingParams struct {
Label string `json:"label" validate:"max=255"`
Type string `json:"type" validate:"required,oneof=id value data uid text"`
Match string `json:"match" validate:"required,oneof=exact partial regex"`
Pattern string `json:"pattern" validate:"required"`
Override string `json:"override"`
Enabled bool `json:"enabled"`
}
type AllMappingsResponse ¶
type AllMappingsResponse struct {
Mappings []MappingResponse `json:"mappings"`
}
type BrowseEntry ¶ added in v2.10.0
type BrowseEntry struct {
SystemID *string `json:"systemId,omitempty"`
RelPath *string `json:"relativePath,omitempty"`
ZapScript *string `json:"zapScript,omitempty"`
FileCount *int `json:"fileCount,omitempty"`
Group *string `json:"group,omitempty"`
Name string `json:"name"`
Path string `json:"path"`
Type string `json:"type"`
Tags []database.TagInfo `json:"tags,omitempty"`
}
type BrowseParams ¶ added in v2.10.0
type BrowseParams struct {
Path *string `json:"path,omitempty"`
MaxResults *int `json:"maxResults,omitempty" validate:"omitempty,gt=0,max=1000"`
Cursor *string `json:"cursor,omitempty"`
Letter *string `json:"letter,omitempty" validate:"omitempty,letter"`
Sort *string `json:"sort,omitempty" validate:"omitempty,oneof=name-asc name-desc filename-asc filename-desc"`
}
type BrowseResults ¶ added in v2.10.0
type BrowseResults struct {
Pagination *PaginationInfo `json:"pagination,omitempty"`
Path string `json:"path"`
Entries []BrowseEntry `json:"entries"`
TotalFiles int `json:"totalFiles"`
}
type ClientError ¶ added in v2.11.0
type ClientError struct {
Err error
}
ClientError wraps an error to indicate it is an expected client-facing error (bad input, validation failure, expected operational state) rather than an internal server error. The API server uses this to log at Warn level instead of Error, keeping expected failures out of Sentry.
func (*ClientError) Error ¶ added in v2.11.0
func (e *ClientError) Error() string
func (*ClientError) Unwrap ¶ added in v2.11.0
func (e *ClientError) Unwrap() error
type ClientResponse ¶
type ClientsDeleteParams ¶ added in v2.11.0
type ClientsDeleteParams struct {
ClientID string `json:"clientId"`
}
ClientsDeleteParams is the parameters object for the clients.delete RPC method.
type ClientsPairStartResponse ¶ added in v2.11.0
ClientsPairStartResponse is the response for the clients.pair.start RPC method.
type ClientsPairedNotification ¶ added in v2.11.0
type ClientsPairedNotification struct {
ClientID string `json:"clientId"`
ClientName string `json:"clientName"`
}
ClientsPairedNotification is the payload for the clients.paired notification, broadcast when a client successfully completes the PAKE pairing flow.
type ClientsResponse ¶ added in v2.11.0
type ClientsResponse struct {
Clients []PairedClient `json:"clients"`
}
ClientsResponse is the response for the clients RPC method.
type DeleteClientParams ¶
type DeleteClientParams struct {
ID string `json:"id" validate:"required,min=1"`
}
type DeleteInboxParams ¶ added in v2.8.0
type DeleteInboxParams struct {
ID int64 `json:"id" validate:"gt=0"`
}
type DeleteMappingParams ¶
type DeleteMappingParams struct {
ID int `json:"id" validate:"gt=0"`
}
type ErrorObject ¶
type HealthCheckResponse ¶ added in v2.7.1
type HealthCheckResponse struct {
Status string `json:"status"`
}
type HistoryResponse ¶
type HistoryResponse struct {
Entries []HistoryResponseEntry `json:"entries"`
}
type HistoryResponseEntry ¶
type InboxMessage ¶ added in v2.8.0
type InboxResponse ¶ added in v2.8.0
type InboxResponse struct {
Messages []InboxMessage `json:"messages"`
}
type IndexingStatusResponse ¶
type IndexingStatusResponse struct {
TotalSteps *int `json:"totalSteps,omitempty"`
CurrentStep *int `json:"currentStep,omitempty"`
CurrentStepDisplay *string `json:"currentStepDisplay,omitempty"`
TotalFiles *int `json:"totalFiles,omitempty"`
TotalMedia *int `json:"totalMedia,omitempty"`
Exists bool `json:"exists"`
Indexing bool `json:"indexing"`
Optimizing bool `json:"optimizing"`
Paused bool `json:"paused"`
}
type InputGamepadParams ¶ added in v2.10.0
type InputGamepadParams struct {
Buttons string `json:"buttons" validate:"required,min=1"`
}
type InputKeyboardParams ¶ added in v2.10.0
type InputKeyboardParams struct {
Keys string `json:"keys" validate:"required,min=1"`
}
type LogDownloadResponse ¶
type MappingResponse ¶
type MediaControlParams ¶ added in v2.10.0
type MediaHistoryParams ¶ added in v2.10.0
type MediaHistoryResponse ¶ added in v2.10.0
type MediaHistoryResponse struct {
Pagination *PaginationInfo `json:"pagination,omitempty"`
Entries []MediaHistoryResponseEntry `json:"entries"`
}
type MediaHistoryResponseEntry ¶ added in v2.10.0
type MediaHistoryResponseEntry struct {
EndedAt *string `json:"endedAt,omitempty"`
SystemID string `json:"systemId"`
SystemName string `json:"systemName"`
MediaName string `json:"mediaName"`
MediaPath string `json:"mediaPath"`
LauncherID string `json:"launcherId"`
StartedAt string `json:"startedAt"`
PlayTime int `json:"playTime"`
}
type MediaHistoryTopEntry ¶ added in v2.10.0
type MediaHistoryTopEntry struct {
SystemID string `json:"systemId"`
SystemName string `json:"systemName"`
MediaName string `json:"mediaName"`
MediaPath string `json:"mediaPath"`
LastPlayedAt string `json:"lastPlayedAt"`
TotalPlayTime int `json:"totalPlayTime"`
SessionCount int `json:"sessionCount"`
}
type MediaHistoryTopParams ¶ added in v2.10.0
type MediaHistoryTopResponse ¶ added in v2.10.0
type MediaHistoryTopResponse struct {
Entries []MediaHistoryTopEntry `json:"entries"`
}
type MediaIndexParams ¶
type MediaLookupMatch ¶ added in v2.10.0
type MediaLookupParams ¶ added in v2.10.0
type MediaLookupResponse ¶ added in v2.10.0
type MediaLookupResponse struct {
Match *MediaLookupMatch `json:"match"`
}
type MediaResponse ¶
type MediaResponse struct {
Database IndexingStatusResponse `json:"database"`
Active []ActiveMediaResponse `json:"active"`
}
type MediaStartedParams ¶
type MediaStoppedParams ¶ added in v2.10.0
type NewClientParams ¶
type NewClientParams struct {
Name string `json:"name" validate:"required,min=1,max=255"`
}
type Notification ¶
type Notification struct {
Method string `json:"method"`
Params json.RawMessage `json:"params"`
}
type NotificationObject ¶ added in v2.9.0
type NotificationObject struct {
JSONRPC string `json:"jsonrpc"`
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
}
type PaginationInfo ¶ added in v2.7.0
type PairedClient ¶ added in v2.11.0
type PairedClient struct {
ClientID string `json:"clientId"`
ClientName string `json:"clientName"`
CreatedAt int64 `json:"createdAt"`
LastSeenAt int64 `json:"lastSeenAt"`
}
PairedClient represents a client paired via the API encryption flow. PairingKey and AuthToken are intentionally omitted from the public API surface — only the metadata identifying the client is exposed.
type PlaytimeLimitReachedParams ¶ added in v2.7.0
type PlaytimeLimitReachedParams struct {
Reason string `json:"reason"`
}
type PlaytimeLimitWarningParams ¶ added in v2.7.0
type PlaytimeLimitsResponse ¶ added in v2.7.0
type PlaytimeStatusResponse ¶ added in v2.7.0
type PlaytimeStatusResponse struct {
SessionStarted *string `json:"sessionStarted,omitempty"`
SessionDuration *string `json:"sessionDuration,omitempty"`
SessionCumulativeTime *string `json:"sessionCumulativeTime,omitempty"`
SessionRemaining *string `json:"sessionRemaining,omitempty"`
CooldownRemaining *string `json:"cooldownRemaining,omitempty"`
DailyUsageToday *string `json:"dailyUsageToday,omitempty"`
DailyRemaining *string `json:"dailyRemaining,omitempty"`
State string `json:"state"`
SessionActive bool `json:"sessionActive"`
LimitsEnabled bool `json:"limitsEnabled"`
}
type RPCID ¶ added in v2.8.0
type RPCID struct {
json.RawMessage
}
RPCID represents a JSON-RPC 2.0 request/response ID. Per spec, ID can be a String, Number, or Null value. We use json.RawMessage to preserve the exact JSON representation, ensuring IDs are echoed back exactly as received.
func NewNumberID ¶ added in v2.8.0
NewNumberID creates an RPCID from an integer value.
func NewStringID ¶ added in v2.8.0
NewStringID creates an RPCID from a string value.
func (*RPCID) IsAbsent ¶ added in v2.8.0
IsAbsent returns true if the ID field was not present in the JSON. This indicates a notification in JSON-RPC 2.0.
func (*RPCID) IsAbsentOrNull ¶ added in v2.8.0
IsAbsentOrNull returns true if the ID is either absent or explicitly null. For JSON-RPC 2.0, absent means notification (no response), while null means request with null ID (must respond). Use IsAbsent() to distinguish.
func (*RPCID) IsNull ¶ added in v2.8.0
IsNull returns true if the ID is explicitly JSON null. Note: This returns false for absent IDs - use IsAbsent() for that.
func (*RPCID) Key ¶ added in v2.8.0
Key returns a string suitable for use as a map key. This is the raw JSON representation of the ID.
func (RPCID) MarshalJSON ¶ added in v2.8.0
MarshalJSON returns the raw JSON bytes of the ID.
func (*RPCID) String ¶ added in v2.8.0
String returns the string representation for logging/debugging. Note: If the ID is a JSON string "foo", this returns "foo" (with quotes).
func (*RPCID) UnmarshalJSON ¶ added in v2.8.0
UnmarshalJSON enforces JSON-RPC 2.0 spec compliance by rejecting objects and arrays as ID values at parse time.
type ReaderConnection ¶ added in v2.9.0
type ReaderConnection struct {
Enabled *bool `json:"enabled,omitempty"`
Driver string `json:"driver" validate:"required,min=1"`
Path string `json:"path"`
IDSource string `json:"idSource,omitempty"`
}
func (ReaderConnection) IsEnabled ¶ added in v2.11.0
func (r ReaderConnection) IsEnabled() bool
IsEnabled returns whether this connection is enabled. nil (omitted) and true both mean enabled; only explicit false disables.
type ReaderInfo ¶
type ReaderResponse ¶
type ReaderWriteCancelParams ¶ added in v2.9.0
type ReaderWriteCancelParams struct {
ReaderID *string `json:"readerId,omitempty"`
}
type ReaderWriteParams ¶
type ReadersResponse ¶
type ReadersResponse struct {
Readers []ReaderInfo `json:"readers"`
}
type RequestObject ¶
type RequestObject struct {
JSONRPC string `json:"jsonrpc"`
ID RPCID `json:"id,omitempty"`
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
}
type ResponseErrorObject ¶
type ResponseErrorObject struct {
Error *ErrorObject `json:"error"`
JSONRPC string `json:"jsonrpc"`
ID RPCID `json:"id"`
}
ResponseErrorObject exists for sending errors, so we can omit result from the response, but so nil responses are still returned when using the main ResponseObject.
type ResponseObject ¶
type ResponseObject struct {
Result any `json:"result"`
Error *ErrorObject `json:"error,omitempty"`
JSONRPC string `json:"jsonrpc"`
ID RPCID `json:"id"`
}
type ResponseWithCallback ¶ added in v2.10.0
type ResponseWithCallback struct {
Result any
AfterWrite func()
}
ResponseWithCallback wraps a method result with a function that should be called after the response has been written to the client. This allows handlers to defer side effects (like triggering a restart) until the client has received the response, without relying on arbitrary sleep timers.
type RunScriptParams ¶
type RunScriptParams struct {
Name *string `json:"name"`
Cmds []zapscript.ZapScriptCmd `json:"cmds"`
ZapScript int `json:"zapscript"`
Unsafe bool `json:"unsafe"`
}
type ScreenshotResponse ¶ added in v2.10.0
type SearchParams ¶
type SearchParams struct {
Systems *[]string `json:"systems" validate:"omitempty,dive,min=1"`
FuzzySystem *bool `json:"fuzzySystem,omitempty"`
MaxResults *int `json:"maxResults" validate:"omitempty,gt=0,max=1000"`
Cursor *string `json:"cursor,omitempty"`
Tags *[]string `json:"tags,omitempty" validate:"omitempty,dive,min=1"`
Letter *string `json:"letter,omitempty" validate:"omitempty,letter"`
Query *string `json:"query"`
}
type SearchResultMedia ¶
type SearchResults ¶
type SearchResults struct {
Pagination *PaginationInfo `json:"pagination,omitempty"`
Results []SearchResultMedia `json:"results"`
Total int `json:"total"`
}
type SettingsAuthClaimParams ¶ added in v2.10.0
type SettingsAuthClaimResponse ¶ added in v2.10.0
type SettingsAuthClaimResponse struct {
Domains []string `json:"domains"`
}
type SettingsResponse ¶
type SettingsResponse struct {
UpdateChannel string `json:"updateChannel"`
ReadersScanMode string `json:"readersScanMode"`
ReadersScanIgnoreSystem []string `json:"readersScanIgnoreSystems"`
ReadersConnect []ReaderConnection `json:"readersConnect"`
ReadersScanExitDelay float32 `json:"readersScanExitDelay"`
LaunchGuardTimeout float32 `json:"launchGuardTimeout"`
LaunchGuardDelay float32 `json:"launchGuardDelay"`
AudioVolume int `json:"audioVolume"`
RunZapScript bool `json:"runZapScript"`
DebugLogging bool `json:"debugLogging"`
AudioScanFeedback bool `json:"audioScanFeedback"`
ReadersAutoDetect bool `json:"readersAutoDetect"`
ErrorReporting bool `json:"errorReporting"`
LaunchGuardEnabled bool `json:"launchGuardEnabled"`
LaunchGuardRequireConfirm bool `json:"launchGuardRequireConfirm"`
}
type SystemsResponse ¶
type SystemsResponse struct {
Systems []System `json:"systems"`
}
type TagsResponse ¶ added in v2.7.0
type TokenResponse ¶
type TokensResponse ¶
type TokensResponse struct {
Last *TokenResponse `json:"last,omitempty"`
Active []TokenResponse `json:"active"`
}
type UpdateActiveMediaParams ¶
type UpdateApplyResponse ¶ added in v2.10.0
type UpdateCheckResponse ¶ added in v2.10.0
type UpdateMappingParams ¶
type UpdateMappingParams struct {
Label *string `json:"label" validate:"omitempty,max=255"`
Enabled *bool `json:"enabled"`
Type *string `json:"type" validate:"omitempty,oneof=id value data uid text"`
Match *string `json:"match" validate:"omitempty,oneof=exact partial regex"`
Pattern *string `json:"pattern" validate:"omitempty,min=1"`
Override *string `json:"override"`
ID int `json:"id" validate:"gt=0"`
}
type UpdatePlaytimeLimitsParams ¶ added in v2.7.0
type UpdatePlaytimeLimitsParams struct {
Enabled *bool `json:"enabled"`
Daily *string `json:"daily" validate:"omitempty,duration"`
Session *string `json:"session" validate:"omitempty,duration"`
SessionReset *string `json:"sessionReset" validate:"omitempty,duration"`
Warnings *[]string `json:"warnings" validate:"omitempty,dive,duration"`
Retention *int `json:"retention" validate:"omitempty,gte=0"`
}
type UpdateSettingsParams ¶
type UpdateSettingsParams struct {
RunZapScript *bool `json:"runZapScript"`
DebugLogging *bool `json:"debugLogging"`
AudioScanFeedback *bool `json:"audioScanFeedback"`
ReadersAutoDetect *bool `json:"readersAutoDetect"`
ErrorReporting *bool `json:"errorReporting"`
UpdateChannel *string `json:"updateChannel" validate:"omitempty,oneof=stable beta"`
ReadersScanMode *string `json:"readersScanMode" validate:"omitempty,oneof=tap hold"`
ReadersScanExitDelay *float32 `json:"readersScanExitDelay" validate:"omitempty,gte=0"`
ReadersScanIgnoreSystem *[]string `json:"readersScanIgnoreSystems" validate:"omitempty,dive,system"`
ReadersConnect *[]ReaderConnection `json:"readersConnect,omitempty"`
AudioVolume *int `json:"audioVolume" validate:"omitempty,gte=0,lte=200"`
LaunchGuardEnabled *bool `json:"launchGuardEnabled"`
LaunchGuardTimeout *float32 `json:"launchGuardTimeout" validate:"omitempty,gte=-1"`
LaunchGuardDelay *float32 `json:"launchGuardDelay" validate:"omitempty,gte=0"`
LaunchGuardRequireConfirm *bool `json:"launchGuardRequireConfirm"`
}