|
12 | 12 |
|
13 | 13 | ME_RESOURCE = 'me' |
14 | 14 | USERS_RESOURCE = 'users' |
| 15 | +GROUPS_RESOURCE = 'groups' |
| 16 | +SITES_RESOURCE = 'sites' |
15 | 17 |
|
16 | 18 | NEXT_LINK_KEYWORD = '@odata.nextLink' |
17 | 19 |
|
@@ -348,13 +350,26 @@ def __repr__(self): |
348 | 350 | def _parse_resource(resource): |
349 | 351 | """ Parses and completes resource information """ |
350 | 352 | resource = resource.strip() if resource else resource |
351 | | - if resource in {ME_RESOURCE, USERS_RESOURCE}: |
| 353 | + if resource in {ME_RESOURCE, USERS_RESOURCE, GROUPS_RESOURCE, SITES_RESOURCE}: |
352 | 354 | return resource |
| 355 | + elif resource.startswith('user:'): |
| 356 | + # user resource shorthand |
| 357 | + resource = resource.replace('user:', '', 1) |
| 358 | + return '{}/{}'.format(USERS_RESOURCE, resource) |
353 | 359 | elif '@' in resource and not resource.startswith(USERS_RESOURCE): |
| 360 | + # user resource backup |
354 | 361 | # when for example accessing a shared mailbox the |
355 | 362 | # resource is set to the email address. we have to prefix |
356 | 363 | # the email with the resource 'users/' so --> 'users/email_address' |
357 | 364 | return '{}/{}'.format(USERS_RESOURCE, resource) |
| 365 | + elif resource.startswith('group:'): |
| 366 | + # group resource shorthand |
| 367 | + resource = resource.replace('group:', '', 1) |
| 368 | + return '{}/{}'.format(GROUPS_RESOURCE, resource) |
| 369 | + elif resource.startswith('site:'): |
| 370 | + # sharepoint site resource shorthand |
| 371 | + resource = resource.replace('site:', '', 1) |
| 372 | + return '{}/{}'.format(SITES_RESOURCE, resource) |
358 | 373 | else: |
359 | 374 | return resource |
360 | 375 |
|
|
0 commit comments