sonatype-mcp
Version:
Model Context Protocol server for Sonatype Nexus Repository Manager
102 lines (101 loc) • 2.71 kB
JavaScript
/**
* Administrative service for Nexus system operations
*/
export class AdminService {
nexusClient;
constructor(nexusClient) {
this.nexusClient = nexusClient;
}
/**
* Get system status and health checks
*/
async getSystemStatus() {
const status = await this.nexusClient.get('/service/rest/v1/status/check');
return status;
}
/**
* Get system information
*/
async getSystemInfo() {
const info = await this.nexusClient.get('/service/rest/v1/status');
return info;
}
/**
* List blob stores
*/
async listBlobStores() {
const blobStores = await this.nexusClient.get('/service/rest/v1/blobstores');
return blobStores;
}
/**
* Get blob store details
*/
async getBlobStore(name) {
const blobStore = await this.nexusClient.get(`/service/rest/v1/blobstores/${encodeURIComponent(name)}`);
return blobStore;
}
/**
* Get system metrics
*/
async getMetrics() {
const metrics = await this.nexusClient.get('/service/rest/v1/metrics');
return metrics;
}
/**
* List scheduled tasks
*/
async listTasks() {
const tasks = await this.nexusClient.get('/service/rest/v1/tasks');
return tasks;
}
/**
* Get task details
*/
async getTask(id) {
const task = await this.nexusClient.get(`/service/rest/v1/tasks/${encodeURIComponent(id)}`);
return task;
}
/**
* Run a task
*/
async runTask(id) {
await this.nexusClient.post(`/service/rest/v1/tasks/${encodeURIComponent(id)}/run`);
}
/**
* Stop a task
*/
async stopTask(id) {
await this.nexusClient.post(`/service/rest/v1/tasks/${encodeURIComponent(id)}/stop`);
}
/**
* Get read-only status
*/
async getReadOnlyStatus() {
const status = await this.nexusClient.get('/service/rest/v1/read-only');
return status;
}
/**
* Set read-only mode
*/
async setReadOnly(enabled) {
if (enabled) {
await this.nexusClient.post('/service/rest/v1/read-only/freeze');
}
else {
await this.nexusClient.post('/service/rest/v1/read-only/release');
}
}
/**
* Get system configuration
*/
async getSystemConfiguration() {
const config = await this.nexusClient.get('/service/rest/v1/system-configuration');
return config;
}
/**
* Update system configuration
*/
async updateSystemConfiguration(config) {
await this.nexusClient.put('/service/rest/v1/system-configuration', config);
}
}