Skip to content

Commit

Permalink
Remove accepts style decorator from apps plugin (#15225)
Browse files Browse the repository at this point in the history
  • Loading branch information
Qubad786 authored Dec 31, 2024
1 parent d6bd38e commit 9ef345f
Show file tree
Hide file tree
Showing 14 changed files with 460 additions and 235 deletions.
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

0 comments on commit 9ef345f

Please sign in to comment.