Returns a collection of Sharepoint Items :param int limit: max no. of items to get. Over 999 uses batch. :param query: applies a filter to the request. :type query: Query or str :param order_by: orders the result set based on this condition :type order_by: Qu
(self, limit=None, *, query=None, order_by=None, batch=None, expand_fields=None)
| 275 | return 'fields(select=' + result.rstrip(',') + ')' |
| 276 | |
| 277 | def get_items(self, limit=None, *, query=None, order_by=None, batch=None, expand_fields=None): |
| 278 | """ Returns a collection of Sharepoint Items |
| 279 | :param int limit: max no. of items to get. Over 999 uses batch. |
| 280 | :param query: applies a filter to the request. |
| 281 | :type query: Query or str |
| 282 | :param order_by: orders the result set based on this condition |
| 283 | :type order_by: Query or str |
| 284 | :param int batch: batch size, retrieves items in |
| 285 | batches allowing to retrieve more items than the limit. |
| 286 | :param expand_fields: specify user-defined fields to return, |
| 287 | True will return all fields |
| 288 | :type expand_fields: list or bool |
| 289 | :return: list of Sharepoint Items |
| 290 | :rtype: list[SharepointListItem] or Pagination |
| 291 | """ |
| 292 | |
| 293 | url = self.build_url(self._endpoints.get('get_items')) |
| 294 | |
| 295 | if limit is None or limit > self.protocol.max_top_value: |
| 296 | batch = self.protocol.max_top_value |
| 297 | |
| 298 | params = {'$top': batch if batch else limit} |
| 299 | |
| 300 | if expand_fields is not None: |
| 301 | params['expand'] = self.build_field_filter(expand_fields) |
| 302 | |
| 303 | if order_by: |
| 304 | params['$orderby'] = order_by |
| 305 | |
| 306 | if query: |
| 307 | if isinstance(query, str): |
| 308 | params['$filter'] = query |
| 309 | else: |
| 310 | params.update(query.as_params()) |
| 311 | |
| 312 | response = self.con.get(url, params=params) |
| 313 | |
| 314 | if not response: |
| 315 | return [] |
| 316 | |
| 317 | data = response.json() |
| 318 | next_link = data.get(NEXT_LINK_KEYWORD, None) |
| 319 | |
| 320 | items = [self.list_item_constructor(parent=self, **{self._cloud_data_key: item}) |
| 321 | for item in data.get('value', [])] |
| 322 | |
| 323 | if batch and next_link: |
| 324 | return Pagination(parent=self, data=items, constructor=self.list_item_constructor, |
| 325 | next_link=next_link, limit=limit) |
| 326 | else: |
| 327 | return items |
| 328 | |
| 329 | def get_item_by_id(self, item_id, expand_fields=None): |
| 330 | """ Returns a sharepoint list item based on id |
nothing calls this directly
no test coverage detected