feat: update create-execution endpoint
This commit is contained in:
parent
43e3f23a4e
commit
f712345677
1 changed files with 6 additions and 6 deletions
|
@ -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,
|
||||||
|
|
Loading…
Reference in a new issue