Skip to content

Commit 7bc4ccb

Browse files
Merge pull request #45354 from nextcloud/docs/taskprocessingapi/cleanup-endpoint-descriptions
2 parents b1f9c4b + a8abe9d commit 7bc4ccb

File tree

2 files changed

+38
-46
lines changed

2 files changed

+38
-46
lines changed

core/Controller/TaskProcessingApiController.php

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,10 @@
3535
use OCP\AppFramework\Http\Attribute\UserRateLimit;
3636
use OCP\AppFramework\Http\DataDownloadResponse;
3737
use OCP\AppFramework\Http\DataResponse;
38-
use OCP\Common\Exception\NotFoundException;
3938
use OCP\Files\File;
40-
use OCP\Files\GenericFileException;
4139
use OCP\Files\IRootFolder;
42-
use OCP\Files\NotPermittedException;
4340
use OCP\IL10N;
4441
use OCP\IRequest;
45-
use OCP\Lock\LockedException;
4642
use OCP\TaskProcessing\EShapeType;
4743
use OCP\TaskProcessing\Exception\Exception;
4844
use OCP\TaskProcessing\Exception\UnauthorizedException;
@@ -67,7 +63,7 @@ public function __construct(
6763
}
6864

6965
/**
70-
* This endpoint returns all available TaskProcessing task types
66+
* Returns all available TaskProcessing task types
7167
*
7268
* @return DataResponse<Http::STATUS_OK, array{types: array<string, CoreTaskProcessingTaskType>}, array{}>
7369
*
@@ -100,7 +96,7 @@ public function taskTypes(): DataResponse {
10096
}
10197

10298
/**
103-
* This endpoint allows scheduling a task
99+
* Schedules a task
104100
*
105101
* @param array<string, mixed> $input Task's input parameters
106102
* @param string $type Type of the task
@@ -141,7 +137,8 @@ public function schedule(array $input, string $type, string $appId, string $cust
141137
}
142138

143139
/**
144-
* This endpoint allows checking the status and results of a task.
140+
* Gets a task including status and result
141+
*
145142
* Tasks are removed 1 week after receiving their last update
146143
*
147144
* @param int $id The id of the task
@@ -163,21 +160,21 @@ public function getTask(int $id): DataResponse {
163160
return new DataResponse([
164161
'task' => $json,
165162
]);
166-
} catch (NotFoundException $e) {
163+
} catch (\OCP\TaskProcessing\Exception\NotFoundException $e) {
167164
return new DataResponse(['message' => $this->l->t('Task not found')], Http::STATUS_NOT_FOUND);
168165
} catch (\RuntimeException $e) {
169166
return new DataResponse(['message' => $this->l->t('Internal error')], Http::STATUS_INTERNAL_SERVER_ERROR);
170167
}
171168
}
172169

173170
/**
174-
* This endpoint allows to delete a scheduled task for a user
171+
* Deletes a task
175172
*
176173
* @param int $id The id of the task
177174
*
178175
* @return DataResponse<Http::STATUS_OK, null, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
179176
*
180-
* 200: Task returned
177+
* 200: Task deleted
181178
*/
182179
#[NoAdminRequired]
183180
#[ApiRoute(verb: 'DELETE', url: '/task/{id}', root: '/taskprocessing')]
@@ -197,14 +194,13 @@ public function deleteTask(int $id): DataResponse {
197194

198195

199196
/**
200-
* This endpoint returns a list of tasks of a user that are related
201-
* with a specific appId and optionally with an identifier
197+
* Returns tasks for the current user filtered by the appId and optional customId
202198
*
203199
* @param string $appId ID of the app
204200
* @param string|null $customId An arbitrary identifier for the task
205201
* @return DataResponse<Http::STATUS_OK, array{tasks: CoreTaskProcessingTask[]}, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
206202
*
207-
* 200: Task list returned
203+
* 200: Tasks returned
208204
*/
209205
#[NoAdminRequired]
210206
#[ApiRoute(verb: 'GET', url: '/tasks/app/{appId}', root: '/taskprocessing')]
@@ -221,24 +217,21 @@ public function listTasksByApp(string $appId, ?string $customId = null): DataRes
221217
]);
222218
} catch (Exception $e) {
223219
return new DataResponse(['message' => $this->l->t('Internal error')], Http::STATUS_INTERNAL_SERVER_ERROR);
224-
} catch (\JsonException $e) {
225-
return new DataResponse(['message' => $this->l->t('Internal error')], Http::STATUS_INTERNAL_SERVER_ERROR);
226220
}
227221
}
228222

