From a127a63e7beff7d35e6ebc7100373609ab56567e Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Sat, 8 Aug 2020 14:01:23 +0300 Subject: [PATCH] Added execution response model --- src/Appwrite/Utopia/Response.php | 2 + .../Utopia/Response/Model/Execution.php | 80 +++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 src/Appwrite/Utopia/Response/Model/Execution.php diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index 609fba389..2b4082263 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -8,6 +8,7 @@ use Appwrite\Utopia\Response\Model; use Appwrite\Utopia\Response\Model\BaseList; use Appwrite\Utopia\Response\Model\Error; use Appwrite\Utopia\Response\Model\ErrorDev; +use Appwrite\Utopia\Response\Model\Execution; use Appwrite\Utopia\Response\Model\File; use Appwrite\Utopia\Response\Model\Func; use Appwrite\Utopia\Response\Model\User; @@ -87,6 +88,7 @@ class Response extends UtopiaResponse ->setModel(new Membership()) ->setModel(new Func()) ->setModel(new Tag()) + ->setModel(new Execution()) ; parent::__construct($time); diff --git a/src/Appwrite/Utopia/Response/Model/Execution.php b/src/Appwrite/Utopia/Response/Model/Execution.php new file mode 100644 index 000000000..92a00208d --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/Execution.php @@ -0,0 +1,80 @@ +addRule('$id', [ + 'type' => 'string', + 'description' => 'Execution ID.', + 'example' => '5e5ea5c16897e', + ]) + ->addRule('functionId', [ + 'type' => 'string', + 'description' => 'Function ID.', + 'example' => '5e5ea6g16897e', + ]) + ->addRule('dateCreated', [ + 'type' => 'integer', + 'description' => 'The execution creation date in Unix timestamp.', + 'example' => 1592981250, + ]) + ->addRule('trigger', [ + 'type' => 'string', + 'description' => 'The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`.', + 'example' => 'http', + ]) + ->addRule('status', [ + 'type' => 'string', + 'description' => 'The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`.', + 'example' => 'processing', + ]) + ->addRule('exitCode', [ + 'type' => 'integer', + 'description' => 'The script exit code.', + 'example' => 0, + ]) + ->addRule('stdout', [ + 'type' => 'string', + 'description' => 'The script stdout output string.', + 'example' => '', + ]) + ->addRule('stderr', [ + 'type' => 'string', + 'description' => 'The script stderr output string.', + 'example' => '', + ]) + ->addRule('time', [ + 'type' => 'float', + 'description' => 'The script execution time in seconds.', + 'example' => 0.400, + ]) + ; + } + + /** + * Get Name + * + * @return string + */ + public function getName():string + { + return 'Execution'; + } + + /** + * Get Collection + * + * @return string + */ + public function getType():string + { + return Response::MODEL_EXECUTION; + } +} \ No newline at end of file