Returns generator all the items inside this folder :param int limit: max no. of folders to get. Over 999 uses batch. :param query: applies a OData filter to the request :type query: Query or str :param order_by: orders the result set based on this condition
(self, limit=None, *, query=None, order_by=None, batch=None)
| 1040 | 'name', None) |
| 1041 | |
| 1042 | def get_items(self, limit=None, *, query=None, order_by=None, batch=None): |
| 1043 | """ Returns generator all the items inside this folder |
| 1044 | |
| 1045 | :param int limit: max no. of folders to get. Over 999 uses batch. |
| 1046 | :param query: applies a OData filter to the request |
| 1047 | :type query: Query or str |
| 1048 | :param order_by: orders the result set based on this condition |
| 1049 | :type order_by: Query or str |
| 1050 | :param int batch: batch size, retrieves items in |
| 1051 | batches allowing to retrieve more items than the limit. |
| 1052 | :return: items in this folder |
| 1053 | :rtype: generator of DriveItem or Pagination |
| 1054 | """ |
| 1055 | |
| 1056 | url = self.build_url( |
| 1057 | self._endpoints.get('list_items').format(id=self.object_id)) |
| 1058 | |
| 1059 | if limit is None or limit > self.protocol.max_top_value: |
| 1060 | batch = self.protocol.max_top_value |
| 1061 | |
| 1062 | params = {'$top': batch if batch else limit} |
| 1063 | |
| 1064 | if order_by: |
| 1065 | params['$orderby'] = order_by |
| 1066 | |
| 1067 | if query: |
| 1068 | if isinstance(query, str): |
| 1069 | params['$filter'] = query |
| 1070 | else: |
| 1071 | params.update(query.as_params()) |
| 1072 | |
| 1073 | response = self.con.get(url, params=params) |
| 1074 | if not response: |
| 1075 | return iter(()) |
| 1076 | |
| 1077 | data = response.json() |
| 1078 | |
| 1079 | # Everything received from cloud must be passed as self._cloud_data_key |
| 1080 | items = ( |
| 1081 | self._classifier(item)(parent=self, **{self._cloud_data_key: item}) |
| 1082 | for item in data.get('value', [])) |
| 1083 | next_link = data.get(NEXT_LINK_KEYWORD, None) |
| 1084 | if batch and next_link: |
| 1085 | return Pagination(parent=self, data=items, |
| 1086 | constructor=self._classifier, |
| 1087 | next_link=next_link, limit=limit) |
| 1088 | else: |
| 1089 | return items |
| 1090 | |
| 1091 | def get_child_folders(self, limit=None, *, query=None, order_by=None, batch=None): |
| 1092 | """ Returns all the folders inside this folder |
no test coverage detected