public inbox for pdm-devel@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

* [pdm-devel] [PATCH datacenter-manager 2/2] api: move remote-tasks, remote-updates and metrics-collection under /remotes
  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 ` 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
  1 sibling, 0 replies; 3+ messages in thread
From: Fabian Grünbichler @ 2025-12-02  9:25 UTC (permalink / raw)
  To: pdm-devel

these are all endpoints/trees which are remote-type agnostic, but they are not
important enough to warrant their own top-level entry point..

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
I hope I haven't missed any references, additional testing would be appreciated!

 lib/pdm-client/src/lib.rs          |  8 ++++----
 server/src/api/mod.rs              |  4 ----
 server/src/api/remotes.rs          | 10 +++++++++-
 ui/src/dashboard/filtered_tasks.rs |  2 +-
 ui/src/dashboard/view.rs           |  2 +-
 ui/src/main.rs                     |  2 +-
 ui/src/remotes/tasks.rs            |  2 +-
 7 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/lib/pdm-client/src/lib.rs b/lib/pdm-client/src/lib.rs
index 2e4e3fc..8cce4f1 100644
--- a/lib/pdm-client/src/lib.rs
+++ b/lib/pdm-client/src/lib.rs
@@ -343,7 +343,7 @@ impl<T: HttpApiClient> PdmClient<T> {
         &self,
         remote: Option<&str>,
     ) -> Result<(), proxmox_client::Error> {
-        let path = "/api2/extjs/metric-collection/trigger";
+        let path = "/api2/extjs/remotes/metric-collection/trigger";
 
         #[derive(Serialize)]
         struct TriggerParams<'a> {
@@ -363,7 +363,7 @@ impl<T: HttpApiClient> PdmClient<T> {
     pub async fn get_metric_collection_status(
         &self,
     ) -> Result<Vec<pdm_api_types::MetricCollectionStatus>, Error> {
-        let path = "/api2/extjs/metric-collection/status";
+        let path = "/api2/extjs/remotes/metric-collection/status";
         Ok(self.0.get(path).await?.expect_json()?.data)
     }
 
@@ -1326,7 +1326,7 @@ impl<T: HttpApiClient> PdmClient<T> {
     ) -> Result<pdm_api_types::remote_updates::UpdateSummary, Error> {
         Ok(self
             .0
-            .get("/api2/extjs/remote-updates/summary")
+            .get("/api2/extjs/remotes/updates/summary")
             .await?
             .expect_json()?
             .data)
@@ -1336,7 +1336,7 @@ impl<T: HttpApiClient> PdmClient<T> {
     pub async fn refresh_remote_update_summary(&self) -> Result<pdm_api_types::UPID, Error> {
         Ok(self
             .0
-            .post_without_body("/api2/extjs/remote-updates/refresh")
+            .post_without_body("/api2/extjs/remotes/updates/refresh")
             .await?
             .expect_json()?
             .data)
diff --git a/server/src/api/mod.rs b/server/src/api/mod.rs
index e3efed8..5688871 100644
--- a/server/src/api/mod.rs
+++ b/server/src/api/mod.rs
@@ -26,16 +26,12 @@ pub mod sdn;
 const SUBDIRS: SubdirMap = &sorted!([
     ("access", &access::ROUTER),
     ("config", &config::ROUTER),
-    ("metric-collection", &metric_collection::ROUTER),
     ("ping", &Router::new().get(&API_METHOD_PING)),
     ("pve", &pve::ROUTER),
     ("pbs", &pbs::ROUTER),
     ("remotes", &remotes::ROUTER),
     ("resources", &resources::ROUTER),
     ("nodes", &nodes::ROUTER),
-    ("remote-tasks", &remote_tasks::ROUTER),
-    // TODO: There might be a better place for this endpoint.
-    ("remote-updates", &remote_updates::ROUTER),
     ("sdn", &sdn::ROUTER),
     ("version", &Router::new().get(&API_METHOD_VERSION)),
 ]);
diff --git a/server/src/api/remotes.rs b/server/src/api/remotes.rs
index 17f8746..298ad13 100644
--- a/server/src/api/remotes.rs
+++ b/server/src/api/remotes.rs
@@ -21,6 +21,9 @@ use pdm_api_types::remotes::{Remote, RemoteType, RemoteUpdater, REMOTE_ID_SCHEMA
 use pdm_api_types::rrddata::RemoteDatapoint;
 use pdm_api_types::{Authid, ConfigDigest, PRIV_RESOURCE_AUDIT, PRIV_RESOURCE_MODIFY};
 
+use crate::api::metric_collection as metric_collection_api;
+use crate::api::remote_tasks;
+use crate::api::remote_updates;
 use crate::metric_collection;
 use crate::{connection, pbs_client};
 
@@ -33,7 +36,12 @@ pub const ROUTER: Router = Router::new()
     .subdirs(SUBDIRS);
 
 #[sortable]
-const SUBDIRS: SubdirMap = &sorted!([("remote", &REMOTE_ROUTER),]);
+const SUBDIRS: SubdirMap = &sorted!([
+    ("remote", &REMOTE_ROUTER),
+    ("updates", &remote_updates::ROUTER),
+    ("tasks", &remote_tasks::ROUTER),
+    ("metric-collection", &metric_collection_api::ROUTER),
+]);
 
 pub const REMOTE_ROUTER: Router = Router::new()
     .get(&API_METHOD_LIST_REMOTES)
diff --git a/ui/src/dashboard/filtered_tasks.rs b/ui/src/dashboard/filtered_tasks.rs
index fa59e59..bfe3347 100644
--- a/ui/src/dashboard/filtered_tasks.rs
+++ b/ui/src/dashboard/filtered_tasks.rs
@@ -112,7 +112,7 @@ impl PdmFilteredTasks {
             params["remote"] = serde_json::Value::String(remote);
         }
 
-        http_get("/remote-tasks/list", Some(params)).await
+        http_get("/remotes/tasks/list", Some(params)).await
     }
 }
 
diff --git a/ui/src/dashboard/view.rs b/ui/src/dashboard/view.rs
index 2791277..0606f1a 100644
--- a/ui/src/dashboard/view.rs
+++ b/ui/src/dashboard/view.rs
@@ -230,7 +230,7 @@ impl ViewComp {
                             "limit": 0,
                         });
                         add_view_filter(&mut params);
-                        let res = http_get("/remote-tasks/statistics", Some(params)).await;
+                        let res = http_get("/remotes/tasks/statistics", Some(params)).await;
                         link.send_message(Msg::LoadingResult(LoadingResult::TaskStatistics(res)));
                     }
                 };
diff --git a/ui/src/main.rs b/ui/src/main.rs
index b7dd3ef..63ac143 100644
--- a/ui/src/main.rs
+++ b/ui/src/main.rs
@@ -191,7 +191,7 @@ impl Component for DatacenterManagerApp {
                     let mut res: Vec<TaskListItem> =
                         http_get(url.to_string(), params.clone()).await?;
 
-                    let res2: Vec<_> = http_get("/remote-tasks/list", params).await?;
+                    let res2: Vec<_> = http_get("/remotes/tasks/list", params).await?;
                     res.extend_from_slice(&res2);
 
                     Ok(res.into_iter().take(100).collect())
diff --git a/ui/src/remotes/tasks.rs b/ui/src/remotes/tasks.rs
index 825bd57..f42fa0f 100644
--- a/ui/src/remotes/tasks.rs
+++ b/ui/src/remotes/tasks.rs
@@ -139,7 +139,7 @@ impl Component for PbsRemoteTaskList {
             });
 
         let mut task_list = Tasks::new()
-            .base_url("/remote-tasks/list")
+            .base_url("/remotes/tasks/list")
             .on_show_task({
                 let link = ctx.link().clone();
                 move |(upid_str, endtime)| link.send_message(Some((upid_str, endtime)))
-- 
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

* [pdm-devel] applied: [PATCH datacenter-manager 1/2] api structure: move /remotes/{id} to /remotes/remote/{id}
  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 ` Thomas Lamprecht
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Lamprecht @ 2025-12-02 12:29 UTC (permalink / raw)
  To: pdm-devel, Fabian Grünbichler

On Tue, 02 Dec 2025 10:25:53 +0100, Fabian Grünbichler wrote:
> to allow moving other top-level endpoints below /remotes/ as well..
> 
> 

Applied, thanks!

[1/2] api structure: move /remotes/{id} to /remotes/remote/{id}
      commit: 7a2ec8437b8267d03d49918b44943030a32ae370
[2/2] api: move remote-tasks, remote-updates and metrics-collection under /remotes
      commit: 1c31c21930e7656db41c373bae56236d76d68c9c


_______________________________________________
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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal