gitea/src/6e1a6731-2587-4ad5-8e70-ca8.../code.power

46 lines
961 B
Plaintext

/**
* List cron tasks.
*
* @param int $page Page number of results to return (1-based).
* @param int $limit Page size of results.
*
* @return array|null
* @since 3.2.0
**/
public function list(int $page = 1, int $limit = 10): ?array
{
// Build the request path.
$path = "/admin/cron";
// Set the query parameters.
$uri = $this->uri->get($path);
$uri->setVar('page', $page);
$uri->setVar('limit', $limit);
// Send the get request.
return $this->response->get(
$this->http->get($uri)
);
}
/**
* Run cron task.
*
* @param string $task The cron task to run.
*
* @return string
* @since 3.2.0
**/
public function run(string $task): string
{
// Build the request path.
$path = "/admin/cron/{$task}";
// Send the post request.
return $this->response->get(
$this->http->post(
$this->uri->get($path)
), 204, 'success'
);
}