On Wed Feb 4, 2026 at 5:13 PM CET, Arthur Bied-Charreton wrote:
> This endpoint allows triggering a refresh of the notification targets'
> state, e.g., to prevent OAuth2 refresh tokens from expiring.
>
> Signed-off-by: Arthur Bied-Charreton <[email protected]>
> ---
>  PVE/API2/Cluster/Notifications.pm | 34 +++++++++++++++++++++++++++++++
>  1 file changed, 34 insertions(+)
>
> diff --git a/PVE/API2/Cluster/Notifications.pm 
> b/PVE/API2/Cluster/Notifications.pm
> index a45a15b2..f993817d 100644
> --- a/PVE/API2/Cluster/Notifications.pm
> +++ b/PVE/API2/Cluster/Notifications.pm
> @@ -321,6 +321,40 @@ __PACKAGE__->register_method({
>      },
>  });
>  
> +__PACKAGE__->register_method({
> +    name => "refresh_targets",
> +    path => 'refresh-targets',

Same note here regarding naming, I think 'refresh-targets' is a bit too
generic for my taste. Either we fully narrow it down to
'refresh-oauth-tokens', or make it rather general, e.g.
'trigger-periodic-maintenance' (or something similar, you get the
general direction), covering the case that *maybe* some other endpoint
could need some periodic action as well.

Also, do have any plans of exposing this in the GUI somehow? It's
definitely nice to have this available via pvesh for manual
troubleshooting by an admin anyways, so the API endpoint makes sense;
but as far as I can tell you do not use this endpoint anywhere in the
GUI code; hence I'm asking.

> +    protected => 1,
> +    method => 'POST',
> +    description => 'Refresh state for all targets',
> +    permissions => {
> +        check => [
> +            'and',
> +            ['perm', '/mapping/notifications', ['Mapping.Modify']],
> +            [
> +                'or',
> +                ['perm', '/', ['Sys.Audit', 'Sys.Modify']],
> +                ['perm', '/', ['Sys.AccessNetwork']],
> +            ],
> +        ],
> +    },
> +    parameters => {
> +        additionalProperties => 0,
> +        properties => {},
> +    },
> +    returns => { type => 'null' },
> +    code => sub {
> +        eval {
> +            my $config = PVE::Notify::read_config();
> +            $config->refresh_targets();
> +        };
> +
> +        raise_api_error($@) if $@;
> +
> +        return;
> +    },
> +});
> +
>  __PACKAGE__->register_method({
>      name => 'test_target',
>      path => 'targets/{name}/test',




Reply via email to