Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NAS-131559 / 25.04 / Remove accepts style decorator from apps plugin #15225

Merged
merged 1 commit into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/middlewared/middlewared/api/base/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ def api_method(
cli_private: bool = False,
authentication_required: bool = True,
authorization_required: bool = True,
pass_app: bool = False,
pass_app_require: bool = False,
pass_app_rest: bool = False,
):
"""
Mark a `Service` class method as an API method.
Expand Down Expand Up @@ -58,6 +61,13 @@ def api_method(
raise TypeError("`returns` model must only have one field called `result`")

def wrapper(func):
if pass_app:
# Pass the application instance as parameter to the method
func._pass_app = {
'require': pass_app_require,
'rest': pass_app_rest,
}

args_index = calculate_args_index(func, audit_callback)

if asyncio.iscoroutinefunction(func):
Expand Down
1 change: 1 addition & 0 deletions src/middlewared/middlewared/api/v25_04_0/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from .api_key import * # noqa
from .app import * # noqa
from .app_image import * # noqa
from .app_ix_volume import * # noqa
from .auth import * # noqa
from .boot_environments import * # noqa
from .catalog import * # noqa
Expand Down
Loading
Loading