1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
use serde::{Deserialize, Serialize};
use crate::{field_access, impl_default, impl_display, GroupSetting};
/// Represents the user group's attributes.
///
/// Modified from `openapi-generator-cli` output:
///
/// ```shell,no_build,no_run
/// $ openapi-generator-cli generate -g rust -i ./zerver/openapi/zulip.yaml -o zulip-openapi --skip-validate-spec
/// ```
///
/// ```text
/// /*
/// * Zulip REST API
/// *
/// * Powerful open source group chat
/// *
/// * The version of the OpenAPI document: 1.0.0
/// *
/// * Generated by: https://openapi-generator.tech
/// */
/// ```
///
/// See [zerver/openapi/zulip.yaml](https://github.com/zulip/zulip/blob/main/zerver/openapi/zulip.yaml) for the original OpenAPI configuration.
///
/// Configuration slightly modified to work with the Rust generator of [`openapi-generator-cli`](https://openapi-generator.tech).
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct UserGroup {
#[serde(skip_serializing_if = "Option::is_none")]
name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
date_created: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
creator_id: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
description: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
members: Option<Vec<u64>>,
#[serde(skip_serializing_if = "Option::is_none")]
direct_subgroup_ids: Option<Vec<u64>>,
#[serde(skip_serializing_if = "Option::is_none")]
id: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
is_system_group: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
can_add_members_group: Option<GroupSetting>,
#[serde(skip_serializing_if = "Option::is_none")]
can_join_group: Option<GroupSetting>,
#[serde(skip_serializing_if = "Option::is_none")]
can_leave_group: Option<GroupSetting>,
#[serde(skip_serializing_if = "Option::is_none")]
can_manage_group: Option<GroupSetting>,
#[serde(skip_serializing_if = "Option::is_none")]
can_mention_group: Option<GroupSetting>,
#[serde(skip_serializing_if = "Option::is_none")]
can_remove_members_group: Option<GroupSetting>,
#[serde(skip_serializing_if = "Option::is_none")]
deactivated: Option<bool>,
}
impl UserGroup {
/// Creates a new [UserGroup].
pub const fn new() -> Self {
Self {
name: None,
date_created: None,
creator_id: None,
description: None,
members: None,
direct_subgroup_ids: None,
id: None,
is_system_group: None,
can_add_members_group: None,
can_join_group: None,
can_leave_group: None,
can_manage_group: None,
can_mention_group: None,
can_remove_members_group: None,
deactivated: None,
}
}
}
field_access! {
UserGroup {
/// The name of the user group.
name: option_cow_deref { str, String },
/// The description of the user group.
description: option_cow_deref { str, String },
/// Array containing the ID of the users who are members of this user group.
///
/// **Changes**: Prior to Zulip 10.0 (feature level 303), this list also included deactivated users who were members of the user group before being deactivated.
members: option_cow_deref { [u64], Vec<u64> },
/// Array containing the ID of the direct_subgroups of this user group.
///
/// **Changes**: New in Zulip 6.0 (feature level 131).
/// Introduced in feature level 127 as `subgroups`, but clients can ignore older events as this feature level predates subgroups being fully implemented.
direct_subgroup_ids: option_cow_deref { [u64], Vec<u64> },
}
}
field_access! {
UserGroup {
/// The UNIX timestamp for when the user group was created, in UTC seconds.
///
/// A `null` value means the user group has no recorded date, which is often because the user group is very old,
/// or because it was created via a data import tool or [management command](https://zulip.readthedocs.io/en/latest/production/management-commands.html).
///
/// **Changes**: New in Zulip 10.0 (feature level 292).
date_created: option { u64 },
/// The ID of the user who created this user group.
///
/// A `null` value means the user group has no recorded creator, which is often because the user group is very old,
/// or because it was created via a data import tool or [management command](https://zulip.readthedocs.io/en/latest/production/management-commands.html).
///
/// **Changes**: New in Zulip 10.0 (feature level 292).
creator_id: option { u64 },
/// The ID of the user group.
id: option { u64 },
/// Whether the user group is a system group which cannot be directly modified by users.
///
/// **Changes**: New in Zulip 5.0 (feature level 93).
is_system_group: option { bool },
/// Whether the user group is deactivated.
///
/// Deactivated groups cannot be used as a subgroup of another group or used for any other purpose.
///
/// **Changes**: New in Zulip 10.0 (feature level 290).
deactivated: option { bool },
}
}
field_access! {
UserGroup {
/// A [GroupSetting] defining the set of users who have permission to add members to this user group.
can_add_members_group: option_ref { GroupSetting },
/// A [GroupSetting] defining the set of users who have permission to join this user group.
can_join_group: option_ref { GroupSetting },
/// A [GroupSetting] defining the set of users who have permission to leave this user group.
can_leave_group: option_ref { GroupSetting },
/// A [GroupSetting] defining the set of users who have permission to [manage this user group](https://zuliip.com/help/manage-user-groups).
can_manage_group: option_ref { GroupSetting },
/// A [GroupSetting] defining the set of users who have permission to [mention this user group](https://zulip.com/help/mention-a-user-or-group).
can_mention_group: option_ref { GroupSetting },
/// A [GroupSetting] defining the set of users who have permission to remove members from this user group.
can_remove_members_group: option_ref { GroupSetting },
}
}
impl_default!(UserGroup);
impl_display!(UserGroup);