|
5 | 5 |
|
6 | 6 | import functools |
7 | 7 | import logging |
8 | | -from typing import Any, List, Dict, Tuple |
| 8 | +from typing import Any, List, Dict, Tuple, Union |
9 | 9 |
|
10 | 10 | import requests |
11 | 11 | from requests import compat |
|
15 | 15 | from connect.logger import function_log |
16 | 16 | from connect.models.base import BaseModel |
17 | 17 | from connect.models.server_error_response import ServerErrorResponse |
| 18 | +from connect.rql import Query |
18 | 19 |
|
19 | 20 |
|
20 | 21 | class ApiClient(object): |
@@ -158,8 +159,13 @@ def filters(self, **kwargs): |
158 | 159 | return filters |
159 | 160 |
|
160 | 161 | def list(self, filters=None): |
161 | | - # type: (Dict[str, Any]) -> List[Any] |
| 162 | + # type: (Union[Query, Dict[str, Any]]) -> List[Any] |
162 | 163 | filters = filters or self.filters() |
163 | | - self.logger.info('Get list request with filters - {}'.format(filters)) |
164 | | - response, _ = self._api.get(params=filters) |
| 164 | + if isinstance(filters, Query): |
| 165 | + compiled = filters.compile() |
| 166 | + self.logger.info('Get list request with Query - {}'.format(compiled)) |
| 167 | + response, _ = ApiClient(self._api.config, self._api.base_path + compiled).get() |
| 168 | + else: |
| 169 | + self.logger.info('Get list request with filters - {}'.format(filters)) |
| 170 | + response, _ = self._api.get(params=filters) |
165 | 171 | return self.model_class.deserialize(response) |
0 commit comments