1
0
Fork 0
mirror of synced 2024-06-27 02:31:04 +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);
}
$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()) {
throw new Exception('Tag not found. Deploy tag before trying to execute a function', 404);
if ($deployment->getAttribute('functionId') !== $function->getId()) {
throw new Exception('Deployment not found. Deploy deployment before trying to execute a function', 404);
}
if ($tag->isEmpty()) {
throw new Exception('Tag not found. Deploy tag before trying to execute a function', 404);
if ($deployment->isEmpty()) {
throw new Exception('Deployment not found. Deploy deployment before trying to execute a function', 404);
}
$validator = new Authorization('execute');
@ -877,7 +877,7 @@ App::post('/v1/functions/:functionId/executions')
'$write' => ['role:all'],
'dateCreated' => time(),
'functionId' => $function->getId(),
'tagId' => $tag->getId(),
'deploymentId' => $deployment->getId(),
'trigger' => 'http', // http / schedule / event
'status' => 'waiting', // waiting / processing / completed / failed
'statusCode' => 0,