MCPcopy Index your code
hub / github.com/omkarcloud/botasaurus / get_tasks

Method get_tasks

botasaurus_api/botasaurus_api/__init__.py:140–172  ·  view source on GitHub ↗

Fetches tasks from the server, with optional result inclusion, pagination, and filtering. :param page: The page number for pagination. :param per_page: The number of tasks to return per page. :param with_results: Whether to include the task results in the respo

(self, page=1, per_page=None, with_results=True)

Source from the content-addressed store, hash-verified

138 return response_data
139
140 def get_tasks(self, page=1, per_page=None, with_results=True):
141 """
142 Fetches tasks from the server, with optional result inclusion, pagination, and filtering.
143
144 :param page: The page number for pagination.
145 :param per_page: The number of tasks to return per page.
146 :param with_results: Whether to include the task results in the response.
147 :return: A dictionary containing the task results and pagination information.
148 """
149 url = self._make_api_url("api/tasks")
150 params = {
151 "with_results": str(with_results).lower(),
152 }
153 if page is not None:
154 params["page"] = str(page)
155 if per_page is not None:
156 params["per_page"] = str(per_page)
157
158 response = requests.get(url, params=params)
159 _raise_for_status(response)
160 response_data = response.json()
161
162 if self._create_response_files:
163 has_many_pages = response_data["total_pages"] > 1
164
165 filename = f"get_tasks-page-{page}" if has_many_pages else "get_tasks"
166 msg = f"get_tasks, page {page}" if has_many_pages else "get_tasks"
167 path = _create_filename(filename)
168 write_json_response(path, response_data)
169
170 print(f"View {msg} response at: ./{path}")
171
172 return response_data
173
174
175 def get_task(self, task_id):

Callers

nothing calls this directly

Calls 5

_make_api_urlMethod · 0.95
_raise_for_statusFunction · 0.85
_create_filenameFunction · 0.85
write_json_responseFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected