all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pdm-devel] [PATCH datacenter-manager 1/2] api structure: move /remotes/{id} to /remotes/remote/{id}
@ 2025-12-02  9:25 Fabian Grünbichler
  2025-12-02  9:25 ` [pdm-devel] [PATCH datacenter-manager 2/2] api: move remote-tasks, remote-updates and metrics-collection under /remotes Fabian Grünbichler
  2025-12-02 12:29 ` [pdm-devel] applied: [PATCH datacenter-manager 1/2] api structure: move /remotes/{id} to /remotes/remote/{id} Thomas Lamprecht
  0 siblings, 2 replies; 3+ messages in thread
From: Fabian Grünbichler @ 2025-12-02  9:25 UTC (permalink / raw)
  To: pdm-devel

to allow moving other top-level endpoints below /remotes/ as well..

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
 lib/pdm-client/src/lib.rs     | 17 +++++++++++------
 server/src/api/remotes.rs     | 13 ++++++++++---
 ui/src/remotes/config.rs      |  6 +++---
 ui/src/remotes/edit_remote.rs |  7 +++++--
 4 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/lib/pdm-client/src/lib.rs b/lib/pdm-client/src/lib.rs
index 11bedb6..2e4e3fc 100644
--- a/lib/pdm-client/src/lib.rs
+++ b/lib/pdm-client/src/lib.rs
@@ -92,7 +92,12 @@ impl<T: HttpApiClient> std::ops::DerefMut for PdmClient<T> {
 
 impl<T: HttpApiClient> PdmClient<T> {
     pub async fn list_remotes(&self) -> Result<Vec<Remote>, Error> {
-        Ok(self.0.get("/api2/extjs/remotes").await?.expect_json()?.data)
+        Ok(self
+            .0
+            .get("/api2/extjs/remotes/remote")
+            .await?
+            .expect_json()?
+            .data)
     }
 
     pub async fn add_remote(
@@ -110,7 +115,7 @@ impl<T: HttpApiClient> PdmClient<T> {
         }
         self.0
             .post(
-                "/api2/extjs/remotes",
+                "/api2/extjs/remotes/remote",
                 &AddRemoteParams {
                     remote,
                     create_token,
@@ -125,13 +130,13 @@ impl<T: HttpApiClient> PdmClient<T> {
         remote: &str,
         updater: &pdm_api_types::remotes::RemoteUpdater,
     ) -> Result<(), Error> {
-        let path = format!("/api2/extjs/remotes/{remote}");
+        let path = format!("/api2/extjs/remotes/remote/{remote}");
         self.0.put(&path, updater).await?.nodata()?;
         Ok(())
     }
 
     pub async fn delete_remote(&self, remote: &str) -> Result<(), Error> {
-        let path = format!("/api2/extjs/remotes/{remote}");
+        let path = format!("/api2/extjs/remotes/remote/{remote}");
         self.0.delete(&path).await?.nodata()?;
         Ok(())
     }
@@ -140,7 +145,7 @@ impl<T: HttpApiClient> PdmClient<T> {
         &self,
         remote: &str,
     ) -> Result<pve_api_types::VersionResponse, proxmox_client::Error> {
-        let path = format!("/api2/extjs/remotes/{remote}/version");
+        let path = format!("/api2/extjs/remotes/remote/{remote}/version");
         Ok(self.0.get(&path).await?.expect_json()?.data)
     }
 
@@ -382,7 +387,7 @@ impl<T: HttpApiClient> PdmClient<T> {
         mode: RrdMode,
         timeframe: RrdTimeframe,
     ) -> Result<pdm_api_types::rrddata::RemoteDatapoint, Error> {
-        let path = ApiPathBuilder::new(format!("/api2/extjs/remotes/{remote}/rrddata"))
+        let path = ApiPathBuilder::new(format!("/api2/extjs/remotes/remote/{remote}/rrddata"))
             .arg("cf", mode)
             .arg("timeframe", timeframe)
             .build();
diff --git a/server/src/api/remotes.rs b/server/src/api/remotes.rs
index a7463b9..17f8746 100644
--- a/server/src/api/remotes.rs
+++ b/server/src/api/remotes.rs
@@ -29,6 +29,13 @@ use super::rrd_common;
 use super::rrd_common::DataPoint;
 
 pub const ROUTER: Router = Router::new()
+    .get(&list_subdirs_api_method!(SUBDIRS))
+    .subdirs(SUBDIRS);
+
+#[sortable]
+const SUBDIRS: SubdirMap = &sorted!([("remote", &REMOTE_ROUTER),]);
+
+pub const REMOTE_ROUTER: Router = Router::new()
     .get(&API_METHOD_LIST_REMOTES)
     .post(&API_METHOD_ADD_REMOTE)
     .match_all("id", &ITEM_ROUTER);
@@ -36,11 +43,11 @@ pub const ROUTER: Router = Router::new()
 const ITEM_ROUTER: Router = Router::new()
     .put(&API_METHOD_UPDATE_REMOTE)
     .delete(&API_METHOD_REMOVE_REMOTE)
-    .get(&list_subdirs_api_method!(SUBDIRS))
-    .subdirs(SUBDIRS);
+    .get(&list_subdirs_api_method!(REMOTE_SUBDIRS))
+    .subdirs(REMOTE_SUBDIRS);
 
 #[sortable]
-const SUBDIRS: SubdirMap = &sorted!([
+const REMOTE_SUBDIRS: SubdirMap = &sorted!([
     ("config", &Router::new().get(&API_METHOD_REMOTE_CONFIG)),
     ("version", &Router::new().get(&API_METHOD_VERSION)),
     (
diff --git a/ui/src/remotes/config.rs b/ui/src/remotes/config.rs
index 7d41828..ac3c0f1 100644
--- a/ui/src/remotes/config.rs
+++ b/ui/src/remotes/config.rs
@@ -38,12 +38,12 @@ use proxmox_yew_comp::{
 use pdm_api_types::remotes::{NodeUrl, RemoteType};
 
 async fn load_remotes() -> Result<Vec<Remote>, Error> {
-    proxmox_yew_comp::http_get("/remotes", None).await
+    proxmox_yew_comp::http_get("/remotes/remote", None).await
 }
 
 async fn delete_item(key: Key) -> Result<(), Error> {
     let id = key.to_string();
-    let url = format!("/remotes/{}", percent_encode_component(&id));
+    let url = format!("/remotes/remote/{}", percent_encode_component(&id));
     proxmox_yew_comp::http_delete(&url, None).await?;
     Ok(())
 }
@@ -69,7 +69,7 @@ pub async fn create_remote(mut data: Value, remote_type: RemoteType) -> Result<(
         params["create-token"] = token.into();
     }
 
-    proxmox_yew_comp::http_post("/remotes", Some(params)).await
+    proxmox_yew_comp::http_post("/remotes/remote", Some(params)).await
 }
 
 /*
diff --git a/ui/src/remotes/edit_remote.rs b/ui/src/remotes/edit_remote.rs
index e5a9664..925d11a 100644
--- a/ui/src/remotes/edit_remote.rs
+++ b/ui/src/remotes/edit_remote.rs
@@ -56,7 +56,7 @@ impl Component for PdmEditRemote {
     fn view(&self, ctx: &Context<Self>) -> Html {
         let props = ctx.props();
         let url = format!(
-            "/remotes/{}/config",
+            "/remotes/remote/{}/config",
             percent_encode_component(&props.remote_id)
         );
         EditWindow::new(tr!("Edit") + ": " + &tr!("Remote"))
@@ -69,7 +69,10 @@ impl Component for PdmEditRemote {
                 move |form_ctx| edit_remote_input_panel(form_ctx, &remote_id)
             })
             .on_submit({
-                let url = format!("/remotes/{}", percent_encode_component(&props.remote_id));
+                let url = format!(
+                    "/remotes/remote/{}",
+                    percent_encode_component(&props.remote_id)
+                );
                 move |form_ctx: FormContext| {
                     let url = url.clone();
                     async move {
-- 
2.47.3



_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-12-02 12:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-02  9:25 [pdm-devel] [PATCH datacenter-manager 1/2] api structure: move /remotes/{id} to /remotes/remote/{id} Fabian Grünbichler
2025-12-02  9:25 ` [pdm-devel] [PATCH datacenter-manager 2/2] api: move remote-tasks, remote-updates and metrics-collection under /remotes Fabian Grünbichler
2025-12-02 12:29 ` [pdm-devel] applied: [PATCH datacenter-manager 1/2] api structure: move /remotes/{id} to /remotes/remote/{id} Thomas Lamprecht

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal