zabbix_api/usergroup/
model.rs

1use crate::user::model::ZabbixUser;
2use serde::{Deserialize, Serialize};
3use serde_with::skip_serializing_none;
4
5/// Represents the permissions for a host group or template group within a user group.
6/// Corresponds to the "Permission" object in Zabbix API documentation.
7#[derive(Serialize, Deserialize, Debug, Clone, Default)]
8pub struct UserGroupPermission {
9    /// ID of the host group or template group.
10    pub id: String,
11    /// Access level to the host group or template group.
12    /// Possible values:
13    /// 0 - access denied;
14    /// 2 - read-only access;
15    /// 3 - read-write access.
16    pub permission: i32,
17}
18
19#[skip_serializing_none]
20#[derive(Serialize, Deserialize, Debug, Clone)]
21pub struct ZabbixUserGroup {
22    #[serde(rename = "usrgrpid")]
23    pub usrgrp_id: String,
24    pub name: String,
25    pub gui_access: Option<String>,
26    pub users_status: Option<String>,
27    pub debug_mode: Option<String>,
28    pub users: Option<Vec<ZabbixUser>>,
29    pub rights: Option<Vec<UserGroupPermission>>,
30}
31
32/// Represents a tag-based permission for a user group.
33/// Corresponds to the "Tag-based permission" object in Zabbix API documentation.
34#[derive(Serialize, Deserialize, Debug, Clone, Default)]
35pub struct UserGroupTagFilter {
36    /// ID of the host group to add permission to.
37    pub groupid: String,
38    /// Tag name.
39    pub tag: String,
40    /// Tag value.
41    pub value: String,
42}
43
44/// Represents a user to be added to a user group.
45/// Only the `userid` property is required.
46#[derive(Serialize, Deserialize, Debug, Clone, Default)]
47pub struct UserGroupUser {
48    #[serde(rename = "userid")]
49    pub user_id: String,
50}
51
52/// Parameters for the `usergroup.create` API method.
53/// See: https://www.zabbix.com/documentation/current/en/manual/api/reference/usergroup/create
54#[skip_serializing_none]
55#[derive(Serialize, Deserialize, Debug, Clone, Default)]
56pub struct CreateUserGroupRequest {
57    /// Name of the user group.
58    pub name: String,
59
60    /// (optional) Whether debug mode is enabled or disabled.
61    /// 0 - (default) disabled;
62    /// 1 - enabled.
63    pub debug_mode: i32,
64
65    /// (optional) Frontend authentication method of the users in the group.
66    /// 0 - (default) use the system default authentication method;
67    /// 1 - use internal authentication;
68    /// 2 - use LDAP authentication;
69    /// 3 - disable access to the frontend.
70    pub gui_access: Option<i32>,
71
72    /// (optional) Whether the user group is enabled or disabled.
73    /// 0 - (default) enabled;
74    /// 1 - disabled.
75    pub users_status: Option<i32>,
76
77    /// (optional) Host group permissions to assign to the user group.
78    pub hostgroup_rights: Option<Vec<UserGroupPermission>>,
79
80    /// (optional) Template group permissions to assign to the user group.
81    pub templategroup_rights: Option<Vec<UserGroupPermission>>,
82
83    /// (optional) Tag-based permissions to assign to the user group.
84    pub tag_filters: Option<Vec<UserGroupTagFilter>>,
85
86    /// (optional) Users to add to the user group.
87    pub users: Option<Vec<UserGroupUser>>,
88}
89
90/// Response structure for the `usergroup.create` API method.
91#[derive(Serialize, Deserialize, Debug, Clone)]
92pub struct CreateUserGroupResponse {
93    #[serde(rename = "usrgrpids")]
94    pub user_group_ids: Vec<String>,
95}