Class UiApiInvoker
java.lang.Object
com.kingsrook.qqq.middleware.javalin.specs.invoke.UiApiInvoker
Invokes UI API (`/qqq/v1`) operations from inside the server, with a given
user's session, with exactly the semantics of an HTTP client: the call is
a loopback HTTP request to the running server, so it passes through the
same session setup, permission checks, filters, logging and error mapping
as a request from the UI. Used by the AI assistant, which must be held to
the user's own security boundaries. See docs/UI-API-EXTENSIONS.md.
- Only operations described by an endpoint spec (core or extension) can be
invoked; anything else is refused before a request is made.
- The caller's credentials are required and are forwarded exactly as the
caller's request carried them (session cookies, Authorization, x-api-key),
so the call authenticates as the same user with any authentication module;
there is no service session and no elevation.
- Nested invocation on one thread is limited to MAX_DEPTH.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionUiApiInvoker(Supplier<String> baseUrlSupplier, AbstractMiddlewareVersion middlewareVersion) Constructor -
Method Summary
Modifier and TypeMethodDescriptionfindOperation(HttpMethod method, String pathTemplate) Find the operation for a method and path template.static UiApiInvokerforBaseUrl(String baseUrl, AbstractMiddlewareVersion middlewareVersion) An invoker for a server at a given base URL (scheme, host and port).static UiApiInvokerforServer(QApplicationJavalinServer server) An invoker for a running server's first (current) UI API version, calling it on the loopback interface.static UiApiInvokerforServer(QApplicationJavalinServer server, String clientChannel) An invoker for a running server, labelling every call with a client channel (e.g. assistant) - fixed here, server side: a request can only add detail (assistant/), never change or remove the channel. Getter for clientChannelinvoke(UiApiRequest request) Invoke an operation with the request's session.invokeForStream(UiApiRequest request) Invoke with a streamed body.Every operation that can be invoked, from the same specs that generate the OpenAPI document.withClientChannel(String clientChannel) Set the client channel name every call is labelled with (default api).
-
Field Details
-
MAX_DEPTH
public static final int MAX_DEPTH- See Also:
-
INVOKED_BY_HEADER
- See Also:
-
TIMEZONE_HEADER
- See Also:
-
CLIENT_CHANNEL_HEADER
- See Also:
-
-
Constructor Details
-
UiApiInvoker
Constructor- Parameters:
baseUrlSupplier- scheme, host and port of the server, e.g. http://127.0.0.1:8000middlewareVersion- the UI API version whose operations may be invoked
-
-
Method Details
-
forServer
An invoker for a running server's first (current) UI API version, calling it on the loopback interface. -
forServer
An invoker for a running server, labelling every call with a client channel (e.g. assistant) - fixed here, server side: a request can only add detail (assistant/), never change or remove the channel. -
withClientChannel
Set the client channel name every call is labelled with (default api). -
getClientChannel
Getter for clientChannel -
forBaseUrl
An invoker for a server at a given base URL (scheme, host and port). -
listOperations
Every operation that can be invoked, from the same specs that generate the OpenAPI document. -
findOperation
Find the operation for a method and path template. -
invoke
Invoke an operation with the request's session.- Throws:
QException
-
invokeForStream
Invoke with a streamed body. The caller must close the returned response. Invocation depth is released on return, independently of stream lifetime.- Throws:
QException
-