zinit client fixes

This commit is contained in:
Timur Gordon
2025-08-29 10:17:51 +02:00
parent 3d86ec7cf5
commit b0b1fbf2c2
2 changed files with 30 additions and 6 deletions

View File

@@ -1,7 +1,8 @@
module zinit
import json
import freeflowuniverse.herolib.schemas.jsonrpc
import freeflowuniverse.herolib.schemas.jsonrpcmodel
import freeflowuniverse.herolib.schemas.openrpc
// Helper function to get or create the RPC client
fn (mut c ZinitRPC) client_() !&jsonrpc.Client {
@@ -13,10 +14,11 @@ fn (mut c ZinitRPC) client_() !&jsonrpc.Client {
// Admin methods
// rpc_discover returns the OpenRPC specification for the API
pub fn (mut c ZinitRPC) rpc_discover() !jsonrpcmodel.OpenRPCSpec {
pub fn (mut c ZinitRPC) rpc_discover() !openrpc.OpenRPC {
mut client := c.client_()!
request := jsonrpc.new_request_generic('rpc.discover', []string{})
return client.send[[]string, jsonrpcmodel.OpenRPCSpec](request)!
request := jsonrpc.new_request('rpc.discover', '')
openrpc_str := client.send_str(request)!
return json.decode(openrpc.OpenRPC, openrpc_str)
}
// service_list lists all services managed by Zinit
@@ -98,9 +100,9 @@ pub fn (mut c ZinitRPC) service_create(name string, config ServiceConfig) !strin
content: config
}
println(params)
$dbg;
// $dbg;
request := jsonrpc.new_request_generic('service_create', params)
$dbg;
// $dbg;
return client.send[ServiceCreateParams, string](request)!
}