cio_api/configs.rs
1use std::collections::BTreeMap;
2
3use serde::{Deserialize, Serialize};
4
5/// The data type for our configuration files.
6#[derive(Debug, Deserialize, Serialize)]
7pub struct Config {
8 pub users: BTreeMap<String, UserConfig>,
9 pub groups: BTreeMap<String, GroupConfig>,
10
11 pub buildings: BTreeMap<String, BuildingConfig>,
12 pub resources: BTreeMap<String, ResourceConfig>,
13
14 pub links: BTreeMap<String, LinkConfig>,
15
16 pub labels: Vec<LabelConfig>,
17}
18
19/// The data type for a user.
20#[derive(Debug, Clone, Deserialize, Serialize)]
21pub struct UserConfig {
22 pub first_name: String,
23 pub last_name: String,
24 pub username: String,
25 #[serde(skip_serializing_if = "Option::is_none")]
26 pub aliases: Option<Vec<String>>,
27 #[serde(skip_serializing_if = "Option::is_none")]
28 pub recovery_email: Option<String>,
29 #[serde(skip_serializing_if = "Option::is_none")]
30 pub recovery_phone: Option<String>,
31 #[serde(skip_serializing_if = "Option::is_none")]
32 pub gender: Option<String>,
33
34 #[serde(skip_serializing_if = "Option::is_none")]
35 pub chat: Option<String>,
36 #[serde(skip_serializing_if = "Option::is_none")]
37 pub github: Option<String>,
38 #[serde(skip_serializing_if = "Option::is_none")]
39 pub twitter: Option<String>,
40
41 #[serde(skip_serializing_if = "Option::is_none")]
42 pub groups: Option<Vec<String>>,
43
44 #[serde(skip_serializing_if = "Option::is_none")]
45 pub is_super_admin: Option<bool>,
46
47 #[serde(skip_serializing_if = "Option::is_none")]
48 pub building: Option<String>,
49}
50
51/// The data type for a group. This applies to Google Groups.
52#[derive(Debug, Clone, Deserialize, Serialize)]
53pub struct GroupConfig {
54 pub name: String,
55 pub description: String,
56
57 #[serde(skip_serializing_if = "Option::is_none")]
58 pub aliases: Option<Vec<String>>,
59
60 /// allow_external_members: Identifies whether members external to your
61 /// organization can join the group. Possible values are:
62 /// - true: G Suite users external to your organization can become
63 /// members of this group.
64 /// - false: Users not belonging to the organization are not allowed to
65 /// become members of this group.
66 pub allow_external_members: bool,
67
68 /// allow_web_posting: Allows posting from web. Possible values are:
69 /// - true: Allows any member to post to the group forum.
70 /// - false: Members only use Gmail to communicate with the group.
71 pub allow_web_posting: bool,
72
73 /// is_archived: Allows the Group contents to be archived. Possible values
74 /// are:
75 /// - true: Archive messages sent to the group.
76 /// - false: Do not keep an archive of messages sent to this group. If
77 /// false, previously archived messages remain in the archive.
78 pub is_archived: bool,
79
80 /// who_can_discover_group: Specifies the set of users for whom this group
81 /// is discoverable. Possible values are:
82 /// - ANYONE_CAN_DISCOVER
83 /// - ALL_IN_DOMAIN_CAN_DISCOVER
84 /// - ALL_MEMBERS_CAN_DISCOVER
85 pub who_can_discover_group: String,
86
87 /// who_can_join: Permission to join group. Possible values are:
88 /// - ANYONE_CAN_JOIN: Anyone in the account domain can join. This
89 /// includes accounts with multiple domains.
90 /// - ALL_IN_DOMAIN_CAN_JOIN: Any Internet user who is outside your
91 /// domain can access your Google Groups service and view the list of
92 /// groups in your Groups directory. Warning: Group owners can add
93 /// external addresses, outside of the domain to their groups. They can
94 /// also allow people outside your domain to join their groups. If you
95 /// later disable this option, any external addresses already added to
96 /// users' groups remain in those groups.
97 /// - INVITED_CAN_JOIN: Candidates for membership can be invited to join.
98 ///
99 /// - CAN_REQUEST_TO_JOIN: Non members can request an invitation to join.
100 pub who_can_join: String,
101
102 /// who_can_moderate_members: Specifies who can manage members. Possible
103 /// values are:
104 /// - ALL_MEMBERS
105 /// - OWNERS_AND_MANAGERS
106 /// - OWNERS_ONLY
107 /// - NONE
108 pub who_can_moderate_members: String,
109
110 /// who_can_post_message: Permissions to post messages. Possible values are:
111 ///
112 /// - NONE_CAN_POST: The group is disabled and archived. No one can post
113 /// a message to this group.
114 /// - When archiveOnly is false, updating who_can_post_message to
115 /// NONE_CAN_POST, results in an error.
116 /// - If archiveOnly is reverted from true to false, who_can_post_messages
117 /// is set to ALL_MANAGERS_CAN_POST.
118 /// - ALL_MANAGERS_CAN_POST: Managers, including group owners, can post
119 /// messages.
120 /// - ALL_MEMBERS_CAN_POST: Any group member can post a message.
121 /// - ALL_OWNERS_CAN_POST: Only group owners can post a message.
122 /// - ALL_IN_DOMAIN_CAN_POST: Anyone in the account can post a message.
123 ///
124 /// - ANYONE_CAN_POST: Any Internet user who outside your account can
125 /// access your Google Groups service and post a message. Note: When
126 /// who_can_post_message is set to ANYONE_CAN_POST, we recommend the
127 /// messageModerationLevel be set to MODERATE_NON_MEMBERS to protect the
128 /// group from possible spam.
129 pub who_can_post_message: String,
130
131 /// who_can_view_group: Permissions to view group messages. Possible values
132 /// are:
133 /// - ANYONE_CAN_VIEW: Any Internet user can view the group's messages.
134 ///
135 /// - ALL_IN_DOMAIN_CAN_VIEW: Anyone in your account can view this
136 /// group's messages.
137 /// - ALL_MEMBERS_CAN_VIEW: All group members can view the group's
138 /// messages.
139 /// - ALL_MANAGERS_CAN_VIEW: Any group manager can view this group's
140 /// messages.
141 pub who_can_view_group: String,
142
143 /// who_can_view_membership: Permissions to view membership. Possible values
144 /// are:
145 /// - ALL_IN_DOMAIN_CAN_VIEW: Anyone in the account can view the group
146 /// members list.
147 /// If a group already has external members, those members can still send
148 /// email to this group.
149 ///
150 /// - ALL_MEMBERS_CAN_VIEW: The group members can view the group members
151 /// list.
152 /// - ALL_MANAGERS_CAN_VIEW: The group managers can view group members
153 /// list.
154 pub who_can_view_membership: String,
155}
156
157/// The data type for a building.
158#[derive(Debug, Clone, Deserialize, Serialize)]
159pub struct BuildingConfig {
160 pub name: String,
161 pub description: String,
162 pub address: String,
163 pub city: String,
164 pub state: String,
165 pub zipcode: String,
166 pub country: String,
167 pub floors: Vec<String>,
168}
169
170/// The data type for a resource. These are conference rooms that people can book
171/// through GSuite or Zoom.
172#[derive(Debug, Clone, Deserialize, Serialize)]
173pub struct ResourceConfig {
174 pub name: String,
175 pub description: String,
176 #[serde(rename = "type")]
177 pub typev: String,
178 pub building: String,
179 pub capacity: i32,
180 pub floor: String,
181 pub section: String,
182
183 #[serde(skip_serializing_if = "Option::is_none")]
184 pub is_zoom_room: Option<bool>,
185}
186
187/// The data type for a link. These get turned into short links like
188/// `{name}.corp.oxide.compuer` by the `shorturls` subcommand.
189#[derive(Debug, Clone, Deserialize, Serialize)]
190pub struct LinkConfig {
191 /// name will not be used in config files.
192 #[serde(skip_serializing_if = "Option::is_none")]
193 pub name: Option<String>,
194 pub description: String,
195 pub link: String,
196 #[serde(skip_serializing_if = "Option::is_none")]
197 pub aliases: Option<Vec<String>>,
198 /// subdomain will not be used in config files.
199 #[serde(skip_serializing_if = "Option::is_none")]
200 pub subdomain: Option<String>,
201 /// discussion will not be used in config files.
202 #[serde(skip_serializing_if = "Option::is_none")]
203 pub discussion: Option<String>,
204}
205
206/// The data type for a label. These become GitHub labels for all the repositories
207/// in our organization.
208#[derive(Debug, Clone, Deserialize, Serialize)]
209pub struct LabelConfig {
210 pub name: String,
211 pub description: String,
212 pub color: String,
213}