Nextcloud PHP API (master)

IManager

API surface for apps interacting with and making use of LanguageModel providers without known which providers are installed

Tags
since
30.0.0

Table of Contents

Methods

cancelTask()  : void
deleteTask()  : void
Delete a task that has been scheduled before
getAvailableTaskTypes()  : array<string, ShapeEnumValue[][]}>
getNextScheduledTask()  : Task
getPreferredProvider()  : IProvider
getProviders()  : array<string|int, IProvider>
getTask()  : Task
getTasks()  : array<int, Task>
getUserTask()  : Task
getUserTasks()  : array<int, Task>
getUserTasksByApp()  : array<int, Task>
hasProviders()  : bool
lockTask()  : bool
Changes the task status to STATUS_RUNNING and, if successful, returns True.
prepareInputData()  : array<string|int, array<int, (numeric)|string|File>|(numeric)|string|File>
Prepare the task's input data, so it can be processed by the provider ie. this replaces file ids with File objects
processTask()  : bool
Process task with a synchronous provider
runTask()  : Task
Run the task and return the finished task
scheduleTask()  : void
setTaskProgress()  : bool
setTaskResult()  : void
setTaskStatus()  : void

Methods

cancelTask()

public cancelTask(int $id) : void
Parameters
$id : int

The id of the task

Tags
throws
Exception

If the query failed

throws
NotFoundException

If the task could not be found

since
30.0.0

deleteTask()

Delete a task that has been scheduled before

public deleteTask(Task $task) : void
Parameters
$task : Task

The task to delete

Tags
throws
Exception

if deleting the task in the database failed

since
30.0.0

getAvailableTaskTypes()

public getAvailableTaskTypes() : array<string, ShapeEnumValue[][]}>
Tags
since
30.0.0
Return values
array<string, ShapeEnumValue[][]}>

getNextScheduledTask()

public getNextScheduledTask([array<int, string> $taskTypeIds = [] ][, array<int, int> $taskIdsToIgnore = [] ]) : Task
Parameters
$taskTypeIds : array<int, string> = []
$taskIdsToIgnore : array<int, int> = []
Tags
throws
Exception

If the query failed

throws
NotFoundException

If no task could not be found

since
30.0.0
Return values
Task

getTask()

public getTask(int $id) : Task
Parameters
$id : int

The id of the task

Tags
throws
Exception

If the query failed

throws
NotFoundException

If the task could not be found

since
30.0.0
Return values
Task

getTasks()

public getTasks(string|null $userId[, string|null $taskTypeId = null ][, string|null $appId = null ][, string|null $customId = null ][, int|null $status = null ][, int|null $scheduleAfter = null ][, int|null $endedBefore = null ]) : array<int, Task>
Parameters
$userId : string|null

The user id that scheduled the task

$taskTypeId : string|null = null

The task type id to filter by

$appId : string|null = null

The app ID of the app that submitted the task

$customId : string|null = null

The custom task ID

$status : int|null = null

The task status

$scheduleAfter : int|null = null

Minimum schedule time filter

$endedBefore : int|null = null

Maximum ending time filter

Tags
throws
Exception

If the query failed

throws
NotFoundException

If the task could not be found

since
30.0.0
Return values
array<int, Task>

getUserTask()

public getUserTask(int $id, string|null $userId) : Task
Parameters
$id : int

The id of the task

$userId : string|null

The user id that scheduled the task

Tags
throws
Exception

If the query failed

throws
NotFoundException

If the task could not be found

since
30.0.0
Return values
Task

getUserTasks()

public getUserTasks(string|null $userId[, string|null $taskTypeId = null ][, string|null $customId = null ]) : array<int, Task>
Parameters
$userId : string|null

The user id that scheduled the task

$taskTypeId : string|null = null

The task type id to filter by

$customId : string|null = null
Tags
throws
Exception

If the query failed

throws
NotFoundException

If the task could not be found

since
30.0.0
Return values
array<int, Task>

getUserTasksByApp()

public getUserTasksByApp(string|null $userId, string $appId[, string|null $customId = null ]) : array<int, Task>
Parameters
$userId : string|null
$appId : string
$customId : string|null = null
Tags
throws
Exception

If the query failed

throws
JsonException

If parsing the task input and output failed

since
30.0.0
Return values
array<int, Task>

hasProviders()

public hasProviders() : bool
Tags
since
30.0.0
Return values
bool

lockTask()

Changes the task status to STATUS_RUNNING and, if successful, returns True.

public lockTask(Task $task) : bool
Parameters
$task : Task
Tags
since
30.0.0
Return values
bool

prepareInputData()

Prepare the task's input data, so it can be processed by the provider ie. this replaces file ids with File objects

public prepareInputData(Task $task) : array<string|int, array<int, (numeric)|string|File>|(numeric)|string|File>
Parameters
$task : Task
Tags
throws
NotPermittedException
throws
GenericFileException
throws
LockedException
throws
ValidationException
throws
UnauthorizedException
since
30.0.0
Return values
array<string|int, array<int, (numeric)|string|File>|(numeric)|string|File>

processTask()

Process task with a synchronous provider

public processTask(Task $task, ISynchronousProvider $provider) : bool

Prepare task input data and run the process method of the provider This should only be used by OC\TaskProcessing\SynchronousBackgroundJob::run() and OCP\TaskProcessing\IManager::runTask()

Parameters
$task : Task
$provider : ISynchronousProvider
Tags
throws
Exception
since
30.0.0
Return values
bool

True if the task has run successfully

runTask()

Run the task and return the finished task

public runTask(Task $task) : Task
Parameters
$task : Task

The task to run

Tags
throws
PreConditionNotMetException

If no or not the requested provider was registered but this method was still called

throws
ValidationException

the given task input didn't pass validation against the task type's input shape and/or the providers optional input shape specs

throws
Exception

storing the task in the database failed

throws
UnauthorizedException

the user scheduling the task does not have access to the files used in the input

since
30.0.0
Return values
Task

The result task

scheduleTask()

public scheduleTask(Task $task) : void
Parameters
$task : Task

The task to run

Tags
throws
PreConditionNotMetException

If no or not the requested provider was registered but this method was still called

throws
ValidationException

the given task input didn't pass validation against the task type's input shape and/or the providers optional input shape specs

throws
Exception

storing the task in the database failed

throws
UnauthorizedException

the user scheduling the task does not have access to the files used in the input

since
30.0.0

setTaskProgress()

public setTaskProgress(int $id, float $progress) : bool
Parameters
$id : int
$progress : float
Tags
throws
ValidationException
throws
Exception
throws
NotFoundException
since
30.0.0
Return values
bool

true if the task should still be running; false if the task has been cancelled in the meantime

setTaskResult()

public setTaskResult(int $id, string|null $error, array<string|int, mixed>|null $result[, bool $isUsingFileIds = false ]) : void
Parameters
$id : int

The id of the task

$error : string|null
$result : array<string|int, mixed>|null
$isUsingFileIds : bool = false
Tags
throws
Exception

If the query failed

throws
NotFoundException

If the task could not be found

since
30.0.0

setTaskStatus()

public setTaskStatus(Task $task, int $status) : void
Parameters
$task : Task
$status : int
Tags
psalm-param

Task::STATUS_* $status

throws
JsonException
throws
Exception
since
30.0.0

        
On this page

Search results