229223
/**
230-
* This endpoint returns a list of tasks of a user that are related
231-
* with a specific appId and optionally with an identifier
224+
* Returns tasks for the current user filtered by the optional taskType and optional customId
232225
*
233226
* @param string|null $taskType The task type to filter by
234227
* @param string|null $customId An arbitrary identifier for the task
235228
* @return DataResponse<Http::STATUS_OK, array{tasks: CoreTaskProcessingTask[]}, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
236229
*
237-
* 200: Task list returned
230+
* 200: Tasks returned
238231
*/
239232
#[NoAdminRequired]
240233
#[ApiRoute(verb: 'GET', url: '/tasks', root: '/taskprocessing')]
241-
public function listTasksByUser(?string $taskType, ?string $customId = null): DataResponse {
234+
public function listTasks(?string $taskType, ?string $customId = null): DataResponse {
242235
try {
243236
$tasks = $this->taskProcessingManager->getUserTasks($this->userId, $taskType, $customId);
244237
/** @var CoreTaskProcessingTask[] $json */
@@ -251,13 +244,11 @@ public function listTasksByUser(?string $taskType, ?string $customId = null): Da
251244
]);
252245
} catch (Exception $e) {
253246
return new DataResponse(['message' => $this->l->t('Internal error')], Http::STATUS_INTERNAL_SERVER_ERROR);
254-
} catch (\JsonException $e) {
255-
return new DataResponse(['message' => $this->l->t('Internal error')], Http::STATUS_INTERNAL_SERVER_ERROR);
256247
}
257248
}
258249

259250
/**
260-
* This endpoint returns the contents of a file referenced in a task
251+
* Returns the contents of a file referenced in a task
261252
*
262253
* @param int $taskId The id of the task
263254
* @param int $fileId The file id of the file to retrieve
@@ -288,7 +279,7 @@ public function getFileContents(int $taskId, int $fileId): Http\DataDownloadResp
288279
return new Http\DataDownloadResponse($node->getContent(), $node->getName(), $node->getMimeType());
289280
} catch (\OCP\TaskProcessing\Exception\NotFoundException $e) {
290281
return new DataResponse(['message' => $this->l->t('Not found')], Http::STATUS_NOT_FOUND);
291-
} catch (GenericFileException|NotPermittedException|LockedException|Exception $e) {
282+
} catch (Exception $e) {
292283
return new DataResponse(['message' => $this->l->t('Internal error')], Http::STATUS_INTERNAL_SERVER_ERROR);
293284
}
294285
}
@@ -333,13 +324,13 @@ private function extractFileIdsFromTask(Task $task): array {
333324
}
334325

335326
/**
336-
* This endpoint sets the task progress
327+
* Sets the task progress
337328
*
338329
* @param int $taskId The id of the task
339330
* @param float $progress The progress
340331
* @return DataResponse<Http::STATUS_OK, array{task: CoreTaskProcessingTask}, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
341332
*
342-
* 200: File content returned
333+
* 200: Progress updated successfully
343334
* 404: Task not found
344335
*/
345336
#[NoAdminRequired]
@@ -363,14 +354,14 @@ public function setProgress(int $taskId, float $progress): DataResponse {
363354
}
364355

365356
/**
366-
* This endpoint sets the task progress
357+
* Sets the task result
367358
*
368359
* @param int $taskId The id of the task
369360
* @param array<string,mixed>|null $output The resulting task output
370361
* @param string|null $errorMessage An error message if the task failed
371362
* @return DataResponse<Http::STATUS_OK, array{task: CoreTaskProcessingTask}, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
372363
*
373-
* 200: File content returned
364+
* 200: Result updated successfully
374365
* 404: Task not found
375366
*/
376367
#[NoAdminRequired]
@@ -397,12 +388,12 @@ public function setResult(int $taskId, ?array $output = null, ?string $errorMess
397388
}
398389

399390
/**
400-
* This endpoint cancels a task
391+
* Cancels a task
401392
*
402393
* @param int $taskId The id of the task
403394
* @return DataResponse<Http::STATUS_OK, array{task: CoreTaskProcessingTask}, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
404395
*
405-
* 200: File content returned
396+
* 200: Task canceled successfully
406397
* 404: Task not found
407398
*/
408399
#[NoAdminRequired]

