|
32 | 32 | # Feed URIs that are given by the API, but cannot be obtained without |
33 | 33 | # making a mostly unnecessary HTTP request. |
34 | 34 | RESOURCE_FEED_URI = '/feeds/default/private/full' |
| 35 | +RESOURCE_SELF_LINK_TEMPLATE = RESOURCE_FEED_URI + '/%s' |
35 | 36 | RESOURCE_UPLOAD_URI = '/feeds/upload/create-session/default/private/full' |
36 | 37 | COLLECTION_UPLOAD_URI_TEMPLATE = \ |
37 | 38 | '/feeds/upload/create-session/feeds/default/private/full/%s/contents' |
@@ -208,6 +209,20 @@ def get_resource(self, entry, **kwargs): |
208 | 209 |
|
209 | 210 | GetResource = get_resource |
210 | 211 |
|
| 212 | + def get_resource_by_id(self, resource_id, **kwargs): |
| 213 | + """Retrieves a resource again given its resource ID. |
| 214 | +
|
| 215 | + Args: |
| 216 | + resource_id: Typed or untyped resource ID of a resource. |
| 217 | + kwargs: Other args to pass to GetResourceBySelfLink(). |
| 218 | + Returns: |
| 219 | + gdata.docs.data.Resource representing retrieved resource. |
| 220 | + """ |
| 221 | + return self.GetResourceBySelfLink( |
| 222 | + RESOURCE_SELF_LINK_TEMPLATE % resource_id, **kwargs) |
| 223 | + |
| 224 | + GetResourceById = get_resource_by_id |
| 225 | + |
211 | 226 | def get_resource_by_self_link(self, uri, etag=None, show_root=None, |
212 | 227 | **kwargs): |
213 | 228 | """Retrieves a particular resource by its self link. |
@@ -571,11 +586,25 @@ def _check_entry_is_not_collection(self, entry): |
571 | 586 | raise ValueError( |
572 | 587 | '%s is a collection, which is not valid in this method' % str(entry)) |
573 | 588 |
|
| 589 | + def get_acl(self, entry, **kwargs): |
| 590 | + """Retrieves an AclFeed for the given resource. |
| 591 | +
|
| 592 | + Args: |
| 593 | + entry: gdata.docs.data.Resource to fetch AclFeed for. |
| 594 | + kwargs: Other args to pass to GetFeed(). |
| 595 | + Returns: |
| 596 | + gdata.docs.data.AclFeed representing retrieved entries. |
| 597 | + """ |
| 598 | + self._check_entry_is_resource(entry) |
| 599 | + return self.get_feed( |
| 600 | + entry.GetAclFeedLink().href, |
| 601 | + desired_class=gdata.docs.data.AclFeed, **kwargs) |
| 602 | + |
574 | 603 | def get_acl_entry(self, entry, **kwargs): |
575 | 604 | """Retrieves an AclEntry again. |
576 | | - |
| 605 | +
|
577 | 606 | This is useful if you need to poll for an ACL changing. |
578 | | - |
| 607 | +
|
579 | 608 | Args: |
580 | 609 | entry: gdata.docs.data.AclEntry to fetch and return. |
581 | 610 | kwargs: Other args to pass to GetAclEntryBySelfLink(). |
|
0 commit comments