Add a UserInfo class which provides type annotations for each member.
This class easily converts to a dict or tuple, simplifying conversion
for usage in SQL statements.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
The HistoryDataField class can be instantiated by any
component. It can then be used to register additional fields
tracked in the job history.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Clear the API cache when closing to purge stale callbacks. In addition,
explicitly delte the server object after the eventloop stops.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Add a POST /server/jsonrpc endpoint that processes jsonrpc
requests from the body. This allows developers familiar with
the JSON-RPC API to use it in places where a websocket is not
desiriable.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Only log registration when verbose (debug) logging is enabled.
In addition, log endpoint removal.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Track authentication requirements in the API Definition. This
eliminates the need to look up the authentication component
to disable auth on an endpoint.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This change refactors the APIDefiniton into a dataclass, allowing
defs to be shared directly among HTTP and RPC requests. In
addition, all transports now share one instance of JSONRPC,
removing duplicate registration. API Defintiions are registered
with the RPC Dispatcher, and it validates the Transport type.
In addition tranports may perform their own validation prior
to request execution.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Refactor endpoint registration to reduce duplicated code.
Rename some APIDefinition attributes for clarity.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Emit a single event where the first argument contains
a "JobEvent" enumeration that describes the particular
event. This reduces the number of callbacks registered
by JobState consumers and allows them react to multiple
state changes in the same callback.
The individual events remain for compatibility, however
they are deprecated. Current modules should be updated
to use the "job_state:state_changed" event and new modules
must use this event.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
These flags replace strings as constants used to register and
identify Request Types (ie: GET, POST) and API Transport
Types.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Create a websocket endpoint that allows clients identified as
agents to register remote methods with Klipper.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
When a client repeatedly makes a request that results in an error
the log is spammed with tracebacks that don't provide significant
value. The method name, code, and error message should be
enough for basic troubleshooting.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>