- RMM Overshell (migration 077): admin page, dispatch UI, executor/worker, target resolver, script registry (AD/DHCP/DNS/event-log/services/software/network/loglift) - LogLift evidence pipeline (migration 078): upload webhook, B2 storage client, receiver/matcher, EventLogCollector PowerShell script - IT Glue audit + write-back (migrations 075, 076): asset-audit runner, ticket xrefs, applications/configurations browse pages + apply/revert/audit endpoints - Link-aware analyzer bundles (migration 073) + provider toggle (migration 074): link-discovery service, OpenRouter LLM provider, related-tickets/itglue-suggestion panels, analyze-bundle endpoint - Endpoint data model + device-link reconciliation (migrations 079, 080): conflicts admin page, reconciler service, resolve endpoints - Dashboard overhaul: integration-health service + alerts, overview/health endpoints - Permissions: add itglue + rmm scopes; middleware: public /api/rmm/loglift route Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
61 lines
2 KiB
TypeScript
61 lines
2 KiB
TypeScript
/**
|
|
* GET /api/admin/rmm/settings
|
|
* Returns the cached Overshell config + recent execution counts.
|
|
*
|
|
* PATCH /api/admin/rmm/settings
|
|
* Body: { overshellVariableName: string }
|
|
* Updates the variable name the Overshell component expects.
|
|
*/
|
|
|
|
import { NextRequest, NextResponse } from 'next/server';
|
|
import { z } from 'zod';
|
|
import { requirePermission } from '@/lib/auth-utils';
|
|
import {
|
|
getRmmSettings,
|
|
updateOvershellVariableName,
|
|
} from '@/lib/services/rmm/settings';
|
|
import postgresClient from '@/lib/services/postgres-client';
|
|
|
|
const PatchBody = z.object({
|
|
overshellVariableName: z.string().min(1).max(100),
|
|
});
|
|
|
|
interface CountsRow {
|
|
total: string;
|
|
running: string;
|
|
failed_24h: string;
|
|
}
|
|
|
|
export async function GET(_request: NextRequest) {
|
|
const { error } = await requirePermission('admin', 'access');
|
|
if (error) return error;
|
|
const settings = await getRmmSettings();
|
|
const counts = await postgresClient.query<CountsRow>(
|
|
`SELECT
|
|
(SELECT COUNT(*)::text FROM rmm_executions) AS total,
|
|
(SELECT COUNT(*)::text FROM rmm_executions WHERE status = 'running') AS running,
|
|
(SELECT COUNT(*)::text FROM rmm_executions
|
|
WHERE status = 'failed' AND queued_at >= NOW() - INTERVAL '24 hours') AS failed_24h`
|
|
);
|
|
return NextResponse.json({
|
|
settings,
|
|
counts: counts.rows[0] ?? { total: '0', running: '0', failed_24h: '0' },
|
|
});
|
|
}
|
|
|
|
export async function PATCH(request: NextRequest) {
|
|
const { error } = await requirePermission('admin', 'access');
|
|
if (error) return error;
|
|
const body = await request.json().catch(() => ({}));
|
|
const parsed = PatchBody.safeParse(body);
|
|
if (!parsed.success) {
|
|
return NextResponse.json(
|
|
{ error: 'Invalid body', details: parsed.error.issues },
|
|
{ status: 400 }
|
|
);
|
|
}
|
|
const settings = await updateOvershellVariableName(
|
|
parsed.data.overshellVariableName
|
|
);
|
|
return NextResponse.json({ settings });
|
|
}
|