Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mxrch
GitHub Repository: mxrch/GHunt
Path: blob/master/ghunt/parsers/drive.py
252 views
1
from typing import *
2
from datetime import datetime
3
4
from ghunt.helpers.utils import get_datetime_utc
5
from ghunt.objects.apis import Parser
6
7
8
class DriveFile(Parser):
9
def __init__(self):
10
self.kind: str = ""
11
self.id: str = ""
12
self.thumbnail_version: str = ""
13
self.title: str = ""
14
self.mime_type: str = ""
15
self.labels: DriveLabels = DriveLabels()
16
self.created_date: datetime = None
17
self.modified_date: datetime = None
18
self.last_viewed_by_me_date: datetime = None
19
self.marked_viewed_by_me_date: datetime = None
20
self.shared_with_me_date: datetime = None
21
self.recency: datetime = None
22
self.recency_reason: str = ""
23
self.version: str = ""
24
self.parents: List[DriveParentReference] = []
25
self.user_permission: DrivePermission = DrivePermission()
26
self.file_extension: str = ""
27
self.file_size: str = ""
28
self.quota_bytes_used: str = ""
29
self.owners: List[DriveUser] = []
30
self.last_modifying_user: DriveUser = DriveUser()
31
self.capabilities: DriveCapabilities = DriveCapabilities()
32
self.copyable: bool = False
33
self.shared: bool = False
34
self.explicitly_trashed: bool = False
35
self.authorized_app_ids: List[str] = []
36
self.primary_sync_parent_id: str = ""
37
self.subscribed: bool = False
38
self.passively_subscribed: bool = False
39
self.flagged_for_abuse: bool = False
40
self.abuse_is_appealable: bool = False
41
self.source_app_id: str = ""
42
self.spaces: List[str] = []
43
self.has_thumbnail: bool = False
44
self.contains_unsubscribed_children: bool = False
45
self.alternate_link: str = ""
46
self.icon_link: str = ""
47
self.copy_requires_writer_permission: bool = False
48
self.permissions: List[DrivePermission] = []
49
self.head_revision_id: str = ""
50
self.video_media_metadata: DriveVideoMediaMetadata = DriveVideoMediaMetadata()
51
self.has_legacy_blob_comments: bool = False
52
self.label_info: DriveLabelInfo = DriveLabelInfo()
53
self.web_content_link: str = ""
54
self.thumbnail_link: str = ""
55
self.description: str = ""
56
self.original_filename: str = ""
57
self.permissions_summary: DrivePermissionsSummary = DrivePermissionsSummary()
58
self.full_file_extension: str = ""
59
self.md5_checksum: str = ""
60
self.owned_by_me: bool = False
61
self.writers_can_share: bool = False
62
self.image_media_metadata: DriveImageMediaMetadata = DriveImageMediaMetadata()
63
self.is_app_authorized: bool = False
64
self.link_share_metadata: DriveLinkShareMetadata = DriveLinkShareMetadata()
65
self.etag: str = ""
66
self.self_link: str = ""
67
self.embed_link: str = ""
68
self.open_with_links: DriveOpenWithLinks = DriveOpenWithLinks()
69
self.default_open_with_link: str = ""
70
self.has_child_folders: bool = False
71
self.owner_names: List[str] = []
72
self.last_modifying_user_name: str = ""
73
self.editable: bool = False
74
self.app_data_contents: bool = False
75
self.drive_source: DriveSource = DriveSource()
76
self.source: DriveSource = DriveSource()
77
self.descendant_of_root: bool = False
78
self.folder_color: str = ""
79
self.folder_properties: DriveFolderProperties = DriveFolderProperties()
80
self.resource_key: str = ""
81
self.has_augmented_permissions: bool = False
82
self.ancestor_has_augmented_permissions: bool = False
83
self.has_visitor_permissions: bool = False
84
self.primary_domain_name: str = ""
85
self.organization_display_name: str = ""
86
self.customer_id: str = ""
87
self.team_drive_id: str = ""
88
self.folder_color_rgb: str = ""
89
90
def _scrape(self, file_data: Dict[str, any]):
91
self.kind = file_data.get('kind')
92
self.id = file_data.get('id')
93
self.thumbnail_version = file_data.get('thumbnailVersion')
94
self.title = file_data.get('title')
95
self.mime_type = file_data.get('mimeType')
96
if (labels_data := file_data.get('labels')):
97
self.labels._scrape(labels_data)
98
if (isodate := file_data.get("createdDate")):
99
self.created_date = get_datetime_utc(isodate)
100
if (isodate := file_data.get("modifiedDate")):
101
self.modified_date = get_datetime_utc(isodate)
102
if (isodate := file_data.get("lastViewedByMeDate")):
103
self.last_viewed_by_me_date = get_datetime_utc(isodate)
104
if (isodate := file_data.get("markedViewedByMeDate")):
105
self.marked_viewed_by_me_date = get_datetime_utc(isodate)
106
if (isodate := file_data.get("sharedWithMeDate")):
107
self.shared_with_me_date = get_datetime_utc(isodate)
108
if (isodate := file_data.get("recency")):
109
self.recency = get_datetime_utc(isodate)
110
self.recency_reason = file_data.get('recencyReason')
111
self.version = file_data.get('version')
112
if (parents_data := file_data.get('parents')):
113
for parents_data_item in parents_data:
114
parents_item = DriveParentReference()
115
parents_item._scrape(parents_data_item)
116
self.parents.append(parents_item)
117
if (user_permission_data := file_data.get('userPermission')):
118
self.user_permission._scrape(user_permission_data)
119
self.file_extension = file_data.get('fileExtension')
120
self.file_size = file_data.get('fileSize')
121
self.quota_bytes_used = file_data.get('quotaBytesUsed')
122
if (owners_data := file_data.get('owners')):
123
for owners_data_item in owners_data:
124
owners_item = DriveUser()
125
owners_item._scrape(owners_data_item)
126
self.owners.append(owners_item)
127
if (last_modifying_user_data := file_data.get('lastModifyingUser')):
128
self.last_modifying_user._scrape(last_modifying_user_data)
129
if (capabilities_data := file_data.get('capabilities')):
130
self.capabilities._scrape(capabilities_data)
131
self.copyable = file_data.get('copyable')
132
self.shared = file_data.get('shared')
133
self.explicitly_trashed = file_data.get('explicitlyTrashed')
134
self.authorized_app_ids = file_data.get('authorizedAppIds')
135
self.primary_sync_parent_id = file_data.get('primarySyncParentId')
136
self.subscribed = file_data.get('subscribed')
137
self.passively_subscribed = file_data.get('passivelySubscribed')
138
self.flagged_for_abuse = file_data.get('flaggedForAbuse')
139
self.abuse_is_appealable = file_data.get('abuseIsAppealable')
140
self.source_app_id = file_data.get('sourceAppId')
141
self.spaces = file_data.get('spaces')
142
self.has_thumbnail = file_data.get('hasThumbnail')
143
self.contains_unsubscribed_children = file_data.get('containsUnsubscribedChildren')
144
self.alternate_link = file_data.get('alternateLink')
145
self.icon_link = file_data.get('iconLink')
146
self.copy_requires_writer_permission = file_data.get('copyRequiresWriterPermission')
147
if (permissions_data := file_data.get('permissions')):
148
for permissions_data_item in permissions_data:
149
permissions_item = DrivePermission()
150
permissions_item._scrape(permissions_data_item)
151
self.permissions.append(permissions_item)
152
self.head_revision_id = file_data.get('headRevisionId')
153
if (video_media_metadata_data := file_data.get('videoMediaMetadata')):
154
self.video_media_metadata._scrape(video_media_metadata_data)
155
self.has_legacy_blob_comments = file_data.get('hasLegacyBlobComments')
156
if (label_info_data := file_data.get('labelInfo')):
157
self.label_info._scrape(label_info_data)
158
self.web_content_link = file_data.get('webContentLink')
159
self.thumbnail_link = file_data.get('thumbnailLink')
160
self.description = file_data.get('description')
161
self.original_filename = file_data.get('originalFilename')
162
if (permissions_summary_data := file_data.get('permissionsSummary')):
163
self.permissions_summary._scrape(permissions_summary_data)
164
self.full_file_extension = file_data.get('fullFileExtension')
165
self.md5_checksum = file_data.get('md5Checksum')
166
self.owned_by_me = file_data.get('ownedByMe')
167
self.writers_can_share = file_data.get('writersCanShare')
168
if (image_media_metadata_data := file_data.get('imageMediaMetadata')):
169
self.image_media_metadata._scrape(image_media_metadata_data)
170
self.is_app_authorized = file_data.get('isAppAuthorized')
171
if (link_share_metadata_data := file_data.get('linkShareMetadata')):
172
self.link_share_metadata._scrape(link_share_metadata_data)
173
self.etag = file_data.get('etag')
174
self.self_link = file_data.get('selfLink')
175
self.embed_link = file_data.get('embedLink')
176
if (open_with_links_data := file_data.get('openWithLinks')):
177
self.open_with_links._scrape(open_with_links_data)
178
self.default_open_with_link = file_data.get('defaultOpenWithLink')
179
self.has_child_folders = file_data.get('hasChildFolders')
180
self.owner_names = file_data.get('ownerNames')
181
self.last_modifying_user_name = file_data.get('lastModifyingUserName')
182
self.editable = file_data.get('editable')
183
self.app_data_contents = file_data.get('appDataContents')
184
if (drive_source_data := file_data.get('driveSource')):
185
self.drive_source._scrape(drive_source_data)
186
if (source_data := file_data.get('source')):
187
self.source._scrape(source_data)
188
self.descendant_of_root = file_data.get('descendantOfRoot')
189
self.folder_color = file_data.get('folderColor')
190
if (folder_properties_data := file_data.get('folderProperties')):
191
self.folder_properties._scrape(folder_properties_data)
192
self.resource_key = file_data.get('resourceKey')
193
self.has_augmented_permissions = file_data.get('hasAugmentedPermissions')
194
self.ancestor_has_augmented_permissions = file_data.get('ancestorHasAugmentedPermissions')
195
self.has_visitor_permissions = file_data.get('hasVisitorPermissions')
196
self.primary_domain_name = file_data.get('primaryDomainName')
197
self.organization_display_name = file_data.get('organizationDisplayName')
198
self.customer_id = file_data.get('customerId')
199
self.team_drive_id = file_data.get('teamDriveId')
200
self.folder_color_rgb = file_data.get('folderColorRgb')
201
202
class DriveLabels(Parser):
203
def __init__(self):
204
self.starred: bool = False
205
self.trashed: bool = False
206
self.restricted: bool = False
207
self.viewed: bool = False
208
self.hidden: bool = False
209
self.modified: bool = False
210
211
def _scrape(self, labels_data: Dict[str, bool]):
212
self.starred = labels_data.get('starred')
213
self.trashed = labels_data.get('trashed')
214
self.restricted = labels_data.get('restricted')
215
self.viewed = labels_data.get('viewed')
216
self.hidden = labels_data.get('hidden')
217
self.modified = labels_data.get('modified')
218
219
class DriveUserPermission(Parser):
220
def __init__(self):
221
self.role: str = ""
222
self.id: str = ""
223
self.type: str = ""
224
225
def _scrape(self, user_permission_data: Dict[str, str]):
226
self.role = user_permission_data.get('role')
227
self.id = user_permission_data.get('id')
228
self.type = user_permission_data.get('type')
229
230
class DriveUser(Parser):
231
def __init__(self):
232
self.kind: str = ""
233
self.id: str = ""
234
self.permission_id: str = ""
235
self.email_address_from_account: str = ""
236
self.display_name: str = ""
237
self.picture: DrivePicture = DrivePicture()
238
self.is_authenticated_user: bool = False
239
self.email_address: str = ""
240
241
def _scrape(self, user_data: Dict[str, any]):
242
self.kind = user_data.get('kind')
243
self.id = user_data.get('id')
244
self.permission_id = user_data.get('permissionId')
245
self.email_address_from_account = user_data.get('emailAddressFromAccount')
246
self.display_name = user_data.get('displayName')
247
if (picture_data := user_data.get('picture')):
248
self.picture._scrape(picture_data)
249
self.is_authenticated_user = user_data.get('isAuthenticatedUser')
250
self.email_address = user_data.get('emailAddress')
251
252
class DriveCapabilities(Parser):
253
def __init__(self):
254
self.can_add_children: bool = False
255
self.can_add_my_drive_parent: bool = False
256
self.can_block_owner: bool = False
257
self.can_change_security_update_enabled: bool = False
258
self.can_copy: bool = False
259
self.can_delete: bool = False
260
self.can_download: bool = False
261
self.can_edit: bool = False
262
self.can_edit_category_metadata: bool = False
263
self.can_request_approval: bool = False
264
self.can_move_children_within_drive: bool = False
265
self.can_move_item_into_team_drive: bool = False
266
self.can_move_item_within_drive: bool = False
267
self.can_read: bool = False
268
self.can_read_category_metadata: bool = False
269
self.can_remove_children: bool = False
270
self.can_remove_my_drive_parent: bool = False
271
self.can_rename: bool = False
272
self.can_share: bool = False
273
self.can_share_child_files: bool = False
274
self.can_share_child_folders: bool = False
275
self.can_trash: bool = False
276
self.can_untrash: bool = False
277
self.can_comment: bool = False
278
self.can_move_item_out_of_drive: bool = False
279
self.can_add_as_owner: bool = False
280
self.can_add_as_organizer: bool = False
281
self.can_add_as_file_organizer: bool = False
282
self.can_add_as_writer: bool = False
283
self.can_add_as_commenter: bool = False
284
self.can_add_as_reader: bool = False
285
self.can_change_to_owner: bool = False
286
self.can_change_to_organizer: bool = False
287
self.can_change_to_file_organizer: bool = False
288
self.can_change_to_writer: bool = False
289
self.can_change_to_commenter: bool = False
290
self.can_change_to_reader: bool = False
291
self.can_change_to_reader_on_published_view: bool = False
292
self.can_remove: bool = False
293
self.can_accept_ownership: bool = False
294
self.can_add_encrypted_children: bool = False
295
self.can_change_copy_requires_writer_permission: bool = False
296
self.can_change_permission_expiration: bool = False
297
self.can_change_restricted_download: bool = False
298
self.can_change_writers_can_share: bool = False
299
self.can_create_decrypted_copy: bool = False
300
self.can_create_encrypted_copy: bool = False
301
self.can_list_children: bool = False
302
self.can_manage_members: bool = False
303
self.can_manage_visitors: bool = False
304
self.can_modify_content: bool = False
305
self.can_modify_content_restriction: bool = False
306
self.can_modify_labels: bool = False
307
self.can_print: bool = False
308
self.can_read_all_permissions: bool = False
309
self.can_read_labels: bool = False
310
self.can_read_revisions: bool = False
311
self.can_set_missing_required_fields: bool = False
312
self.can_share_as_commenter: bool = False
313
self.can_share_as_file_organizer: bool = False
314
self.can_share_as_organizer: bool = False
315
self.can_share_as_owner: bool = False
316
self.can_share_as_reader: bool = False
317
self.can_share_as_writer: bool = False
318
self.can_share_published_view_as_reader: bool = False
319
self.can_share_to_all_users: bool = False
320
self.can_add_folder_from_another_drive: bool = False
321
self.can_delete_children: bool = False
322
self.can_move_item_out_of_team_drive: bool = False
323
self.can_move_item_within_team_drive: bool = False
324
self.can_move_team_drive_item: bool = False
325
self.can_read_team_drive: bool = False
326
self.can_trash_children: bool = False
327
328
def _scrape(self, capabilities_data: Dict[str, bool]):
329
self.can_add_children = capabilities_data.get('canAddChildren')
330
self.can_add_my_drive_parent = capabilities_data.get('canAddMyDriveParent')
331
self.can_block_owner = capabilities_data.get('canBlockOwner')
332
self.can_change_security_update_enabled = capabilities_data.get('canChangeSecurityUpdateEnabled')
333
self.can_copy = capabilities_data.get('canCopy')
334
self.can_delete = capabilities_data.get('canDelete')
335
self.can_download = capabilities_data.get('canDownload')
336
self.can_edit = capabilities_data.get('canEdit')
337
self.can_edit_category_metadata = capabilities_data.get('canEditCategoryMetadata')
338
self.can_request_approval = capabilities_data.get('canRequestApproval')
339
self.can_move_children_within_drive = capabilities_data.get('canMoveChildrenWithinDrive')
340
self.can_move_item_into_team_drive = capabilities_data.get('canMoveItemIntoTeamDrive')
341
self.can_move_item_within_drive = capabilities_data.get('canMoveItemWithinDrive')
342
self.can_read = capabilities_data.get('canRead')
343
self.can_read_category_metadata = capabilities_data.get('canReadCategoryMetadata')
344
self.can_remove_children = capabilities_data.get('canRemoveChildren')
345
self.can_remove_my_drive_parent = capabilities_data.get('canRemoveMyDriveParent')
346
self.can_rename = capabilities_data.get('canRename')
347
self.can_share = capabilities_data.get('canShare')
348
self.can_share_child_files = capabilities_data.get('canShareChildFiles')
349
self.can_share_child_folders = capabilities_data.get('canShareChildFolders')
350
self.can_trash = capabilities_data.get('canTrash')
351
self.can_untrash = capabilities_data.get('canUntrash')
352
self.can_comment = capabilities_data.get('canComment')
353
self.can_move_item_out_of_drive = capabilities_data.get('canMoveItemOutOfDrive')
354
self.can_add_as_owner = capabilities_data.get('canAddAsOwner')
355
self.can_add_as_organizer = capabilities_data.get('canAddAsOrganizer')
356
self.can_add_as_file_organizer = capabilities_data.get('canAddAsFileOrganizer')
357
self.can_add_as_writer = capabilities_data.get('canAddAsWriter')
358
self.can_add_as_commenter = capabilities_data.get('canAddAsCommenter')
359
self.can_add_as_reader = capabilities_data.get('canAddAsReader')
360
self.can_change_to_owner = capabilities_data.get('canChangeToOwner')
361
self.can_change_to_organizer = capabilities_data.get('canChangeToOrganizer')
362
self.can_change_to_file_organizer = capabilities_data.get('canChangeToFileOrganizer')
363
self.can_change_to_writer = capabilities_data.get('canChangeToWriter')
364
self.can_change_to_commenter = capabilities_data.get('canChangeToCommenter')
365
self.can_change_to_reader = capabilities_data.get('canChangeToReader')
366
self.can_change_to_reader_on_published_view = capabilities_data.get('canChangeToReaderOnPublishedView')
367
self.can_remove = capabilities_data.get('canRemove')
368
self.can_accept_ownership = capabilities_data.get('canAcceptOwnership')
369
self.can_add_encrypted_children = capabilities_data.get('canAddEncryptedChildren')
370
self.can_change_copy_requires_writer_permission = capabilities_data.get('canChangeCopyRequiresWriterPermission')
371
self.can_change_permission_expiration = capabilities_data.get('canChangePermissionExpiration')
372
self.can_change_restricted_download = capabilities_data.get('canChangeRestrictedDownload')
373
self.can_change_writers_can_share = capabilities_data.get('canChangeWritersCanShare')
374
self.can_create_decrypted_copy = capabilities_data.get('canCreateDecryptedCopy')
375
self.can_create_encrypted_copy = capabilities_data.get('canCreateEncryptedCopy')
376
self.can_list_children = capabilities_data.get('canListChildren')
377
self.can_manage_members = capabilities_data.get('canManageMembers')
378
self.can_manage_visitors = capabilities_data.get('canManageVisitors')
379
self.can_modify_content = capabilities_data.get('canModifyContent')
380
self.can_modify_content_restriction = capabilities_data.get('canModifyContentRestriction')
381
self.can_modify_labels = capabilities_data.get('canModifyLabels')
382
self.can_print = capabilities_data.get('canPrint')
383
self.can_read_all_permissions = capabilities_data.get('canReadAllPermissions')
384
self.can_read_labels = capabilities_data.get('canReadLabels')
385
self.can_read_revisions = capabilities_data.get('canReadRevisions')
386
self.can_set_missing_required_fields = capabilities_data.get('canSetMissingRequiredFields')
387
self.can_share_as_commenter = capabilities_data.get('canShareAsCommenter')
388
self.can_share_as_file_organizer = capabilities_data.get('canShareAsFileOrganizer')
389
self.can_share_as_organizer = capabilities_data.get('canShareAsOrganizer')
390
self.can_share_as_owner = capabilities_data.get('canShareAsOwner')
391
self.can_share_as_reader = capabilities_data.get('canShareAsReader')
392
self.can_share_as_writer = capabilities_data.get('canShareAsWriter')
393
self.can_share_published_view_as_reader = capabilities_data.get('canSharePublishedViewAsReader')
394
self.can_share_to_all_users = capabilities_data.get('canShareToAllUsers')
395
self.can_add_folder_from_another_drive = capabilities_data.get('canAddFolderFromAnotherDrive')
396
self.can_delete_children = capabilities_data.get('canDeleteChildren')
397
self.can_move_item_out_of_team_drive = capabilities_data.get('canMoveItemOutOfTeamDrive')
398
self.can_move_item_within_team_drive = capabilities_data.get('canMoveItemWithinTeamDrive')
399
self.can_move_team_drive_item = capabilities_data.get('canMoveTeamDriveItem')
400
self.can_read_team_drive = capabilities_data.get('canReadTeamDrive')
401
self.can_trash_children = capabilities_data.get('canTrashChildren')
402
403
class DriveVideoMediaMetadata(Parser):
404
def __init__(self):
405
self.width: int = 0
406
self.height: int = 0
407
self.duration_millis: str = ""
408
409
def _scrape(self, video_media_metadata_data: Dict[str, any]):
410
self.width = video_media_metadata_data.get('width')
411
self.height = video_media_metadata_data.get('height')
412
self.duration_millis = video_media_metadata_data.get('durationMillis')
413
414
class DriveLabelInfo(Parser):
415
def __init__(self):
416
self.label_count: int = 0
417
self.incomplete: bool = False
418
419
def _scrape(self, label_info_data: Dict[str, any]):
420
self.label_count = label_info_data.get('labelCount')
421
self.incomplete = label_info_data.get('incomplete')
422
423
class DrivePermission(Parser):
424
def __init__(self):
425
self.kind: str = ""
426
self.id: str = ""
427
self.self_link: str = ""
428
self.role: str = ""
429
self.additional_roles: List[str] = []
430
self.type: str = ""
431
self.selectable_roles: List[list] = []
432
self.pending_owner: bool = False
433
self.with_link: bool = False
434
self.capabilities: DriveCapabilities = DriveCapabilities()
435
self.user_id: str = ""
436
self.name: str = ""
437
self.email_address: str = ""
438
self.domain: str = ""
439
self.photo_link: str = ""
440
self.deleted: bool = False
441
self.is_collaborator_account: bool = False
442
443
def _scrape(self, permission_data: Dict[str, any]):
444
self.kind = permission_data.get('kind')
445
self.id = permission_data.get('id')
446
self.self_link = permission_data.get('selfLink')
447
self.role = permission_data.get('role')
448
self.additional_roles = permission_data.get('additionalRoles', [])
449
self.type = permission_data.get('type')
450
self.selectable_roles = permission_data.get('selectableRoles')
451
self.pending_owner = permission_data.get('pendingOwner')
452
self.with_link = permission_data.get('withLink')
453
if (capabilities_data := permission_data.get('capabilities')):
454
self.capabilities._scrape(capabilities_data)
455
self.user_id = permission_data.get('userId')
456
self.name = permission_data.get('name')
457
self.email_address = permission_data.get('emailAddress')
458
self.domain = permission_data.get('domain')
459
self.photo_link = permission_data.get('photoLink')
460
self.deleted = permission_data.get('deleted')
461
self.is_collaborator_account = permission_data.get('isCollaboratorAccount')
462
463
class DrivePermissionsSummary(Parser):
464
def __init__(self):
465
self.entry_count: int = 0
466
self.visibility: List[DriveMiniPermission] = []
467
self.select_permissions: List[DrivePermission] = []
468
469
def _scrape(self, permissions_summary_data: Dict[str, any]):
470
self.entry_count = permissions_summary_data.get('entryCount')
471
if (visibility_data := permissions_summary_data.get('visibility')):
472
for visibility_data_item in visibility_data:
473
visibility_item = DriveMiniPermission()
474
visibility_item._scrape(visibility_data_item)
475
self.visibility.append(visibility_item)
476
if (select_permissions_data := permissions_summary_data.get('selectPermissions')):
477
for select_permissions_data_item in select_permissions_data:
478
select_permissions_item = DrivePermission()
479
select_permissions_item._scrape(select_permissions_data_item)
480
self.select_permissions.append(select_permissions_item)
481
482
class DriveMiniPermission(Parser):
483
def __init__(self):
484
self.permission_id: str = ""
485
self.role: str = ""
486
self.type: str = ""
487
self.with_link: bool = False
488
489
def _scrape(self, unknown_model4_data: Dict[str, any]):
490
self.permission_id = unknown_model4_data.get('permissionId')
491
self.role = unknown_model4_data.get('role')
492
self.type = unknown_model4_data.get('type')
493
self.with_link = unknown_model4_data.get('withLink')
494
495
class DrivePicture(Parser):
496
def __init__(self):
497
self.url: str = ""
498
499
def _scrape(self, picture_data: Dict[str, str]):
500
self.url = picture_data.get('url')
501
502
class DriveImageMediaMetadata(Parser):
503
def __init__(self):
504
self.width: int = 0
505
self.height: int = 0
506
self.rotation: int = 0
507
508
def _scrape(self, image_media_metadata_data: Dict[str, int]):
509
self.width = image_media_metadata_data.get('width')
510
self.height = image_media_metadata_data.get('height')
511
self.rotation = image_media_metadata_data.get('rotation')
512
513
class DriveLinkShareMetadata(Parser):
514
def __init__(self):
515
self.security_update_eligible: bool = False
516
self.security_update_enabled: bool = False
517
self.security_update_change_disabled_reason: str = ""
518
self.security_update_explicitly_set: bool = False
519
520
def _scrape(self, link_share_metadata_data: Dict[str, any]):
521
self.security_update_eligible = link_share_metadata_data.get('securityUpdateEligible')
522
self.security_update_enabled = link_share_metadata_data.get('securityUpdateEnabled')
523
self.security_update_change_disabled_reason = link_share_metadata_data.get('securityUpdateChangeDisabledReason')
524
self.security_update_explicitly_set = link_share_metadata_data.get('securityUpdateExplicitlySet')
525
526
class DriveChildList(Parser):
527
def __init__(self):
528
self.kind: str = ""
529
self.etag: str = ""
530
self.self_link: str = ""
531
self.items: List[DriveChildReference] = []
532
533
def _scrape(self, child_list_data: Dict[str, any]):
534
self.kind = child_list_data.get('kind')
535
self.etag = child_list_data.get('etag')
536
self.self_link = child_list_data.get('selfLink')
537
if (items_data := child_list_data.get('items')):
538
for items_data_item in items_data:
539
items_item = DriveChildReference()
540
items_item._scrape(items_data_item)
541
self.items.append(items_item)
542
543
class DriveChildReference(Parser):
544
def __init__(self):
545
self.id: str = ""
546
self.self_link: str = ""
547
self.kind: str = ""
548
self.child_link: str = ""
549
550
def _scrape(self, child_reference_data: Dict[str, str]):
551
self.id = child_reference_data.get('id')
552
self.self_link = child_reference_data.get('selfLink')
553
self.kind = child_reference_data.get('kind')
554
self.child_link = child_reference_data.get('childLink')
555
556
class DriveApp(Parser):
557
def __init__(self):
558
self.kind: str = ""
559
self.id: str = ""
560
self.name: str = ""
561
self.type: str = ""
562
self.short_description: str = ""
563
self.long_description: str = ""
564
self.supports_create: bool = False
565
self.supports_import: bool = False
566
self.supports_multi_open: bool = False
567
self.supports_offline_create: bool = False
568
self.supports_mobile_browser: bool = False
569
self.installed: bool = False
570
self.authorized: bool = False
571
self.drive_branded_app: bool = False
572
self.drive_branded: bool = False
573
self.hidden: bool = False
574
self.removable: bool = False
575
self.has_drive_wide_scope: bool = False
576
self.use_by_default: bool = False
577
self.primary_mime_types: List[str] = []
578
self.requires_authorization_before_open_with: bool = False
579
self.supports_team_drives: bool = False
580
self.supports_all_drives: bool = False
581
582
def _scrape(self, app_data: Dict[str, any]):
583
self.kind = app_data.get('kind')
584
self.id = app_data.get('id')
585
self.name = app_data.get('name')
586
self.type = app_data.get('type')
587
self.short_description = app_data.get('shortDescription')
588
self.long_description = app_data.get('longDescription')
589
self.supports_create = app_data.get('supportsCreate')
590
self.supports_import = app_data.get('supportsImport')
591
self.supports_multi_open = app_data.get('supportsMultiOpen')
592
self.supports_offline_create = app_data.get('supportsOfflineCreate')
593
self.supports_mobile_browser = app_data.get('supportsMobileBrowser')
594
self.installed = app_data.get('installed')
595
self.authorized = app_data.get('authorized')
596
self.drive_branded_app = app_data.get('driveBrandedApp')
597
self.drive_branded = app_data.get('driveBranded')
598
self.hidden = app_data.get('hidden')
599
self.removable = app_data.get('removable')
600
self.has_drive_wide_scope = app_data.get('hasDriveWideScope')
601
self.use_by_default = app_data.get('useByDefault')
602
self.primary_mime_types = app_data.get('primaryMimeTypes')
603
self.requires_authorization_before_open_with = app_data.get('requiresAuthorizationBeforeOpenWith')
604
self.supports_team_drives = app_data.get('supportsTeamDrives')
605
self.supports_all_drives = app_data.get('supportsAllDrives')
606
607
class DriveOpenWithLinks(Parser):
608
def __init__(self):
609
self.digitsfield: str = ""
610
611
def _scrape(self, open_with_links_data: Dict[str, str]):
612
self.digitsfield = open_with_links_data.get('digits_field')
613
614
class DriveParentReference(Parser):
615
def __init__(self):
616
self.kind: str = ""
617
self.id: str = ""
618
self.self_link: str = ""
619
self.parent_link: str = ""
620
self.is_root: bool = False
621
622
def _scrape(self, parent_reference_data: Dict[str, any]):
623
self.kind = parent_reference_data.get('kind')
624
self.id = parent_reference_data.get('id')
625
self.self_link = parent_reference_data.get('selfLink')
626
self.parent_link = parent_reference_data.get('parentLink')
627
self.is_root = parent_reference_data.get('isRoot')
628
629
class DriveSource(Parser):
630
def __init__(self):
631
self.client_service_id: str = ""
632
self.value: str = ""
633
634
def _scrape(self, source_data: Dict[str, str]):
635
self.client_service_id = source_data.get('clientServiceId')
636
self.value = source_data.get('value')
637
638
class DriveFolderProperties(Parser):
639
def __init__(self):
640
self.psyncho_root: bool = False
641
self.psyncho_folder: bool = False
642
self.machine_root: bool = False
643
self.arbitrary_sync_folder: bool = False
644
self.external_media: bool = False
645
self.photos_and_videos_only: bool = False
646
647
def _scrape(self, folder_properties_data: Dict[str, bool]):
648
self.psyncho_root = folder_properties_data.get('psynchoRoot')
649
self.psyncho_folder = folder_properties_data.get('psynchoFolder')
650
self.machine_root = folder_properties_data.get('machineRoot')
651
self.arbitrary_sync_folder = folder_properties_data.get('arbitrarySyncFolder')
652
self.external_media = folder_properties_data.get('externalMedia')
653
self.photos_and_videos_only = folder_properties_data.get('photosAndVideosOnly')
654
655
class DriveCommentList(Parser):
656
def __init__(self):
657
self.kind: str = ""
658
self.self_link: str = ""
659
self.items: List[DriveComment] = []
660
661
def _scrape(self, comment_list_data: Dict[str, any]):
662
self.kind = comment_list_data.get('kind')
663
self.self_link = comment_list_data.get('selfLink')
664
if (items_data := comment_list_data.get('items')):
665
for items_data_item in items_data:
666
items_item = DriveComment()
667
items_item._scrape(items_data_item)
668
self.items.append(items_item)
669
670
class DriveComment(Parser):
671
def __init__(self):
672
self.comment_id: str = ""
673
self.kind: str = ""
674
self.created_date: str = ""
675
self.modified_date: str = ""
676
self.file_id: str = ""
677
self.status: str = ""
678
self.anchor: str = ""
679
self.replies: List[DriveCommentReply] = []
680
self.author: DriveUser = DriveUser()
681
self.deleted: bool = False
682
self.html_content: str = ""
683
self.content: str = ""
684
self.context: DriveCommentContext = DriveCommentContext()
685
self.file_title: str = ""
686
687
def _scrape(self, comment_data: Dict[str, any]):
688
self.comment_id = comment_data.get('commentId')
689
self.kind = comment_data.get('kind')
690
self.created_date = comment_data.get('createdDate')
691
self.modified_date = comment_data.get('modifiedDate')
692
self.file_id = comment_data.get('fileId')
693
self.status = comment_data.get('status')
694
self.anchor = comment_data.get('anchor')
695
if (replies_data := comment_data.get('replies')):
696
for replies_data_item in replies_data:
697
replies_item = DriveCommentReply()
698
replies_item._scrape(replies_data_item)
699
self.replies.append(replies_item)
700
if (author_data := comment_data.get('author')):
701
self.author._scrape(author_data)
702
self.deleted = comment_data.get('deleted')
703
self.html_content = comment_data.get('htmlContent')
704
self.content = comment_data.get('content')
705
if (context_data := comment_data.get('context')):
706
self.context._scrape(context_data)
707
self.file_title = comment_data.get('fileTitle')
708
709
class DriveCommentContext(Parser):
710
def __init__(self):
711
self.type: str = ""
712
self.value: str = ""
713
714
def _scrape(self, context_data: Dict[str, str]):
715
self.type = context_data.get('type')
716
self.value = context_data.get('value')
717
718
class DriveCommentReply(Parser):
719
def __init__(self):
720
self.reply_id: str = ""
721
self.kind: str = ""
722
self.created_date: str = ""
723
self.modified_date: str = ""
724
self.author: DriveUser = DriveUser()
725
self.deleted: bool = False
726
self.html_content: str = ""
727
self.content: str = ""
728
729
def _scrape(self, comment_reply_data: Dict[str, any]):
730
self.reply_id = comment_reply_data.get('replyId')
731
self.kind = comment_reply_data.get('kind')
732
self.created_date = comment_reply_data.get('createdDate')
733
self.modified_date = comment_reply_data.get('modifiedDate')
734
if (author_data := comment_reply_data.get('author')):
735
self.author._scrape(author_data)
736
self.deleted = comment_reply_data.get('deleted')
737
self.html_content = comment_reply_data.get('htmlContent')
738
self.content = comment_reply_data.get('content')
739