Skip to content

Commit 960a565

Browse files
committed
fixed Zabbix API issue zabbix#21
1 parent e4a2ec8 commit 960a565

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

zabbix_utils/aioapi.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,17 @@ async def func(*args: Any, **kwargs: Any) -> Any:
8484
# Support '_' suffix to avoid conflicts with python keywords
8585
method = removesuffix(self.object, '_') + "." + removesuffix(name, '_')
8686

87+
# Support passing list of ids and params as a dict
88+
params = kwargs or (
89+
(args[0] if type(args[0]) in (list, dict,) else list(args)) if args else None)
90+
8791
log.debug("Executing %s method", method)
8892

8993
need_auth = method not in ModuleUtils.UNAUTH_METHODS
9094

9195
response = await self.parent.send_async_request(
9296
method,
93-
args or kwargs,
97+
params,
9498
need_auth
9599
)
96100
return response.get('result')

zabbix_utils/api.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,17 @@ def func(*args: Any, **kwargs: Any) -> Any:
8383
# Support '_' suffix to avoid conflicts with python keywords
8484
method = removesuffix(self.object, '_') + "." + removesuffix(name, '_')
8585

86+
# Support passing list of ids and params as a dict
87+
params = kwargs or (
88+
(args[0] if type(args[0]) in (list, dict,) else list(args)) if args else None)
89+
8690
log.debug("Executing %s method", method)
8791

8892
need_auth = method not in ModuleUtils.UNAUTH_METHODS
8993

9094
return self.parent.send_api_request(
9195
method,
92-
args or kwargs,
96+
params,
9397
need_auth
9498
).get('result')
9599

@@ -136,7 +140,7 @@ def __init__(self, url: Optional[str] = None, token: Optional[str] = None,
136140

137141
if ssl_context is not None:
138142
if not isinstance(ssl_context, ssl.SSLContext):
139-
raise TypeError('Function "ssl_context" must return "ssl.SSLContext".') from None
143+
raise TypeError('Parameter "ssl_context" must be an "ssl.SSLContext".') from None
140144
self.ssl_context = ssl_context
141145

142146
self.__check_version(skip_version_check)

0 commit comments

Comments
 (0)