|
9 | 9 | from boxsdk.object.group import Group |
10 | 10 | from boxsdk.object.item import Item |
11 | 11 | from boxsdk.object.user import User |
| 12 | +from boxsdk.pagination.limit_offset_based_object_collection import LimitOffsetBasedObjectCollection |
| 13 | +from boxsdk.pagination.marker_based_object_collection import MarkerBasedObjectCollection |
12 | 14 | from boxsdk.util.api_call_decorator import api_call |
13 | 15 | from boxsdk.util.text_enum import TextEnum |
14 | 16 |
|
@@ -154,6 +156,69 @@ def get_items(self, limit, offset=0, fields=None): |
154 | 156 | response = box_response.json() |
155 | 157 | return [self.translator.translate(item['type'])(self._session, item['id'], item) for item in response['entries']] |
156 | 158 |
|
| 159 | + @api_call |
| 160 | + def get_items_limit_offset(self, limit=None, offset=0, fields=None): |
| 161 | + """ |
| 162 | + Get the items in a folder using limit-offset paging. |
| 163 | +
|
| 164 | + :param limit: |
| 165 | + The maximum number of items to return per page. If not specified, then will use the server-side default. |
| 166 | + :type limit: |
| 167 | + `int` or None |
| 168 | + :param offset: |
| 169 | + The index at which to start returning items. |
| 170 | + :type offset: |
| 171 | + `int` |
| 172 | + :param fields: |
| 173 | + List of fields to request. |
| 174 | + :type fields: |
| 175 | + `Iterable` of `unicode` |
| 176 | + :returns: |
| 177 | + An iterator of the items in the folder. |
| 178 | + :rtype: |
| 179 | + :class:`BoxObjectCollection` |
| 180 | + """ |
| 181 | + return LimitOffsetBasedObjectCollection( |
| 182 | + self.session, |
| 183 | + self.get_url('items'), |
| 184 | + limit=limit, |
| 185 | + fields=fields, |
| 186 | + offset=offset, |
| 187 | + return_full_pages=False, |
| 188 | + ) |
| 189 | + |
| 190 | + @api_call |
| 191 | + def get_items_marker(self, limit=None, marker=None, fields=None): |
| 192 | + """ |
| 193 | + Get the items in a folder using marker-based paging. |
| 194 | +
|
| 195 | + :param limit: |
| 196 | + The maximum number of items to return per page. If not specified, then will use the server-side default. |
| 197 | + :type limit: |
| 198 | + `int` or None |
| 199 | + :param marker: |
| 200 | + The offset index to start paging from. |
| 201 | + :type marker: |
| 202 | + `str` or None |
| 203 | + :param fields: |
| 204 | + List of fields to request. |
| 205 | + :type fields: |
| 206 | + `Iterable` of `unicode` |
| 207 | + :returns: |
| 208 | + An iterator of the items in the folder. |
| 209 | + :rtype: |
| 210 | + :class:`BoxObjectCollection` |
| 211 | + """ |
| 212 | + return MarkerBasedObjectCollection( |
| 213 | + self.session, |
| 214 | + self.get_url('items'), |
| 215 | + limit=limit, |
| 216 | + fields=fields, |
| 217 | + marker=marker, |
| 218 | + return_full_pages=False, |
| 219 | + supports_limit_offset_paging=True, |
| 220 | + ) |
| 221 | + |
157 | 222 | @api_call |
158 | 223 | def upload_stream( |
159 | 224 | self, |
|
0 commit comments