]> git.proxmox.com Git - proxmox-backup.git/commitdiff
move subscription API path to /nodes
authorStefan Reiter <s.reiter@proxmox.com>
Tue, 21 Jul 2020 11:41:06 +0000 (13:41 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 21 Jul 2020 17:33:52 +0000 (19:33 +0200)
This aligns it with PVE and allows the widget toolkit's update window
"refresh" to work without modifications once POST /apt/update is
implemented.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
src/api2.rs
src/api2/node.rs
src/api2/node/subscription.rs [new file with mode: 0644]
src/api2/subscription.rs [deleted file]
www/Dashboard.js
www/Subscription.js

index 178f3f4570f1c6b33e3aa14c6fb4dc05ab6068e4..85d29ed20f989488fe9f304df19ea2209afb969e 100644 (file)
@@ -4,7 +4,6 @@ pub mod backup;
 pub mod config;
 pub mod node;
 pub mod reader;
-mod subscription;
 pub mod status;
 pub mod types;
 pub mod version;
@@ -26,7 +25,6 @@ pub const SUBDIRS: SubdirMap = &[
     ("pull", &pull::ROUTER),
     ("reader", &reader::ROUTER),
     ("status", &status::ROUTER),
-    ("subscription", &subscription::ROUTER),
     ("version", &version::ROUTER),
 ];
 
index 13ff282cd1d3ca7d53d172c9404faa6dc48f366d..e67cab4eec532ab83937bf278b365465cce6354f 100644 (file)
@@ -9,6 +9,7 @@ mod syslog;
 mod journal;
 mod services;
 mod status;
+mod subscription;
 pub(crate) mod rrd;
 pub mod disks;
 
@@ -20,6 +21,7 @@ pub const SUBDIRS: SubdirMap = &[
     ("rrd", &rrd::ROUTER),
     ("services", &services::ROUTER),
     ("status", &status::ROUTER),
+    ("subscription", &subscription::ROUTER),
     ("syslog", &syslog::ROUTER),
     ("tasks", &tasks::ROUTER),
     ("time", &time::ROUTER),
diff --git a/src/api2/node/subscription.rs b/src/api2/node/subscription.rs
new file mode 100644 (file)
index 0000000..186019c
--- /dev/null
@@ -0,0 +1,56 @@
+use anyhow::{Error};
+use serde_json::{json, Value};
+
+use proxmox::api::{api, Router, Permission};
+
+use crate::tools;
+use crate::config::acl::PRIV_SYS_AUDIT;
+use crate::api2::types::NODE_SCHEMA;
+
+#[api(
+    input: {
+        properties: {
+            node: {
+                schema: NODE_SCHEMA,
+            },
+        },
+    },
+    returns: {
+        description: "Subscription status.",
+        properties: {
+            status: {
+                type: String,
+                description: "'NotFound', 'active' or 'inactive'."
+            },
+            message: {
+                type: String,
+                description: "Human readable problem description.",
+            },
+            serverid: {
+                type: String,
+                description: "The unique server ID.",
+            },
+            url: {
+                type: String,
+                description: "URL to Web Shop.",
+            },
+        },
+    },
+    access: {
+        permission: &Permission::Privilege(&[], PRIV_SYS_AUDIT, false),
+    },
+)]
+/// Read subscription info.
+fn get_subscription(_param: Value) -> Result<Value, Error> {
+
+    let url = "https://www.proxmox.com/en/proxmox-backup-server/pricing";
+    Ok(json!({
+        "status": "NotFound",
+       "message": "There is no subscription key",
+       "serverid": tools::get_hardware_address()?,
+       "url":  url,
+     }))
+}
+
+pub const ROUTER: Router = Router::new()
+    .get(&API_METHOD_GET_SUBSCRIPTION);
diff --git a/src/api2/subscription.rs b/src/api2/subscription.rs
deleted file mode 100644 (file)
index 7d1b023..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-use anyhow::{Error};
-use serde_json::{json, Value};
-
-use proxmox::api::{api, Router, Permission};
-
-use crate::tools;
-use crate::config::acl::PRIV_SYS_AUDIT;
-
-#[api(
-    returns: {
-        description: "Subscription status.",
-        properties: {
-            status: {
-                type: String,
-                description: "'NotFound', 'active' or 'inactive'."
-            },
-            message: {
-                type: String,
-                description: "Human readable problem description.",
-            },
-            serverid: {
-                type: String,
-                description: "The unique server ID.",
-            },
-            url: {
-                type: String,
-                description: "URL to Web Shop.",
-            },
-        },
-    },
-    access: {
-        permission: &Permission::Privilege(&[], PRIV_SYS_AUDIT, false),
-    },
-)]
-/// Read subscription info.
-fn get_subscription(_param: Value) -> Result<Value, Error> {
-
-    let url = "https://www.proxmox.com/en/proxmox-backup-server/pricing";
-    Ok(json!({
-        "status": "NotFound",
-       "message": "There is no subscription key",
-       "serverid": tools::get_hardware_address()?,
-       "url":  url,
-     }))
-}
-
-pub const ROUTER: Router = Router::new()
-    .get(&API_METHOD_GET_SUBSCRIPTION);
index 7f699d93a3198716832c2663e9d98f1135bc8b2f..d6dc40d256d86c06d33463dfc0020327a4aa4143 100644 (file)
@@ -209,7 +209,7 @@ Ext.define('PBS.Dashboard', {
                autoDestroy: true,
                proxy: {
                    type: 'proxmox',
-                   url: '/api2/json/subscription'
+                   url: '/api2/json/nodes/localhost/subscription'
                },
                listeners: {
                    load: 'updateSubscription'
index f5a64459a48ecd09e665629655dcc1971d268e2e..8746091fe42fcb0da34d9da368daa577f87ff28a 100644 (file)
@@ -37,7 +37,7 @@ Ext.define('PBS.Subscription', {
            me.rstore.load();
        };
 
-       var baseurl = '/subscription';
+       var baseurl = '/nodes/localhost/subscription';
 
        var render_status = function(value) {