feat: connect alpine logs and usage to admin api

This commit is contained in:
a.tolmachev
2026-03-30 01:49:32 +03:00
parent 40ef8d9cf8
commit e4d2f6adc9
7 changed files with 609 additions and 660 deletions
+32
View File
@@ -67,6 +67,19 @@
return request(path, { method: 'DELETE' });
}
function query(params) {
var search = new URLSearchParams();
Object.keys(params || {}).forEach(function(key) {
var value = params[key];
if (value === undefined || value === null || value === '') {
return;
}
search.set(key, value);
});
var encoded = search.toString();
return encoded ? ('?' + encoded) : '';
}
function postBytes(path, bytes, fileName) {
return request(path, {
method: 'POST',
@@ -143,5 +156,24 @@
deletePlatformApiKey: function(workspaceId, keyId) {
return del('/workspaces/' + encodeURIComponent(workspaceId) + '/platform-api-keys/' + encodeURIComponent(keyId));
},
listLogs: function(workspaceId, params) {
return get('/workspaces/' + encodeURIComponent(workspaceId) + '/logs' + query(params));
},
getLog: function(workspaceId, logId) {
return get('/workspaces/' + encodeURIComponent(workspaceId) + '/logs/' + encodeURIComponent(logId));
},
getUsageOverview: function(workspaceId, params) {
return get('/workspaces/' + encodeURIComponent(workspaceId) + '/usage' + query(params));
},
getOperationUsage: function(workspaceId, operationId, params) {
return get(
'/workspaces/' + encodeURIComponent(workspaceId) + '/usage/operations/' + encodeURIComponent(operationId) + query(params)
);
},
getAgentUsage: function(workspaceId, agentId, params) {
return get(
'/workspaces/' + encodeURIComponent(workspaceId) + '/usage/agents/' + encodeURIComponent(agentId) + query(params)
);
},
};
}());