Skip to content

Commit 33fc245

Browse files
committed
Reorder in same order as docs
1 parent 7871d5d commit 33fc245

File tree

2 files changed

+80
-80
lines changed

2 files changed

+80
-80
lines changed

apify/Crawler.py

Lines changed: 76 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,42 @@ def __init__(self, crawler_id, session=requests.Session(), config="apify_config.
2929
self._base_url = 'https://api.apify.com/v1/' + \
3030
self.get_user_id() + '/crawlers/' + self.get_crawler_id()
3131

32+
def get_crawler_id(self):
33+
"""Returns: crawler_id (str): crawler ID"""
34+
return self._crawler_id
35+
36+
def get_settings(self, **kwargs):
37+
"""Gets full crawler details and settings
38+
https://www.apify.com/docs/api/v1#/reference/crawlers/crawler-settings/get-crawler-settings
39+
40+
Args:
41+
kwargs:
42+
noSecrets (int): If 1, response will not contain sensitive data like auth tokens (default: 0)
43+
executionId (str): execution ID for which to return the settings (default: current settings)
44+
45+
Returns:
46+
settings (JSON object): crawler settings
47+
"""
48+
return super()._get() # TODO ADD **KWARGS
49+
50+
def update_settings(self, settings={}):
51+
"""Updates crawler settings
52+
https://www.apify.com/docs/api/v1#/reference/crawlers/crawler-settings/update-crawler-settings
53+
54+
Args:
55+
settings (JSON object): settings to be updated
56+
57+
Returns:
58+
settings (JSON object): new crawler settings
59+
"""
60+
return super()._put(data=settings)
61+
62+
def delete(self):
63+
"""Deletes the crawler
64+
https://www.apify.com/docs/api/v1#/reference/crawlers/crawler-settings/delete-crawler
65+
"""
66+
return super()._delete()
67+
3268
def start(self, settings={}, **kwargs):
3369
"""Executes crawler
3470
https://www.apify.com/docs/api/v1#/reference/executions/start-execution/start-execution
@@ -62,6 +98,23 @@ def start(self, settings={}, **kwargs):
6298
r.raise_for_status()
6399
return r.json()
64100

101+
def get_list_of_executions(self, **kwargs):
102+
"""Gets the crawler's list of executions
103+
https://www.apify.com/docs/api/v1#/reference/executions/list-of-executions/get-list-of-executions
104+
105+
Args:
106+
kwargs:
107+
status (str): Filter for the execution status (default: no filter)
108+
offset (int): Rank of first execution to return (default: 0)
109+
limit (int): Maximum number of executions to return (default: 1000)
110+
desc (int): If 1, executions are sorted from newest to oldest (default: None)
111+
112+
Returns:
113+
execution_list (JSON object): list of executions and their metadata
114+
"""
115+
url = self._base_url + "/execs"
116+
return super()._get(url, None, **kwargs)
117+
65118
def get_last_execution(self, **kwargs):
66119
"""Gets information about the crawler's last execution
67120
https://www.apify.com/docs/api/v1#/reference/executions/last-execution/get-last-execution
@@ -109,55 +162,6 @@ def get_last_execution_results(self, status=None, combine=False, **kwargs):
109162

110163
return execution.get_results(combine=combine, **kwargs)
111164

112-
def delete(self):
113-
"""Deletes the crawler
114-
https://www.apify.com/docs/api/v1#/reference/crawlers/crawler-settings/delete-crawler
115-
"""
116-
return super()._delete()
117-
118-
def get_settings(self, **kwargs):
119-
"""Gets full details and settings of a specific crawler
120-
https://www.apify.com/docs/api/v1#/reference/crawlers/crawler-settings/get-crawler-settings
121-
122-
Args:
123-
kwargs:
124-
noSecrets (int): If 1, response will not contain sensitive data like auth tokens (default: 0)
125-
executionId (str): execution ID for which to return the settings (default: current settings)
126-
127-
Returns:
128-
settings (JSON object): crawler settings
129-
"""
130-
return super()._get()
131-
132-
def update_settings(self, settings={}):
133-
"""Updates a specific crawler's settings
134-
https://www.apify.com/docs/api/v1#/reference/crawlers/crawler-settings/update-crawler-settings
135-
136-
Args:
137-
settings (JSON object): settings to be updated
138-
139-
Returns:
140-
settings (JSON object): new crawler settings
141-
"""
142-
return super()._put(data=settings)
143-
144-
def get_list_of_executions(self, **kwargs):
145-
"""Gets the crawler's list of executions
146-
https://www.apify.com/docs/api/v1#/reference/executions/list-of-executions/get-list-of-executions
147-
148-
Args:
149-
kwargs:
150-
status (str): Filter for the execution status (default: no filter)
151-
offset (int): Rank of first execution to return (default: 0)
152-
limit (int): Maximum number of executions to return (default: 1000)
153-
desc (int): If 1, executions are sorted from newest to oldest (default: None)
154-
155-
Returns:
156-
execution_list (JSON object): list of executions and their metadata
157-
"""
158-
url = self._base_url + "/execs"
159-
return super()._get(url, None, **kwargs)
160-
161165
def stop_last_execution(self):
162166
"""Stops the last crawler execution
163167
https://www.apify.com/docs/api/v1#/reference/executions/stop-execution
@@ -169,10 +173,6 @@ def stop_last_execution(self):
169173
execution = Execution(execution_id, session=self.get_session(), config=self._config)
170174
return execution.stop()
171175

172-
def get_crawler_id(self):
173-
"""Returns: crawler_id (str): crawler ID"""
174-
return self._crawler_id
175-
176176

177177
class Execution(CrawlerABC):
178178
def __init__(self, execution_id, session=requests.Session(), config="apify_config.json"):
@@ -188,6 +188,29 @@ def __init__(self, execution_id, session=requests.Session(), config="apify_confi
188188
self._execution_id = execution_id
189189
self._base_url = "https://api.apify.com/v1/execs/" + self.get_execution_id()
190190

191+
def get_execution_id(self):
192+
"""Returns: execution_id (str): crawler ID"""
193+
return self._execution_id
194+
195+
def stop(self):
196+
"""Stops the execution
197+
https://www.apify.com/docs/api/v1#/reference/executions/stop-execution/
198+
199+
Returns:
200+
execution_details (JSON object): execution details
201+
"""
202+
url = self._base_url + "/stop"
203+
return super()._post(url)
204+
205+
def get_details(self):
206+
"""Gets execution details
207+
https://www.apify.com/docs/api/v1#/reference/executions/execution-details/get-execution-details
208+
209+
Returns:
210+
execution_details (JSON object): execution details
211+
"""
212+
return super()._get()
213+
191214
def get_results(self, combine=False, **kwargs):
192215
""" Gets execution results
193216
https://www.apify.com/docs/api/v1#/reference/executions
@@ -246,26 +269,3 @@ def get_results(self, combine=False, **kwargs):
246269
else:
247270
result = r.text
248271
return result
249-
250-
def stop(self):
251-
"""Stops the execution
252-
https://www.apify.com/docs/api/v1#/reference/executions/stop-execution/stop-execution
253-
254-
Returns:
255-
execution_details (JSON object): execution details
256-
"""
257-
url = self._base_url + "/stop"
258-
return super()._post(url)
259-
260-
def get_details(self):
261-
"""Gets execution details
262-
https://www.apify.com/docs/api/v1#/reference/executions/execution-details/get-execution-details
263-
264-
Returns:
265-
execution_details (JSON object): execution details
266-
"""
267-
return super()._get()
268-
269-
def get_execution_id(self):
270-
"""Returns: execution_id (str): crawler ID"""
271-
return self._execution_id

apify/Dataset.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ def __init__(self, dataset_id, session=requests.Session(), config="apify_config.
1919
self._dataset_id = dataset_id
2020
self._base_url = "https://api.apify.com/v2/datasets/" + self.get_dataset_id()
2121

22+
def get_dataset_id(self):
23+
"""Returns: dataset_id (str): dataset ID"""
24+
return self._dataset_id
25+
2226
def get(self):
2327
"""Gets actor details
2428
https://www.apify.com/docs/api/v2#/reference/datasets/dataset/get-dataset
@@ -34,10 +38,6 @@ def delete(self):
3438
"""
3539
return super()._delete()
3640

37-
def get_dataset_id(self):
38-
"""Returns: dataset_id (str): dataset ID"""
39-
return self._dataset_id
40-
4141
def get_items(self, **kwargs):
4242
"""Gets items stored in the dataset
4343
https://www.apify.com/docs/api/v2#/reference/datasets/item-collection/get-items

0 commit comments

Comments
 (0)