From 4afd9771c6e0d8f7d45bcdde5abbaf5081f80e5d Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Thu, 27 Feb 2025 23:42:43 +0530 Subject: [PATCH] Remove functions.php --- app/controllers/api/functions.php | 4 ---- .../Functions/Http/Deployments/Delete.php | 20 +++++++++---------- .../Modules/Functions/Http/Templates/Get.php | 1 - .../Functions/Http/Templates/XList.php | 1 - .../Modules/Sites/Http/Templates/Get.php | 1 - .../Modules/Sites/Http/Templates/XList.php | 1 - 6 files changed, 10 insertions(+), 18 deletions(-) delete mode 100644 app/controllers/api/functions.php diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php deleted file mode 100644 index edf673745e..0000000000 --- a/app/controllers/api/functions.php +++ /dev/null @@ -1,4 +0,0 @@ -callback([$this, 'action']); } - public function action(string $siteId, string $deploymentId, Response $response, Database $dbForProject, DeleteEvent $queueForDeletes, Event $queueForEvents, Device $deviceForSites) + public function action(string $functionId, string $deploymentId, Response $response, Database $dbForProject, DeleteEvent $queueForDeletes, Event $queueForEvents, Device $deviceForFunctions) { - $site = $dbForProject->getDocument('sites', $siteId); - if ($site->isEmpty()) { - throw new Exception(Exception::SITE_NOT_FOUND); + $function = $dbForProject->getDocument('functions', $functionId); + if ($function->isEmpty()) { + throw new Exception(Exception::FUNCTION_NOT_FOUND); } $deployment = $dbForProject->getDocument('deployments', $deploymentId); @@ -75,7 +75,7 @@ class Delete extends Action throw new Exception(Exception::DEPLOYMENT_NOT_FOUND); } - if ($deployment->getAttribute('resourceId') !== $site->getId()) { + if ($deployment->getAttribute('resourceId') !== $function->getId()) { throw new Exception(Exception::DEPLOYMENT_NOT_FOUND); } @@ -84,20 +84,20 @@ class Delete extends Action } if (!empty($deployment->getAttribute('path', ''))) { - if (!($deviceForSites->delete($deployment->getAttribute('path', '')))) { + if (!($deviceForFunctions->delete($deployment->getAttribute('path', '')))) { throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Failed to remove deployment from storage'); } } - if ($site->getAttribute('deployment') === $deployment->getId()) { // Reset site deployment - $site = $dbForProject->updateDocument('sites', $site->getId(), new Document(array_merge($site->getArrayCopy(), [ - 'deploymentId' => '', + if ($function->getAttribute('deployment') === $deployment->getId()) { // Reset function deployment + $function = $dbForProject->updateDocument('functions', $function->getId(), new Document(array_merge($function->getArrayCopy(), [ + 'deployment' => '', 'deploymentInternalId' => '', ]))); } $queueForEvents - ->setParam('siteId', $site->getId()) + ->setParam('functionId', $function->getId()) ->setParam('deploymentId', $deployment->getId()); $queueForDeletes diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Templates/Get.php b/src/Appwrite/Platform/Modules/Functions/Http/Templates/Get.php index 4b84f777de..e624b26de6 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Templates/Get.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Templates/Get.php @@ -29,7 +29,6 @@ class Get extends Base ->setHttpMethod(Action::HTTP_REQUEST_METHOD_GET) ->setHttpPath('/v1/functions/templates/:templateId') ->desc('Get function template') - ->groups(['api']) ->label('scope', 'public') ->label('resourceType', RESOURCE_TYPE_FUNCTIONS) ->label('sdk', new Method( diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Templates/XList.php b/src/Appwrite/Platform/Modules/Functions/Http/Templates/XList.php index ebf9ee28d4..310ed89fdf 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Templates/XList.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Templates/XList.php @@ -30,7 +30,6 @@ class XList extends Base ->setHttpMethod(Action::HTTP_REQUEST_METHOD_GET) ->setHttpPath('/v1/functions/templates') ->desc('List function templates') - ->groups(['api']) ->label('scope', 'public') ->label('resourceType', RESOURCE_TYPE_FUNCTIONS) ->label('sdk', new Method( diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Templates/Get.php b/src/Appwrite/Platform/Modules/Sites/Http/Templates/Get.php index 977bfe7fd1..9d2991bce9 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Templates/Get.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Templates/Get.php @@ -29,7 +29,6 @@ class Get extends Base ->setHttpMethod(Action::HTTP_REQUEST_METHOD_GET) ->setHttpPath('/v1/sites/templates/:templateId') ->desc('Get site template') - ->groups(['api']) ->label('scope', 'public') ->label('sdk', new Method( namespace: 'sites', diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Templates/XList.php b/src/Appwrite/Platform/Modules/Sites/Http/Templates/XList.php index 277cc2c615..3c27b75578 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Templates/XList.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Templates/XList.php @@ -30,7 +30,6 @@ class XList extends Base ->setHttpMethod(Action::HTTP_REQUEST_METHOD_GET) ->setHttpPath('/v1/sites/templates') ->desc('List templates') - ->groups(['api']) ->label('scope', 'public') ->label('sdk', new Method( namespace: 'sites',