From: "Max R. Carrara" <m.carrara@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [RFC pve-storage master v1 06/12] plugin: meta: add metadata regarding views in API
Date: Mon, 8 Sep 2025 20:00:50 +0200 [thread overview]
Message-ID: <20250908180058.530119-7-m.carrara@proxmox.com> (raw)
In-Reply-To: <20250908180058.530119-1-m.carrara@proxmox.com>
Define and expose currently possible view types and view modes in
`::Plugin::Meta`.
Add a 'views' array to the objects returned by the 'plugins/storage'
and 'plugins/storage/{plugin}' endpoints, containing all view types
that a plugin currently supports.
Signed-off-by: Max R. Carrara <m.carrara@proxmox.com>
---
src/PVE/API2/Plugins/Storage/Config.pm | 9 ++++++
src/PVE/Storage/Plugin/Meta.pm | 40 ++++++++++++++++++++++++++
2 files changed, 49 insertions(+)
diff --git a/src/PVE/API2/Plugins/Storage/Config.pm b/src/PVE/API2/Plugins/Storage/Config.pm
index 2160e4e..60c0515 100644
--- a/src/PVE/API2/Plugins/Storage/Config.pm
+++ b/src/PVE/API2/Plugins/Storage/Config.pm
@@ -12,6 +12,7 @@ use PVE::Storage::Plugin::Meta qw(
plugin_kinds
plugin_content_types
plugin_formats
+ plugin_view_types
get_plugin_metadata
get_plugin_metadata_all
);
@@ -81,6 +82,14 @@ my $PLUGIN_METADATA_SCHEMA = {
type => 'string',
},
},
+ views => {
+ type => 'array',
+ optional => 0,
+ items => {
+ type => 'string',
+ enum => plugin_view_types(),
+ },
+ },
},
};
diff --git a/src/PVE/Storage/Plugin/Meta.pm b/src/PVE/Storage/Plugin/Meta.pm
index 561c01b..38d6279 100644
--- a/src/PVE/Storage/Plugin/Meta.pm
+++ b/src/PVE/Storage/Plugin/Meta.pm
@@ -14,6 +14,8 @@ our @EXPORT_OK = qw(
plugin_kinds
plugin_content_types
plugin_formats
+ plugin_view_types
+ plugin_view_modes
get_plugin_metadata
get_plugin_metadata_all
);
@@ -44,6 +46,14 @@ my $PLUGIN_FORMATS = [
my $DEFAULT_PLUGIN_FORMAT = 'raw';
+my $PLUGIN_VIEW_TYPES = [
+ 'form',
+];
+
+my $PLUGIN_VIEW_MODES = [
+ 'create', 'update',
+];
+
sub plugin_kinds() {
return [$PLUGIN_KINDS->@*];
}
@@ -56,6 +66,14 @@ sub plugin_formats() {
return [$PLUGIN_FORMATS->@*];
}
+sub plugin_view_types() {
+ return [$PLUGIN_VIEW_TYPES->@*];
+}
+
+sub plugin_view_modes() {
+ return [$PLUGIN_VIEW_MODES->@*];
+}
+
my $plugin_metadata = undef;
my sub assemble_plugin_metadata_content($plugin) {
@@ -114,6 +132,26 @@ my sub assemble_plugin_metadata_format($plugin) {
return $format_metadata;
}
+my sub assemble_plugin_metadata_views($plugin) {
+ confess '$plugin is undef' if !defined($plugin);
+
+ my $plugindata = $plugin->plugindata();
+
+ return [] if !defined($plugindata->{views});
+
+ my $view_metadata = [];
+
+ my $views = $plugindata->{views};
+
+ for my $view ($PLUGIN_VIEW_TYPES->@*) {
+ if (defined($views->{$view})) {
+ push($view_metadata->@*, $view);
+ }
+ }
+
+ return $view_metadata;
+}
+
my sub assemble_plugin_metadata() {
return if defined($plugin_metadata);
@@ -145,6 +183,8 @@ my sub assemble_plugin_metadata() {
$metadata->{'sensitive-properties'} =
[grep { $sensitive_properties->{$_} } sort keys $sensitive_properties->%*];
+ $metadata->{views} = assemble_plugin_metadata_views($plugin);
+
$plugin_metadata->{$type} = $metadata;
}
--
2.47.2
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2025-09-08 18:01 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-08 18:00 [pve-devel] [RFC pve-storage, pve-manager master v1 00/12] GUI Support for Custom Storage Plugins Max R. Carrara
2025-09-08 18:00 ` [pve-devel] [RFC pve-storage master v1 01/12] plugin: meta: add package PVE::Storage::Plugin::Meta Max R. Carrara
2025-09-08 18:00 ` [pve-devel] [RFC pve-storage master v1 02/12] api: Add 'plugins/storage' and 'plugins/storage/{plugin}' paths Max R. Carrara
2025-09-08 18:00 ` [pve-devel] [RFC pve-storage master v1 03/12] plugin: meta: introduce 'short-name' Max R. Carrara
2025-09-08 18:00 ` [pve-devel] [RFC pve-storage master v1 04/12] plugin: views: add package PVE::Storage::Plugin::Views Max R. Carrara
2025-09-08 18:00 ` [pve-devel] [RFC pve-storage master v1 05/12] plugin: add new plugin API method `get_form_view()` Max R. Carrara
2025-09-08 18:00 ` Max R. Carrara [this message]
2025-09-08 18:00 ` [pve-devel] [RFC pve-storage master v1 07/12] api: views: add paths regarding storage plugin views Max R. Carrara
2025-09-08 18:00 ` [pve-devel] [RFC pve-storage master v1 08/12] plugin: zfspool: add 'short-name' and form view for ZFS pool plugin Max R. Carrara
2025-09-08 18:00 ` [pve-devel] [RFC pve-manager master v1 09/12] api: handle path 'plugins/storage' through its package Max R. Carrara
2025-09-08 18:00 ` [pve-devel] [RFC pve-manager master v1 10/12] ui: storage: add CustomBase.js Max R. Carrara
2025-09-08 18:00 ` [pve-devel] [RFC pve-manager master v1 11/12] ui: storage: support custom storage plugins in Datacenter > Storage Max R. Carrara
2025-09-08 18:00 ` [pve-devel] [RFC pve-manager master v1 12/12] ui: storage: use `Ext.Msg.alert()` instead of throwing an exception Max R. Carrara
2025-09-08 19:23 ` [pve-devel] [RFC pve-storage, pve-manager master v1 00/12] GUI Support for Custom Storage Plugins Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250908180058.530119-7-m.carrara@proxmox.com \
--to=m.carrara@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox