Revert "Merge pull request 'clan-cli: Refactor the API to use the Flake object' (#3531) from Qubasa/clan-core:replace_machine_name_with_machine_obj into main"

This reverts commit 572ce8885f, reversing
changes made to 0bee027251.
This commit is contained in:
Jörg Thalheim
2025-05-07 15:24:57 +02:00
parent 572ce8885f
commit 444fc3f820
31 changed files with 136 additions and 168 deletions

View File

@@ -13,9 +13,9 @@ export async function get_inventory(client: QueryClient, base_path: string) {
queryKey: [base_path, "inventory"],
queryFn: () => {
console.log("Refreshing inventory");
return callApi("get_inventory", {
flake: { identifier: base_path },
}) as Promise<ApiEnvelope<Inventory>>;
return callApi("get_inventory", { base_path }) as Promise<
ApiEnvelope<Inventory>
>;
},
revalidateIfStale: true,
staleTime: 60 * 1000,

View File

@@ -6,7 +6,7 @@ export const instance_name = (machine_name: string) =>
export async function get_iwd_service(base_path: string, machine_name: string) {
const r = await callApi("get_inventory", {
flake: { identifier: base_path },
base_path,
});
if (r.status == "error") {
return null;

View File

@@ -43,7 +43,7 @@ export const tagsQuery = (uri: string | null) =>
if (!uri) return [];
const response = await callApi("get_inventory", {
flake: { identifier: uri },
base_path: uri,
});
if (response.status === "error") {
toast.error("Failed to fetch data");
@@ -64,7 +64,7 @@ export const machinesQuery = (uri: string | null) =>
if (!uri) return [];
const response = await callApi("get_inventory", {
flake: { identifier: uri },
base_path: uri,
});
if (response.status === "error") {
toast.error("Failed to fetch data");

View File

@@ -42,7 +42,7 @@ const EditClanForm = (props: EditClanFormProps) => {
(async () => {
await callApi("update_clan_meta", {
options: {
flake: { identifier: props.directory },
directory: props.directory,
meta: values,
},
});

View File

@@ -10,9 +10,7 @@ export function DiskView() {
const currUri = activeURI();
if (currUri) {
// Example of calling an API
const result = await callApi("get_inventory", {
flake: { identifier: currUri },
});
const result = await callApi("get_inventory", { base_path: currUri });
if (result.status === "error") throw new Error("Failed to fetch data");
return result.data;
}

View File

@@ -115,7 +115,7 @@ const InstallMachine = (props: InstallMachineProps) => {
if (shouldRunDisk) {
setProgressText("Setting up disk ... (1/5)");
const disk_response = await callApi("set_machine_disk_schema", {
flake: { identifier: curr_uri },
base_path: curr_uri,
machine_name: props.name,
placeholders: diskValues.placeholders,
schema_name: diskValues.schema,
@@ -415,9 +415,7 @@ const MachineForm = (props: MachineDetailsProps) => {
}
const machine_response = await callApi("set_machine", {
flake: {
identifier: curr_uri,
},
flake_url: curr_uri,
machine_name: props.initialData.machine.name || "My machine",
machine: {
...values.machine,
@@ -682,12 +680,8 @@ export const MachineDetails = () => {
const curr = activeURI();
if (curr) {
const result = await callApi("get_machine_details", {
machine: {
flake: {
identifier: curr,
},
name: params.id,
},
flake_url: curr,
machine_name: params.id,
});
if (result.status === "error") throw new Error("Failed to fetch data");
return result.data;

View File

@@ -37,9 +37,7 @@ export const DiskStep = (props: StepProps<DiskValues>) => {
queryKey: [props.dir, props.machine_id, "disk_schemas"],
queryFn: async () => {
const result = await callApi("get_disk_schemas", {
flake: {
identifier: props.dir,
},
base_path: props.dir,
machine_name: props.machine_id,
});
if (result.status === "error") throw new Error("Failed to fetch data");

View File

@@ -52,9 +52,7 @@ export const HWStep = (props: StepProps<HardwareValues>) => {
queryKey: [props.dir, props.machine_id, "hw_report"],
queryFn: async () => {
const result = await callApi("show_machine_hardware_config", {
flake: {
identifier: props.dir,
},
clan_dir: props.dir,
machine_name: props.machine_id,
});
if (result.status === "error") throw new Error("Failed to fetch data");

View File

@@ -39,9 +39,7 @@ export const MachineListView: Component = () => {
const uri = activeURI();
if (uri) {
const response = await callApi("list_machines", {
flake: {
identifier: uri,
},
flake_url: uri,
});
if (response.status === "error") {
toast.error("Failed to fetch data");