Skip to content

Commit f679dce

Browse files
Add separate functions for accessing limit or marker paging in folders
1 parent 07e8549 commit f679dce

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

boxsdk/object/folder.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
from boxsdk.object.group import Group
1010
from boxsdk.object.item import Item
1111
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
1214
from boxsdk.util.api_call_decorator import api_call
1315
from boxsdk.util.text_enum import TextEnum
1416

@@ -154,6 +156,69 @@ def get_items(self, limit, offset=0, fields=None):
154156
response = box_response.json()
155157
return [self.translator.translate(item['type'])(self._session, item['id'], item) for item in response['entries']]
156158

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+
157222
@api_call
158223
def upload_stream(
159224
self,

0 commit comments

Comments
 (0)