1
0
Fork 0
mirror of synced 2024-07-01 20:50:49 +12:00

feat: update create-execution endpoint

This commit is contained in:
Christy Jacob 2022-01-25 03:16:53 +04:00
parent 43e3f23a4e
commit f712345677

View file

@ -853,14 +853,14 @@ App::post('/v1/functions/:functionId/executions')
throw new Exception('Function not found', 404); throw new Exception('Function not found', 404);
} }
$tag = Authorization::skip(fn() => $dbForProject->getDocument('tags', $function->getAttribute('tag'))); $deployment = Authorization::skip(fn() => $dbForProject->getDocument('deployments', $function->getAttribute('deployment')));
if ($tag->getAttribute('functionId') !== $function->getId()) { if ($deployment->getAttribute('functionId') !== $function->getId()) {
throw new Exception('Tag not found. Deploy tag before trying to execute a function', 404); throw new Exception('Deployment not found. Deploy deployment before trying to execute a function', 404);
} }
if ($tag->isEmpty()) { if ($deployment->isEmpty()) {
throw new Exception('Tag not found. Deploy tag before trying to execute a function', 404); throw new Exception('Deployment not found. Deploy deployment before trying to execute a function', 404);
} }
$validator = new Authorization('execute'); $validator = new Authorization('execute');
@ -877,7 +877,7 @@ App::post('/v1/functions/:functionId/executions')
'$write' => ['role:all'], '$write' => ['role:all'],
'dateCreated' => time(), 'dateCreated' => time(),
'functionId' => $function->getId(), 'functionId' => $function->getId(),
'tagId' => $tag->getId(), 'deploymentId' => $deployment->getId(),
'trigger' => 'http', // http / schedule / event 'trigger' => 'http', // http / schedule / event
'status' => 'waiting', // waiting / processing / completed / failed 'status' => 'waiting', // waiting / processing / completed / failed
'statusCode' => 0, 'statusCode' => 0,