Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
operationId support
Browse files Browse the repository at this point in the history
  • Loading branch information
senia-psm committed Feb 21, 2024
1 parent 89526d6 commit ffd0ec4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
10 changes: 5 additions & 5 deletions src/clients/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl<C: golem_client::api::TemplateClient + Sync + Send> TemplateClient for Temp

let name = name.map(|n| n.0);

let templates: Vec<Template> = self.client.get(name.as_deref()).await?;
let templates: Vec<Template> = self.client.get_all_templates(name.as_deref()).await?;
let views = templates.iter().map(|c| c.into()).collect();
Ok(views)
}
Expand All @@ -205,7 +205,7 @@ impl<C: golem_client::api::TemplateClient + Sync + Send> TemplateClient for Temp
.await
.map_err(|e| GolemError(format!("Can't open template file: {e}")))?;

self.client.post(&name.0, file).await?
self.client.upload_template(&name.0, file).await?
}
PathBufOrStdin::Stdin => {
let mut bytes = Vec::new();
Expand All @@ -214,7 +214,7 @@ impl<C: golem_client::api::TemplateClient + Sync + Send> TemplateClient for Temp
.read_to_end(&mut bytes) // TODO: steaming request from stdin
.map_err(|e| GolemError(format!("Failed to read stdin: {e:?}")))?;

self.client.post(&name.0, bytes).await?
self.client.upload_template(&name.0, bytes).await?
}
};

Expand All @@ -234,7 +234,7 @@ impl<C: golem_client::api::TemplateClient + Sync + Send> TemplateClient for Temp
.await
.map_err(|e| GolemError(format!("Can't open template file: {e}")))?;

self.client.template_id_upload_put(&id.0, file).await?
self.client.update_template(&id.0, file).await?
}
PathBufOrStdin::Stdin => {
let mut bytes = Vec::new();
Expand All @@ -243,7 +243,7 @@ impl<C: golem_client::api::TemplateClient + Sync + Send> TemplateClient for Temp
.read_to_end(&mut bytes) // TODO: steaming request from stdin
.map_err(|e| GolemError(format!("Failed to read stdin: {e:?}")))?;

self.client.template_id_upload_put(&id.0, bytes).await?
self.client.update_template(&id.0, bytes).await?
}
};

Expand Down
24 changes: 8 additions & 16 deletions src/clients/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl<C: golem_client::api::WorkerClient + Sync + Send> WorkerClient for WorkerCl

Ok(self
.client
.template_id_workers_post(
.launch_new_worker(
&template_id.0,
&WorkerCreationRequest {
name: name.0,
Expand All @@ -124,7 +124,7 @@ impl<C: golem_client::api::WorkerClient + Sync + Send> WorkerClient for WorkerCl

let key = self
.client
.template_id_workers_worker_name_key_post(&template_id.0, &name.0)
.get_invocation_key(&template_id.0, &name.0)
.await?;

Ok(key_api_to_cli(key))
Expand Down Expand Up @@ -152,7 +152,7 @@ impl<C: golem_client::api::WorkerClient + Sync + Send> WorkerClient for WorkerCl

Ok(self
.client
.template_id_workers_worker_name_invoke_and_await_post(
.invoke_and_await_function(
&template_id.0,
&name.0,
&invocation_key.0,
Expand All @@ -174,12 +174,7 @@ impl<C: golem_client::api::WorkerClient + Sync + Send> WorkerClient for WorkerCl

let _ = self
.client
.template_id_workers_worker_name_invoke_post(
&template_id.0,
&name.0,
&function,
&parameters,
)
.invoke_function(&template_id.0, &name.0, &function, &parameters)
.await?;
Ok(())
}
Expand All @@ -193,7 +188,7 @@ impl<C: golem_client::api::WorkerClient + Sync + Send> WorkerClient for WorkerCl

let _ = self
.client
.template_id_workers_worker_name_interrupt_post(&template_id.0, &name.0, Some(false))
.interrupt_worker(&template_id.0, &name.0, Some(false))
.await?;
Ok(())
}
Expand All @@ -207,18 +202,15 @@ impl<C: golem_client::api::WorkerClient + Sync + Send> WorkerClient for WorkerCl

let _ = self
.client
.template_id_workers_worker_name_interrupt_post(&template_id.0, &name.0, Some(true))
.interrupt_worker(&template_id.0, &name.0, Some(true))
.await?;
Ok(())
}

async fn delete(&self, name: WorkerName, template_id: RawTemplateId) -> Result<(), GolemError> {
info!("Deleting worker {}/{}", template_id.0, name.0);

let _ = self
.client
.template_id_workers_worker_name_delete(&template_id.0, &name.0)
.await?;
let _ = self.client.delete_worker(&template_id.0, &name.0).await?;
Ok(())
}

Expand All @@ -231,7 +223,7 @@ impl<C: golem_client::api::WorkerClient + Sync + Send> WorkerClient for WorkerCl

Ok(self
.client
.template_id_workers_worker_name_get(&template_id.0, &name.0)
.get_worker_metadata(&template_id.0, &name.0)
.await?)
}

Expand Down

0 comments on commit ffd0ec4

Please sign in to comment.