From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 259921FF187 for ; Mon, 8 Sep 2025 20:01:16 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id DF6E418899; Mon, 8 Sep 2025 20:01:14 +0200 (CEST) From: "Max R. Carrara" To: pve-devel@lists.proxmox.com Date: Mon, 8 Sep 2025 20:00:50 +0200 Message-ID: <20250908180058.530119-7-m.carrara@proxmox.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250908180058.530119-1-m.carrara@proxmox.com> References: <20250908180058.530119-1-m.carrara@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1757354448386 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.089 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [RFC pve-storage master v1 06/12] plugin: meta: add metadata regarding views in API X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" 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 --- 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