From 5d1dda9e5e5120139c7d249402ef5f70b248f493 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Fri, 4 Sep 2020 15:15:22 +0300 Subject: [PATCH] Added the Task response model --- app/config/collections.php | 2 +- src/Appwrite/Utopia/Response.php | 2 + src/Appwrite/Utopia/Response/Model/Task.php | 57 ++++++++++++++++----- 3 files changed, 46 insertions(+), 15 deletions(-) diff --git a/app/config/collections.php b/app/config/collections.php index 64b63f74c6..546f7eb30f 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -4,7 +4,7 @@ use Utopia\App; use Utopia\Config\Config; use Appwrite\Database\Database; -$providers = Config::getParam('providers'); +$providers = Config::getParam('providers', []); $collections = [ 'console' => [ diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index 196fed8aa8..10da3899d8 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -20,6 +20,7 @@ use Appwrite\Utopia\Response\Model\Team; use Appwrite\Utopia\Response\Model\Locale; use Appwrite\Utopia\Response\Model\Membership; use Appwrite\Utopia\Response\Model\Tag; +use Appwrite\Utopia\Response\Model\Task; use Appwrite\Utopia\Response\Model\Webhook; class Response extends SwooleResponse @@ -118,6 +119,7 @@ class Response extends SwooleResponse ->setModel(new Execution()) ->setModel(new Webhook()) ->setModel(new Key()) + ->setModel(new Task()) // Locale // Continent // Country diff --git a/src/Appwrite/Utopia/Response/Model/Task.php b/src/Appwrite/Utopia/Response/Model/Task.php index b9efc19d24..e2ab652fe7 100644 --- a/src/Appwrite/Utopia/Response/Model/Task.php +++ b/src/Appwrite/Utopia/Response/Model/Task.php @@ -55,25 +55,54 @@ class Task extends Model 'example' => 'password', ]) ->addRule('duration', [ - 'type' => 'integer', + 'type' => 'float', 'description' => 'Task duration in seconds.', 'default' => 0, 'example' => 1.2, ]) + ->addRule('delay', [ + 'type' => 'float', + 'description' => 'Task delay time in seconds.', + 'default' => 0, + 'example' => 1.2, + ]) + ->addRule('failures', [ + 'type' => 'integer', + 'description' => 'Number of recurring task failures.', + 'default' => 0, + 'example' => 0, + ]) + ->addRule('schedule', [ + 'type' => 'string', + 'description' => 'Task schedule in CRON syntax.', + 'example' => '* * * * *', + ]) + ->addRule('status', [ + 'type' => 'string', + 'description' => 'Task status. Possible values: play, pause', // TODO - change to enabled disabled + 'example' => 'enabled', + ]) + ->addRule('updated', [ + 'type' => 'integer', + 'description' => 'Task last updated time in Unix timestamp.', + 'default' => 0, + 'example' => 1592981250, + ]) + ->addRule('previous', [ + 'type' => 'integer', + 'description' => 'Task previous run time in Unix timestamp.', + 'default' => 0, + 'example' => 1592981250, + ]) + ->addRule('next', [ + 'type' => 'integer', + 'description' => 'Task next run time in Unix timestamp.', + 'default' => 0, + 'example' => 1592981650, + ]) ; } - /* - delay: 6 - failures: 5 - log: "[{"code":411,"duration":1.82,"delay":6,"errors":["Request failed with status code 411"],"headers":"HTTP\/1.1 411 Length Required\r\nContent-Type: text\/html\r\nContent-Length: 357\r\nConnection: close\r\nDate: Sat, 21 Mar 2020 21:22:08 GMT\r\nServer: ECSF (nyb\/1D33)\r\n\r\n","body":""},{"code":411,"duration":1.86,"delay":4,"errors":["Request failed with status code 411"],"headers":"HTTP\/1.1 411 Length Required\r\nContent-Type: text\/html\r\nContent-Length: 357\r\nConnection: close\r\nDate: Sat, 21 Mar 2020 21:21:06 GMT\r\nServer: ECSF (nyb\/1D32)\r\n\r\n","body":""},{"code":411,"duration":1.82,"delay":2,"errors":["Request failed with status code 411"],"headers":"HTTP\/1.1 411 Length Required\r\nContent-Type: text\/html\r\nContent-Length: 357\r\nConnection: close\r\nDate: Sat, 21 Mar 2020 21:20:04 GMT\r\nServer: ECSF (nyb\/1D0A)\r\n\r\n","body":""},{"code":411,"duration":1.49,"delay":6,"errors":["Request failed with status code 411"],"headers":"HTTP\/1.1 411 Length Required\r\nContent-Type: text\/html\r\nContent-Length: 357\r\nConnection: close\r\nDate: Sat, 21 Mar 2020 21:19:07 GMT\r\nServer: ECSF (nyb\/1D04)\r\n\r\n","body":""},{"code":411,"duration":2.18,"delay":4,"errors":["Request failed with status code 411"],"headers":"HTTP\/1.1 411 Length Required\r\nContent-Type: text\/html\r\nContent-Length: 357\r\nConnection: close\r\nDate: Sat, 21 Mar 2020 21:18:05 GMT\r\nServer: ECSF (nyb\/1D23)\r\n\r\n","body":""}]" - schedule: "* * * * *" - status: "pause" - updated: 1594494053 - previous: 1584825726 - next: "1597439760" - */ - /** * Get Name * @@ -81,7 +110,7 @@ class Task extends Model */ public function getName():string { - return 'Webhook'; + return 'Task'; } /** @@ -91,6 +120,6 @@ class Task extends Model */ public function getType():string { - return Response::MODEL_WEBHOOK; + return Response::MODEL_TASK; } } \ No newline at end of file