core/openapi.json

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3345,7 +3345,7 @@
33453345
"/ocs/v2.php/taskprocessing/tasktypes": {
33463346
"get": {
33473347
"operationId": "task_processing_api-task-types",
3348-
"summary": "This endpoint returns all available TaskProcessing task types",
3348+
"summary": "Returns all available TaskProcessing task types",
33493349
"tags": [
33503350
"task_processing_api"
33513351
],
@@ -3418,7 +3418,7 @@
34183418
"/ocs/v2.php/taskprocessing/schedule": {
34193419
"post": {
34203420
"operationId": "task_processing_api-schedule",
3421-
"summary": "This endpoint allows scheduling a task",
3421+
"summary": "Schedules a task",
34223422
"tags": [
34233423
"task_processing_api"
34243424
],
@@ -3676,7 +3676,8 @@
36763676
"/ocs/v2.php/taskprocessing/task/{id}": {
36773677
"get": {
36783678
"operationId": "task_processing_api-get-task",
3679-
"summary": "This endpoint allows checking the status and results of a task. Tasks are removed 1 week after receiving their last update",
3679+
"summary": "Gets a task including status and result",
3680+
"description": "Tasks are removed 1 week after receiving their last update",
36803681
"tags": [
36813682
"task_processing_api"
36823683
],
@@ -3830,7 +3831,7 @@
38303831
},
38313832
"delete": {
38323833
"operationId": "task_processing_api-delete-task",
3833-
"summary": "This endpoint allows to delete a scheduled task for a user",
3834+
"summary": "Deletes a task",
38343835
"tags": [
38353836
"task_processing_api"
38363837
],
@@ -3866,7 +3867,7 @@
38663867
],
38673868
"responses": {
38683869
"200": {
3869-
"description": "Task returned",
3870+
"description": "Task deleted",
38703871
"content": {
38713872
"application/json": {
38723873
"schema": {
@@ -3939,7 +3940,7 @@
39393940
"/ocs/v2.php/taskprocessing/tasks/app/{appId}": {
39403941
"get": {
39413942
"operationId": "task_processing_api-list-tasks-by-app",
3942-
"summary": "This endpoint returns a list of tasks of a user that are related with a specific appId and optionally with an identifier",
3943+
"summary": "Returns tasks for the current user filtered by the appId and optional customId",
39433944
"tags": [
39443945
"task_processing_api"
39453946
],
@@ -3983,7 +3984,7 @@
39833984
],
39843985
"responses": {
39853986
"200": {
3986-
"description": "Task list returned",
3987+
"description": "Tasks returned",
39873988
"content": {
39883989
"application/json": {
39893990
"schema": {
@@ -4066,8 +4067,8 @@
40664067
},
40674068
"/ocs/v2.php/taskprocessing/tasks": {
40684069
"get": {
4069-
"operationId": "task_processing_api-list-tasks-by-user",
4070-
"summary": "This endpoint returns a list of tasks of a user that are related with a specific appId and optionally with an identifier",
4070+
"operationId": "task_processing_api-list-tasks",
4071+
"summary": "Returns tasks for the current user filtered by the optional taskType and optional customId",
40714072
"tags": [
40724073
"task_processing_api"
40734074
],
@@ -4111,7 +4112,7 @@
41114112
],
41124113
"responses": {
41134114
"200": {
4114-
"description": "Task list returned",
4115+
"description": "Tasks returned",
41154116
"content": {
41164117
"application/json": {
41174118
"schema": {
@@ -4195,7 +4196,7 @@
41954196
"/ocs/v2.php/taskprocessing/tasks/{taskId}/file/{fileId}": {
41964197
"get": {
41974198
"operationId": "task_processing_api-get-file-contents",
4198-
"summary": "This endpoint returns the contents of a file referenced in a task",
4199+
"summary": "Returns the contents of a file referenced in a task",
41994200
"tags": [
42004201
"task_processing_api"
42014202
],
@@ -4333,7 +4334,7 @@
43334334
"/ocs/v2.php/taskprocessing/tasks/{taskId}/progress": {
43344335
"post": {
43354336
"operationId": "task_processing_api-set-progress",
4336-
"summary": "This endpoint sets the task progress",
4337+
"summary": "Sets the task progress",
43374338
"tags": [
43384339
"task_processing_api"
43394340
],
@@ -4379,7 +4380,7 @@
43794380
],
43804381
"responses": {
43814382
"200": {
4382-
"description": "File content returned",
4383+
"description": "Progress updated successfully",
43834384
"content": {
43844385
"application/json": {
43854386
"schema": {
@@ -4498,7 +4499,7 @@
44984499
"/ocs/v2.php/taskprocessing/tasks/{taskId}/result": {
44994500
"post": {
45004501
"operationId": "task_processing_api-set-result",
4501-
"summary": "This endpoint sets the task progress",
4502+
"summary": "Sets the task result",
45024503
"tags": [
45034504
"task_processing_api"
45044505
],
@@ -4552,7 +4553,7 @@
45524553
],
45534554
"responses": {
45544555
"200": {
4555-
"description": "File content returned",
4556+
"description": "Result updated successfully",
45564557
"content": {
45574558
"application/json": {
45584559
"schema": {
@@ -4671,7 +4672,7 @@
46714672
"/ocs/v2.php/taskprocessing/tasks/{taskId}/cancel": {
46724673
"post": {
46734674
"operationId": "task_processing_api-cancel-task",
4674-
"summary": "This endpoint cancels a task",
4675+
"summary": "Cancels a task",
46754676
"tags": [
46764677
"task_processing_api"
46774678
],
@@ -4707,7 +4708,7 @@
47074708
],
47084709
"responses": {
47094710
"200": {
4710-
"description": "File content returned",
4711+
"description": "Task canceled successfully",
47114712
"content": {
47124713
"application/json": {
47134714
"schema": {

0 commit comments

Comments
 (0)