@@ -1150,13 +1150,13 @@ def revoke_user_access(self, username, database=None):
11501150 def async_jobs (self , status , count = None ):
11511151 """Return the IDs of asynchronous jobs with the specified status.
11521152
1153- :param status: the job status (``"pending"`` or ``"done"``)
1153+ :param status: The job status (``"pending"`` or ``"done"``).
11541154 :type status: str | unicode
1155- :param count: the maximum number of job IDs to return
1155+ :param count: The maximum number of job IDs to return.
11561156 :type count: int
1157- :returns: the list of job IDs
1157+ :returns: The list of job IDs.
11581158 :rtype: [str]
1159- :raises arango.exceptions.AsyncJobListError: if the retrieval fails
1159+ :raises arango.exceptions.AsyncJobListError: If the retrieval fails.
11601160 """
11611161 res = self ._conn .get (
11621162 '/_api/job/{}' .format (status ),
@@ -1169,13 +1169,13 @@ def async_jobs(self, status, count=None):
11691169 def clear_async_jobs (self , threshold = None ):
11701170 """Delete asynchronous job results from the server.
11711171
1172- :param threshold: if specified, only the job results created prior to
1172+ :param threshold: If specified, only the job results created prior to
11731173 the threshold (a unix timestamp) are deleted, otherwise *all* job
1174- results are deleted
1174+ results are deleted.
11751175 :type threshold: int
1176- :returns: whether the deletion of results was successful
1176+ :returns: Whether the deletion of results was successful.
11771177 :rtype: bool
1178- :raises arango.exceptions.AsyncJobClearError: if the operation fails
1178+ :raises arango.exceptions.AsyncJobClearError: If the operation fails.
11791179
11801180 .. note::
11811181 Async jobs currently queued or running are not stopped.
@@ -1190,3 +1190,71 @@ def clear_async_jobs(self, threshold=None):
11901190 if res .status_code in HTTP_OK :
11911191 return True
11921192 raise AsyncJobClearError (res )
1193+
1194+ ###############
1195+ # Pregel Jobs #
1196+ ###############
1197+
1198+ def create_pregel_job (self , algorithm , graph ):
1199+ """Start/create a Pregel job.
1200+
1201+ :param algorithm: The name of the algorithm (e.g. ``"pagerank"``).
1202+ :type algorithm: str | unicode
1203+ :param graph: The name of the graph.
1204+ :type graph: str | unicode
1205+ :returns: The ID of the Pregel job.
1206+ :rtype: int
1207+ :raises arango.exceptions.PregelJobCreateError: If the operation fails.
1208+
1209+ """
1210+ res = self ._conn .post (
1211+ '/_api/control_pregel' ,
1212+ data = {
1213+ 'algorithm' : algorithm ,
1214+ 'graphName' : graph ,
1215+ }
1216+ )
1217+ if res .status_code in HTTP_OK :
1218+ return res .body
1219+ raise PregelJobCreateError (res )
1220+
1221+ def pregel_job (self , job_id ):
1222+ """Return the details of a Pregel job.
1223+
1224+ :param job_id: The Pregel job ID.
1225+ :type job_id: int
1226+ :returns: The details of the Pregel job.
1227+ :rtype: dict
1228+ :raises arango.exceptions.PregelJobGetError: If the lookup fails.
1229+ """
1230+ res = self ._conn .get (
1231+ '/_api/control_pregel/{}' .format (job_id )
1232+ )
1233+ if res .status_code in HTTP_OK :
1234+ return {
1235+ 'aggregators' : res .body ['aggregators' ],
1236+ 'edge_count' : res .body .get ('edgeCount' ),
1237+ 'gss' : res .body ['gss' ],
1238+ 'received_count' : res .body ['receivedCount' ],
1239+ 'send_count' : res .body ['sendCount' ],
1240+ 'state' : res .body ['state' ],
1241+ 'total_runtime' : res .body ['totalRuntime' ],
1242+ 'vertex_count' : res .body .get ('vertexCount' )
1243+ }
1244+ raise PregelJobGetError (res )
1245+
1246+ def delete_pregel_job (self , job_id ):
1247+ """Cancel/delete a Pregel job.
1248+
1249+ :param job_id: The Pregel job ID.
1250+ :type job_id: int
1251+ :returns: ``True`` if the Pregel job was successfully cancelled.
1252+ :rtype: bool
1253+ :raises arango.exceptions.PregelJobDeleteError: If the deletion fails.
1254+ """
1255+ res = self ._conn .delete (
1256+ '/_api/control_pregel/{}' .format (job_id )
1257+ )
1258+ if res .status_code in HTTP_OK :
1259+ return True
1260+ raise PregelJobDeleteError (res )
0 commit comments