[pve-devel] [PATCH manager 2/6] ACME: add challengeschema api call
Dominik Csapak
d.csapak at proxmox.com
Tue May 5 14:38:14 CEST 2020
which returns a list of challenge api types with the schema of their
required data (if it exists)
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
PVE/API2/ACMEAccount.pm | 55 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/PVE/API2/ACMEAccount.pm b/PVE/API2/ACMEAccount.pm
index baff26bd..cbfa19a7 100644
--- a/PVE/API2/ACMEAccount.pm
+++ b/PVE/API2/ACMEAccount.pm
@@ -9,6 +9,7 @@ use PVE::Exception qw(raise_param_exc);
use PVE::JSONSchema qw(get_standard_option);
use PVE::RPCEnvironment;
use PVE::Tools qw(extract_param);
+use PVE::ACME::Challenge;
use PVE::API2::ACMEPlugin;
@@ -63,6 +64,7 @@ __PACKAGE__->register_method ({
{ name => 'tos' },
{ name => 'directories' },
{ name => 'plugins' },
+ { name => 'challengeschema' },
];
}});
@@ -366,4 +368,57 @@ __PACKAGE__->register_method ({
return $acme_directories;
}});
+__PACKAGE__->register_method ({
+ name => 'challengeschema',
+ path => 'challengeschema',
+ method => 'GET',
+ description => "Get schema of ACME challenge types.",
+ permissions => { user => 'all' },
+ parameters => {
+ additionalProperties => 0,
+ properties => {},
+ },
+ returns => {
+ type => 'array',
+ items => {
+ type => 'object',
+ additionalProperties => 0,
+ properties => {
+ name => {
+ type => 'string',
+ },
+ type => {
+ type => 'string',
+ },
+ schema => {
+ type => 'object',
+ },
+ },
+ },
+ },
+ code => sub {
+ my ($param) = @_;
+
+ my $plugin_type_enum = PVE::ACME::Challenge->lookup_types();
+
+ my $res = [];
+
+ for my $type (@$plugin_type_enum) {
+ my $plugin = PVE::ACME::Challenge->lookup($type);
+ if ($plugin->can('get_supported_plugins')) {
+ my $type = $plugin->type();
+ my $plugins = $plugin->get_supported_plugins();
+ for my $name (sort keys %$plugins) {
+ push @$res, {
+ name => $name,
+ type => $type,
+ schema => $plugins->{$name},
+ };
+ }
+ }
+ }
+
+ return $res;
+ }});
+
1;
--
2.20.1
More information about the pve-devel
mailing list