Skip to content

Commit

Permalink
fix: Add notification users to default user group
Browse files Browse the repository at this point in the history
  • Loading branch information
pederhan committed Dec 4, 2024
1 parent c9b1b07 commit 264420c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- `create_notification_user`: Now adds users to the default user group in addition to the notification user group to match behavior in V2.

### Deprecated

- `login` command. It is fundamentally flawed and is slated to be removed in a future version unless a valid use case is presented.
Expand Down
19 changes: 11 additions & 8 deletions zabbix_cli/commands/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ def create_notification_user(
Run [command]show_media_types[/command] to get a list of available media types.
Uses the default notification user group defined in the configuration file
if no user groups are specified with [option]--usergroups[/option].
Adds the user to the default user group and default notification user group
unless [option]--usergroups[/option] is specified.
"""
from zabbix_cli.models import Result
from zabbix_cli.pyzabbix.types import User
Expand Down Expand Up @@ -227,12 +227,15 @@ def create_notification_user(
f"Media type {mediatype!r} does not exist. Run [command]show_media_types[/command] command to get a list of available media types."
)

with app.status("Fetching usergroup(s)..."):
if usergroups:
ug_list = parse_list_arg(usergroups)
else:
ug_list = app.state.config.app.default_notification_users_usergroups
ugroups = [app.state.client.get_usergroup(ug) for ug in ug_list]
# Parse user groups args or use defaults
if usergroups:
ug_list = parse_list_arg(usergroups)
else:
ug_list: List[str] = []
ug_list.extend(app.state.config.app.default_notification_users_usergroups)
ug_list.extend(app.state.config.app.default_create_user_usergroups)
with app.status("Fetching user group(s)..."):
ugroups = [app.state.client.get_usergroup(ug) for ug in set(ug_list)]

user_media = [
UserMedia(
Expand Down

0 comments on commit 264420c

Please sign in to comment.