UNPKG

@brianveltman/sonatype-mcp

Version:

Model Context Protocol server for Sonatype Nexus Repository Manager

96 lines 3.32 kB
export class AdminService { nexusClient; constructor(nexusClient) { this.nexusClient = nexusClient; } async getSystemStatus() { const status = await this.nexusClient.get('/service/rest/v1/status/check'); return status; } async getSystemInfo() { const info = await this.nexusClient.get('/service/rest/v1/status'); return info; } async listBlobStores() { const blobStores = await this.nexusClient.get('/service/rest/v1/blobstores'); return blobStores; } async getBlobStore(name) { const blobStore = await this.nexusClient.get(`/service/rest/v1/blobstores/${encodeURIComponent(name)}`); return blobStore; } async listTasks() { const tasks = await this.nexusClient.get('/service/rest/v1/tasks'); return tasks; } async getTask(id) { const task = await this.nexusClient.get(`/service/rest/v1/tasks/${encodeURIComponent(id)}`); return task; } async runTask(id) { await this.nexusClient.post(`/service/rest/v1/tasks/${encodeURIComponent(id)}/run`); } async stopTask(id) { await this.nexusClient.post(`/service/rest/v1/tasks/${encodeURIComponent(id)}/stop`); } async getReadOnlyStatus() { const status = await this.nexusClient.get('/service/rest/v1/read-only'); return status; } 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'); } } async getSystemConfiguration() { const config = await this.nexusClient.get('/service/rest/v1/system-configuration'); return config; } async updateSystemConfiguration(config) { await this.nexusClient.put('/service/rest/v1/system-configuration', config); } async getServiceMetricsData() { try { const metricsData = await this.nexusClient.get('/service/metrics/data'); return metricsData; } catch (error) { if (error.response?.status === 404) { try { const metricsData = await this.nexusClient.get('/service/rest/v1/metrics/data'); return metricsData; } catch (fallbackError) { throw error; } } throw error; } } async generateSupportZip(config = {}) { const defaultConfig = { systemInformation: true, threadDump: true, metrics: true, configuration: true, security: false, logFiles: true, taskLogFiles: false, auditLogFiles: false, jmx: false }; const finalConfig = { ...defaultConfig, ...config }; const response = await this.nexusClient.post('/service/rest/v1/support/supportzip', finalConfig, { responseType: 'arraybuffer', headers: { 'Accept': 'application/octet-stream', 'Content-Type': 'application/json' } }); return Buffer.from(response); } } //# sourceMappingURL=admin.js.map