feat: complete catalog fleet management workflow
This commit is contained in:
@@ -66,6 +66,7 @@ const secretsSchema = z.object({
|
||||
values: z.partialRecord(z.enum(secretNames), z.string().min(1).max(65_536)).refine((values) => Object.keys(values).length > 0),
|
||||
}).strict();
|
||||
const versionQuery = z.object({ version: z.coerce.number().int().positive() });
|
||||
const metricsQuery = z.object({ databaseId: z.uuid().optional() }).strict();
|
||||
|
||||
function safeError(reply: FastifyReply, error: unknown) {
|
||||
if (error instanceof CatalogUnavailableError) {
|
||||
@@ -114,6 +115,21 @@ export function catalogDatabaseRoutes(
|
||||
return { available: await deps.repository.available() };
|
||||
});
|
||||
|
||||
app.get("/catalog/metrics", async (request, reply) => {
|
||||
if (!manage(request, reply)) return reply;
|
||||
try {
|
||||
const { databaseId } = metricsQuery.parse(request.query);
|
||||
const metrics = await deps.repository.getCatalogMetrics(databaseId);
|
||||
if (!metrics) {
|
||||
return reply.code(404).send({
|
||||
code: "database_not_found",
|
||||
message: "Database configuration was not found.",
|
||||
});
|
||||
}
|
||||
return metrics;
|
||||
} catch (error) { return safeError(reply, error); }
|
||||
});
|
||||
|
||||
app.get("/catalog/databases", async (request, reply) => {
|
||||
if (!manage(request, reply)) return reply;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user