From f712345677dbd8c23394fb35ff4b3f7da46927ea Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Tue, 25 Jan 2022 03:16:53 +0400 Subject: [PATCH] feat: update create-execution endpoint --- app/controllers/api/functions.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 7aecc5f2b..6a5eba151 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -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,