Parses and completes resource information
(resource)
| 354 | |
| 355 | @staticmethod |
| 356 | def _parse_resource(resource): |
| 357 | """ Parses and completes resource information """ |
| 358 | resource = resource.strip() if resource else resource |
| 359 | resource_start = list(filter(lambda part: part, resource.split('/')))[0] if resource else resource |
| 360 | |
| 361 | if ':' not in resource_start and '@' not in resource_start: |
| 362 | return resource |
| 363 | |
| 364 | if '@' in resource_start: |
| 365 | # user resource backup |
| 366 | # when for example accessing a shared mailbox the |
| 367 | # resource is set to the email address. we have to prefix |
| 368 | # the email with the resource 'users/' so --> 'users/email_address' |
| 369 | return '{}/{}'.format(USERS_RESOURCE, resource) |
| 370 | elif resource.startswith('user:'): |
| 371 | # user resource shorthand |
| 372 | resource = resource.replace('user:', '', 1) |
| 373 | return '{}/{}'.format(USERS_RESOURCE, resource) |
| 374 | elif resource.startswith('group:'): |
| 375 | # group resource shorthand |
| 376 | resource = resource.replace('group:', '', 1) |
| 377 | return '{}/{}'.format(GROUPS_RESOURCE, resource) |
| 378 | elif resource.startswith('site:'): |
| 379 | # sharepoint site resource shorthand |
| 380 | resource = resource.replace('site:', '', 1) |
| 381 | return '{}/{}'.format(SITES_RESOURCE, resource) |
| 382 | else: |
| 383 | return resource |
| 384 | |
| 385 | def build_base_url(self, resource): |
| 386 | """ |
no test coverage detected