fix: align all API mappings with live Core v2.3.3, close #4-#11
- Remove 72 phantom endpoints from types.ts (non-existent in live API) - Fix 11 naming drifts (ListSyncResources→ListResourceSyncs, RunStackPull→PullStack, etc.) - Add missing execute ops: pull_stack, deploy_stack_service (RunStackService), run_sync - Remove phantom resource types: execution, access_request, terminal, alert - Add komodo_copy tool (11 resource types) and komodo_rename tool (12 types) - Add 14 new list_detail types (swarm_*, config, extra_args, etc.) - Fix komodo-client.ts: fallback to KOMODO_INIT_ADMIN_USERNAME/PASSWORD env vars - Rewrite references/api.md to match actual OpenAPI v2.3.3 spec - Remove terminal from test script RESOURCE_DEFS (no longer valid resource type)
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import { z } from "zod";
|
||||
import { KomodoClient } from "../komodo-client.js";
|
||||
import { RENAME_REQUEST_MAP } from "../types.js";
|
||||
|
||||
const RenameableType = z.enum([
|
||||
"stack", "build", "server", "deployment", "procedure",
|
||||
"alerter", "action", "repo", "builder", "swarm", "tag", "user_group",
|
||||
]);
|
||||
|
||||
export const renameInputSchema = {
|
||||
resource_type: RenameableType.describe(
|
||||
"Resource type to rename (stack, build, server, deployment, procedure, alerter, action, repo, builder, swarm, tag, user_group)",
|
||||
),
|
||||
id: z.string().describe("Resource ID or name to rename"),
|
||||
name: z.string().describe("New name for the resource"),
|
||||
};
|
||||
|
||||
export async function handleRename(
|
||||
args: {
|
||||
resource_type: z.infer<typeof RenameableType>;
|
||||
id: string;
|
||||
name: string;
|
||||
},
|
||||
client: KomodoClient,
|
||||
): Promise<{ content: { type: "text"; text: string }[] }> {
|
||||
const { resource_type, id, name } = args;
|
||||
|
||||
const requestName = RENAME_REQUEST_MAP[resource_type];
|
||||
if (!requestName) {
|
||||
throw new Error(
|
||||
`No RENAME endpoint available for resource type: ${resource_type}`,
|
||||
);
|
||||
}
|
||||
|
||||
const params: Record<string, unknown> = { id, name };
|
||||
if (resource_type === "tag") {
|
||||
params.tag = id;
|
||||
delete params.id;
|
||||
}
|
||||
|
||||
const result = await client.rpc("write", requestName, params);
|
||||
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: JSON.stringify(result, null, 2),
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user