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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
use std::fmt;
use serde::{Serialize, Deserialize};
/// Capabilities the current user has on a file.
///
/// Each capability corresponds to a fine-grained action that a user may take.
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct FileCapabilities {
/// Whether the current user can move children of this folder outside of the
/// shared drive.
///
/// This is false when the item is not a folder. Only populated for items
/// in shared drives.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_move_children_out_of_drive: Option<bool>,
/// Whether the current user can read the shared drive to which this file
/// belongs.
///
/// Only populated for items in shared drives.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_read_drive: Option<bool>,
/// Whether the current user can edit this file.
///
/// Other factors may limit the type of changes a user can make to a file.
/// For example, see
/// [`can_change_copy_requires_writer_permission`](FileCapabilities::can_change_copy_requires_writer_permission)
/// or [`can_modify_content`](FileCapabilities::can_modify_content).
#[serde(skip_serializing_if = "Option::is_none")]
pub can_edit: Option<bool>,
/// Whether the current user can copy this file.
///
/// For an item in a shared drive, whether the current user can copy
/// non-folder descendants of this item, or this item itself if it is not a
/// folder.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_copy: Option<bool>,
/// Whether the current user can comment on this file.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_comment: Option<bool>,
/// Whether the current user can add children to this folder.
///
/// This is always false when the item is not a folder.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_add_children: Option<bool>,
/// Whether the current user can delete this file.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_delete: Option<bool>,
/// Whether the current user can download this file.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_download: Option<bool>,
/// Whether the current user can list the children of this folder.
///
/// This is always false when the item is not a folder.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_list_children: Option<bool>,
/// Whether the current user can remove children from this folder.
///
/// This is always false when the item is not a folder. For a folder in a
/// shared drive, use
/// [`can_delete_children`](FileCapabilities::can_delete_children) or
/// [`can_trash_children`](FileCapabilities::can_trash_children) instead.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_remove_children: Option<bool>,
/// Whether the current user can rename this file.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_rename: Option<bool>,
/// Whether the current user can move this file to trash.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_trash: Option<bool>,
/// Whether the current user can read the revisions resource of this file.
///
/// For a shared drive item, whether revisions of non-folder descendants of
/// this item, or this item itself if it is not a folder, can be read.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_read_revisions: Option<bool>,
/// Whether the current user can change the
/// [`copy_requires_writer_permission`](super::File::copy_requires_writer_permission)
/// restriction of this file.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_change_copy_requires_writer_permission: Option<bool>,
/// Whether the current user can restore this file from trash.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_untrash: Option<bool>,
/// Whether the current user can modify the content of this file.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_modify_content: Option<bool>,
/// Whether the current user can delete children of this folder.
///
/// This is false when the item is not a folder. Only populated for items in
/// shared drives.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_delete_children: Option<bool>,
/// Whether the current user can trash children of this folder.
///
/// This is false when the item is not a folder. Only populated for items in
/// shared drives.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_trash_children: Option<bool>,
/// Whether the current user can move this item outside of this drive by
/// changing its parent.
///
/// Note that a request to change the parent of the item may still fail
/// depending on the new parent that is being added.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_move_item_out_of_drive: Option<bool>,
/// Whether the current user can add a parent for the item without removing
/// an existing parent in the same request.
///
/// Not populated for shared drive files.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_add_my_drive_parent: Option<bool>,
/// Whether the current user can move this item within this drive.
///
/// Note that a request to change the parent of the item may still fail
/// depending on the new parent that is being added and the parent that is
/// being removed.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_move_item_within_drive: Option<bool>,
/// Whether the current user can modify the sharing settings for this file.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_share: Option<bool>,
/// Whether the current user can move children of this folder within this
/// drive.
///
/// This is false when the item is not a folder. Note that a request to move
/// the child may still fail depending on the current user's access to the
/// child and to the destination folder.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_move_children_within_drive: Option<bool>,
/// Whether the current user can add a folder from another drive (different
/// shared drive or My Drive) to this folder.
///
/// This is false when the item is not a folder. Only populated for items in
/// shared drives.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_add_folder_from_another_drive: Option<bool>,
/// Whether the current user can change the
/// [`security_update_enabled`](super::LinkShareMetadata::security_update_enabled)
/// field on link share metadata.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_change_security_update_enabled: Option<bool>,
/// Whether the current user is the pending owner of the file.
///
/// Not populated for shared drive files.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_accept_ownership: Option<bool>,
/// Whether the current user can read the labels on the file.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_read_labels: Option<bool>,
/// Whether the current user can modify the labels on the file.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_modify_labels: Option<bool>,
/// Whether the current user can add or modify content restrictions on the
/// file which are editor restricted.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_modify_editor_content_restriction: Option<bool>,
/// Whether the current user can add or modify content restrictions which
/// are owner restricted.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_modify_owner_content_restriction: Option<bool>,
/// Whether there is a content restriction on the file that can be removed
/// by the current user.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_remove_content_restriction: Option<bool>,
}
impl fmt::Display for FileCapabilities {
fn fmt( &self, f: &mut fmt::Formatter<'_> ) -> fmt::Result {
let json = serde_json::to_string_pretty(&self)
.unwrap_or( format!("unable to parse JSON, this is the debug view:\n{:#?}", self) );
write!(f, "{}", json)
}
}
impl FileCapabilities {
/// Creates a new, empty instance of this struct.
pub fn new() -> Self {
Self { ..Default::default() }
}
}
/// Capabilities the current user has on a shared drive.
///
/// Each capability corresponds to a fine-grained action that a user may take.
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DriveCapabilities {
/// Whether the current user can add children to folders in this shared
/// drive.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_add_children: Option<bool>,
/// Whether the current user can comment on files in this shared drive.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_comment: Option<bool>,
/// Whether the current user can copy files in this shared drive.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_copy: Option<bool>,
/// Whether the current user can delete this shared drive.
///
/// Attempting to delete the shared drive may still fail if there are
/// untrashed items inside the shared drive.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_delete_drive: Option<bool>,
/// Whether the current user can download files in this shared drive.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_download: Option<bool>,
/// Whether the current user can edit files in this shared drive
#[serde(skip_serializing_if = "Option::is_none")]
pub can_edit: Option<bool>,
/// Whether the current user can list the children of folders in this shared
/// drive.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_list_children: Option<bool>,
/// Whether the current user can add members to this shared drive or remove
/// them or change their role.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_manage_members: Option<bool>,
/// Whether the current user can read the revisions resource of files in
/// this shared drive.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_read_revisions: Option<bool>,
/// Whether the current user can rename files or folders in this shared
/// drive.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_rename: Option<bool>,
/// Whether the current user can rename this shared drive.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_rename_drive: Option<bool>,
/// Whether the current user can change the background of this shared drive.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_change_drive_background: Option<bool>,
/// Whether the current user can share files or folders in this shared
/// drive.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_share: Option<bool>,
/// Whether the current user can change the `copyRequiresWriterPermission`
/// restriction of this shared drive.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_change_copy_requires_writer_permission_restriction: Option<bool>,
/// Whether the current user can change the `domainUsersOnly` restriction
/// of this shared drive.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_change_domain_users_only_restriction: Option<bool>,
/// Whether the current user can change the driveMembersOnly restriction of
/// this shared drive.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_change_drive_members_only_restriction: Option<bool>,
/// Whether the current user can change the
/// `sharingFoldersRequiresOrganizerPermission` restriction of this shared
/// drive.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_change_sharing_folders_requires_organizer_permission_restriction: Option<bool>,
/// Whether the current user can reset the shared drive restrictions to
/// defaults.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_reset_drive_restrictions: Option<bool>,
/// Whether the current user can delete children from folders in this shared
/// drive.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_delete_children: Option<bool>,
/// Whether the current user can trash children from folders in this shared
/// drive.
#[serde(skip_serializing_if = "Option::is_none")]
pub can_trash_children: Option<bool>,
}
impl fmt::Display for DriveCapabilities {
fn fmt( &self, f: &mut fmt::Formatter<'_> ) -> fmt::Result {
let json = serde_json::to_string_pretty(&self)
.unwrap_or( format!("unable to parse JSON, this is the debug view:\n{:#?}", self) );
write!(f, "{}", json)
}
}
impl DriveCapabilities {
/// Creates a new, empty instance of this struct.
pub fn new() -> Self {
Self { ..Default::default() }
}
}