diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e89aa369cf..19fd9e3d48 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -163,6 +163,28 @@ Other containes should be named the same as their service, for example `redis` s - [Encryption](https://medium.com/searchencrypt/what-is-encryption-how-does-it-work-e8f20e340537#:~:text=Encryption%20is%20a%20process%20that,%2C%20or%20decrypt%2C%20the%20information.) - [Hashing](https://searchsqlserver.techtarget.com/definition/hashing#:~:text=Hashing%20is%20the%20transformation%20of,it%20using%20the%20original%20value.) +## Modules + +As Appwrite grows, we noticed approach of having all service endpoints in `app/controllers/api/[service].php` is not maintainable. Not only it creates massive files, it also doesnt contain all product's features such as workers or tasks. While there might still be some occurances of those controller files, we avoid it in all new development, and gradually migrate existing controllers to **HTTP modules**. + +### HTTP Endpoints + +Every endpoint file follows below structure, making it consistent with HTTP REST endpoint path: + +``` +src/Appwrite/Platform/Modules/[service]/Http/[resource]/[action].php +``` + +Tips and tricks: + +1. If endpoint doesn't have resource, use service name as resource name too +> Example: `Modules/Sites/Http/Sites/Get.php` + +2. If there are multiple resources, use then all in folder structure +> Example: `Modules/Sites/Http/Deployments/Builds/Create.php` + +3. Action can only be `Get`, `Create`, `Update`, `Delete` or `XList` + ## Architecture Appwrite's current structure is a combination of both [Monolithic](https://en.wikipedia.org/wiki/Monolithic_application) and [Microservice](https://en.wikipedia.org/wiki/Microservices) architectures. diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index ba0251afd5..888ff35382 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -18,7 +18,6 @@ use Appwrite\SDK\MethodType; use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Database\Validator\Queries\Deployments; use Appwrite\Utopia\Database\Validator\Queries\Executions; -use Appwrite\Utopia\Database\Validator\Queries\Functions; use Appwrite\Utopia\Response; use Executor\Executor; use MaxMind\Db\Reader; @@ -48,84 +47,9 @@ use Utopia\Validator\Boolean; use Utopia\Validator\Range; use Utopia\Validator\Text; use Utopia\Validator\WhiteList; -use Utopia\VCS\Adapter\Git\GitHub; -use Utopia\VCS\Exception\RepositoryNotFound; include_once __DIR__ . '/../shared/api.php'; -// $redeployVcs = function (Request $request, Document $function, Document $project, Document $installation, Database $dbForProject, Build $queueForBuilds, Document $template, GitHub $github) { -// $deploymentId = ID::unique(); -// $entrypoint = $function->getAttribute('entrypoint', ''); -// $providerInstallationId = $installation->getAttribute('providerInstallationId', ''); -// $privateKey = System::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY'); -// $githubAppId = System::getEnv('_APP_VCS_GITHUB_APP_ID'); -// $github->initializeVariables($providerInstallationId, $privateKey, $githubAppId); -// $owner = $github->getOwnerName($providerInstallationId); -// $providerRepositoryId = $function->getAttribute('providerRepositoryId', ''); -// try { -// $repositoryName = $github->getRepositoryName($providerRepositoryId) ?? ''; -// if (empty($repositoryName)) { -// throw new Exception(Exception::PROVIDER_REPOSITORY_NOT_FOUND); -// } -// } catch (RepositoryNotFound $e) { -// throw new Exception(Exception::PROVIDER_REPOSITORY_NOT_FOUND); -// } -// $providerBranch = $function->getAttribute('providerBranch', 'main'); -// $authorUrl = "https://github.com/$owner"; -// $repositoryUrl = "https://github.com/$owner/$repositoryName"; -// $branchUrl = "https://github.com/$owner/$repositoryName/tree/$providerBranch"; - -// $commitDetails = []; -// if ($template->isEmpty()) { -// try { -// $commitDetails = $github->getLatestCommit($owner, $repositoryName, $providerBranch); -// } catch (\Throwable $error) { -// Console::warning('Failed to get latest commit details'); -// Console::warning($error->getMessage()); -// Console::warning($error->getTraceAsString()); -// } -// } - -// $deployment = $dbForProject->createDocument('deployments', new Document([ -// '$id' => $deploymentId, -// '$permissions' => [ -// Permission::read(Role::any()), -// Permission::update(Role::any()), -// Permission::delete(Role::any()), -// ], -// 'resourceId' => $function->getId(), -// 'resourceInternalId' => $function->getInternalId(), -// 'resourceType' => 'functions', -// 'entrypoint' => $entrypoint, -// 'commands' => $function->getAttribute('commands', ''), -// 'type' => 'vcs', -// 'installationId' => $installation->getId(), -// 'installationInternalId' => $installation->getInternalId(), -// 'providerRepositoryId' => $providerRepositoryId, -// 'repositoryId' => $function->getAttribute('repositoryId', ''), -// 'repositoryInternalId' => $function->getAttribute('repositoryInternalId', ''), -// 'providerBranchUrl' => $branchUrl, -// 'providerRepositoryName' => $repositoryName, -// 'providerRepositoryOwner' => $owner, -// 'providerRepositoryUrl' => $repositoryUrl, -// 'providerCommitHash' => $commitDetails['commitHash'] ?? '', -// 'providerCommitAuthorUrl' => $authorUrl, -// 'providerCommitAuthor' => $commitDetails['commitAuthor'] ?? '', -// 'providerCommitMessage' => $commitDetails['commitMessage'] ?? '', -// 'providerCommitUrl' => $commitDetails['commitUrl'] ?? '', -// 'providerBranch' => $providerBranch, -// 'providerRootDirectory' => $function->getAttribute('providerRootDirectory', ''), -// 'search' => implode(' ', [$deploymentId, $entrypoint]), -// 'activate' => true, -// ])); - -// $queueForBuilds -// ->setType(BUILD_TYPE_DEPLOYMENT) -// ->setResource($function) -// ->setDeployment($deployment) -// ->setTemplate($template); -// }; - App::get('/v1/functions/specifications') ->groups(['api', 'functions']) ->desc('List available function runtime specifications') diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/CreateDeployment.php b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Create.php similarity index 99% rename from src/Appwrite/Platform/Modules/Functions/Http/Deployments/CreateDeployment.php rename to src/Appwrite/Platform/Modules/Functions/Http/Deployments/Create.php index 70a10b141d..15b63c1f70 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/CreateDeployment.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Create.php @@ -29,7 +29,7 @@ use Utopia\System\System; use Utopia\Validator\Boolean; use Utopia\Validator\Text; -class CreateDeployment extends Action +class Create extends Action { use HTTP; diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Functions/CreateFunction.php b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Create.php similarity index 99% rename from src/Appwrite/Platform/Modules/Functions/Http/Functions/CreateFunction.php rename to src/Appwrite/Platform/Modules/Functions/Http/Functions/Create.php index f573f23f8c..e66421b40e 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Functions/CreateFunction.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Create.php @@ -38,7 +38,7 @@ use Utopia\Validator\Text; use Utopia\Validator\WhiteList; use Utopia\VCS\Adapter\Git\GitHub; -class CreateFunction extends Base +class Create extends Base { use HTTP; @@ -62,7 +62,7 @@ class CreateFunction extends Base ->label('sdk', new Method( namespace: 'functions', name: 'create', - description: '/docs/references/functions/create-function.md', + description: '/docs/references/functions/create.md', auth: [AuthType::KEY], responses: [ new SDKResponse( diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Functions/UpdateFunction.php b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Update.php similarity index 99% rename from src/Appwrite/Platform/Modules/Functions/Http/Functions/UpdateFunction.php rename to src/Appwrite/Platform/Modules/Functions/Http/Functions/Update.php index f8a76e08e4..fc10b60229 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Functions/UpdateFunction.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Update.php @@ -38,7 +38,7 @@ use Utopia\Validator\Text; use Utopia\Validator\WhiteList; use Utopia\VCS\Adapter\Git\GitHub; -class UpdateFunction extends Base +class Update extends Base { use HTTP; diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Functions/ListFunctions.php b/src/Appwrite/Platform/Modules/Functions/Http/Functions/XList.php similarity index 99% rename from src/Appwrite/Platform/Modules/Functions/Http/Functions/ListFunctions.php rename to src/Appwrite/Platform/Modules/Functions/Http/Functions/XList.php index de17a65fe3..518dda1a40 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Functions/ListFunctions.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Functions/XList.php @@ -18,7 +18,7 @@ use Utopia\Platform\Action; use Utopia\Platform\Scope\HTTP; use Utopia\Validator\Text; -class ListFunctions extends Base +class XList extends Base { use HTTP; diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Functions/ListRuntimes.php b/src/Appwrite/Platform/Modules/Functions/Http/Runtimes/XList.php similarity index 95% rename from src/Appwrite/Platform/Modules/Functions/Http/Functions/ListRuntimes.php rename to src/Appwrite/Platform/Modules/Functions/Http/Runtimes/XList.php index 7957055486..e7512fa84d 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Functions/ListRuntimes.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Runtimes/XList.php @@ -1,6 +1,6 @@ label('audits.resource', 'site/{request.siteId}') ->label('sdk', new Method( namespace: 'sites', - name: 'createBuild', - description: '/docs/references/sites/create-build.md', + name: 'createDeploymentBuild', + description: '/docs/references/sites/create-deployment-build.md', auth: [AuthType::KEY], responses: [ new SDKResponse( diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/DownloadBuild.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Builds/Download/Get.php similarity index 94% rename from src/Appwrite/Platform/Modules/Sites/Http/Deployments/DownloadBuild.php rename to src/Appwrite/Platform/Modules/Sites/Http/Deployments/Builds/Download/Get.php index 5b266ad24f..8871d60463 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/DownloadBuild.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Builds/Download/Get.php @@ -1,6 +1,6 @@ label('scope', 'sites.read') ->label('sdk.auth', [APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT]) ->label('sdk.namespace', 'sites') - ->label('sdk.method', 'getBuildDownload') - ->label('sdk.description', '/docs/references/sites/get-build-download.md') + ->label('sdk.method', 'getDeploymentBuildDownload') + ->label('sdk.description', '/docs/references/sites/get-deployment-build-download.md') ->label('sdk.response.code', Response::STATUS_CODE_OK) ->label('sdk.response.type', '*/*') ->label('sdk.methodType', 'location') diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/CancelDeployment.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Builds/Update.php similarity index 94% rename from src/Appwrite/Platform/Modules/Sites/Http/Deployments/CancelDeployment.php rename to src/Appwrite/Platform/Modules/Sites/Http/Deployments/Builds/Update.php index f19d1f0ba6..00d004f8ff 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/CancelDeployment.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Builds/Update.php @@ -1,6 +1,6 @@ label('audits.event', 'deployment.update') ->label('audits.resource', 'site/{request.siteId}') ->label('sdk', new Method( - namespace: 'functions', + namespace: 'sites', name: 'updateDeploymentBuild', - description: '/docs/references/functions/update-deployment-build.md', + description: '/docs/references/sites/update-deployment-build.md', auth: [AuthType::KEY], responses: [ new SDKResponse( diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/CreateDeployment.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php similarity index 99% rename from src/Appwrite/Platform/Modules/Sites/Http/Deployments/CreateDeployment.php rename to src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php index cf069f4547..e15324600b 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/CreateDeployment.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php @@ -30,7 +30,7 @@ use Utopia\System\System; use Utopia\Validator\Boolean; use Utopia\Validator\Text; -class CreateDeployment extends Action +class Create extends Action { use HTTP; diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/DeleteDeployment.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Delete.php similarity index 98% rename from src/Appwrite/Platform/Modules/Sites/Http/Deployments/DeleteDeployment.php rename to src/Appwrite/Platform/Modules/Sites/Http/Deployments/Delete.php index 4dca0ef146..6c8d2203f3 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/DeleteDeployment.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Delete.php @@ -2,7 +2,7 @@ namespace Appwrite\Platform\Modules\Sites\Http\Deployments; -use Appwrite\Event\Delete; +use Appwrite\Event\Delete as DeleteEvent; use Appwrite\Event\Event; use Appwrite\Extend\Exception; use Appwrite\SDK\AuthType; @@ -17,7 +17,7 @@ use Utopia\Platform\Action; use Utopia\Platform\Scope\HTTP; use Utopia\Storage\Device; -class DeleteDeployment extends Action +class Delete extends Action { use HTTP; diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/DownloadDeployment.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Download/Get.php similarity index 96% rename from src/Appwrite/Platform/Modules/Sites/Http/Deployments/DownloadDeployment.php rename to src/Appwrite/Platform/Modules/Sites/Http/Deployments/Download/Get.php index e9e2ab146f..e216989dd1 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/DownloadDeployment.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Download/Get.php @@ -1,6 +1,6 @@ label('audits.event', 'deployment.update') ->label('audits.resource', 'site/{request.siteId}') ->label('sdk', new Method( - namespace: 'functions', + namespace: 'sites', name: 'updateDeployment', - description: '/docs/references/functions/update-function-deployment.md', + description: '/docs/references/sites/update-deployment.md', auth: [AuthType::KEY], responses: [ new SDKResponse( diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/ListDeployments.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/XList.php similarity index 99% rename from src/Appwrite/Platform/Modules/Sites/Http/Deployments/ListDeployments.php rename to src/Appwrite/Platform/Modules/Sites/Http/Deployments/XList.php index 7ad71e7212..fab3db3cba 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/ListDeployments.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/XList.php @@ -19,7 +19,7 @@ use Utopia\Platform\Action; use Utopia\Platform\Scope\HTTP; use Utopia\Validator\Text; -class ListDeployments extends Action +class XList extends Action { use HTTP; diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/ListFrameworks.php b/src/Appwrite/Platform/Modules/Sites/Http/Frameworks/XList.php similarity index 95% rename from src/Appwrite/Platform/Modules/Sites/Http/Sites/ListFrameworks.php rename to src/Appwrite/Platform/Modules/Sites/Http/Frameworks/XList.php index 8142a40886..1afdbdcc12 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/ListFrameworks.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Frameworks/XList.php @@ -1,6 +1,6 @@ label('event', 'sites.[siteId].logs.[logId].delete') ->label('audits.event', 'logs.delete') ->label('audits.resource', 'site/{request.siteId}') - ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) - ->label('sdk.namespace', 'sites') - ->label('sdk.method', 'deleteLog') - ->label('sdk.description', '/docs/references/sites/delete-log.md') // TODO: add this file - ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) - ->label('sdk.response.model', Response::MODEL_NONE) + ->label('sdk', new Method( + namespace: 'sites', + name: 'deleteLog', + description: '/docs/references/sites/delete-log.md', + auth: [AuthType::KEY], + responses: [ + new SDKResponse( + code: Response::STATUS_CODE_NOCONTENT, + model: Response::MODEL_NONE, + ) + ] + )) ->param('siteId', '', new UID(), 'Site ID.') ->param('logId', '', new UID(), 'Log ID.') ->inject('response') diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Logs/GetLog.php b/src/Appwrite/Platform/Modules/Sites/Http/Logs/Get.php similarity index 75% rename from src/Appwrite/Platform/Modules/Sites/Http/Logs/GetLog.php rename to src/Appwrite/Platform/Modules/Sites/Http/Logs/Get.php index 0106e6082b..e2f4363311 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Logs/GetLog.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Logs/Get.php @@ -4,13 +4,16 @@ namespace Appwrite\Platform\Modules\Sites\Http\Logs; use Appwrite\Extend\Exception; use Appwrite\Platform\Modules\Compute\Base; +use Appwrite\SDK\AuthType; +use Appwrite\SDK\Method; +use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response; use Utopia\Database\Database; use Utopia\Database\Validator\UID; use Utopia\Platform\Action; use Utopia\Platform\Scope\HTTP; -class GetLog extends Base +class Get extends Base { use HTTP; @@ -27,13 +30,18 @@ class GetLog extends Base ->desc('Get log') ->groups(['api', 'sites']) ->label('scope', 'log.read') - ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) - ->label('sdk.namespace', 'sites') - ->label('sdk.method', 'getLog') - ->label('sdk.description', '/docs/references/sites/get-log.md') // TODO: add this file - ->label('sdk.response.code', Response::STATUS_CODE_OK) - ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) - ->label('sdk.response.model', Response::MODEL_EXECUTION) + ->label('sdk', new Method( + namespace: 'sites', + name: 'getLog', + description: '/docs/references/sites/get-log.md', + auth: [AuthType::KEY], + responses: [ + new SDKResponse( + code: Response::STATUS_CODE_OK, + model: Response::MODEL_EXECUTION, + ) + ] + )) ->param('siteId', '', new UID(), 'Site ID.') ->param('logId', '', new UID(), 'Log ID.') ->inject('response') diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Logs/ListLogs.php b/src/Appwrite/Platform/Modules/Sites/Http/Logs/XList.php similarity index 87% rename from src/Appwrite/Platform/Modules/Sites/Http/Logs/ListLogs.php rename to src/Appwrite/Platform/Modules/Sites/Http/Logs/XList.php index d972bae95c..c84428822a 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Logs/ListLogs.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Logs/XList.php @@ -4,6 +4,9 @@ namespace Appwrite\Platform\Modules\Sites\Http\Logs; use Appwrite\Extend\Exception; use Appwrite\Platform\Modules\Compute\Base; +use Appwrite\SDK\AuthType; +use Appwrite\SDK\Method; +use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Database\Validator\Queries\Executions; use Appwrite\Utopia\Database\Validator\Queries\Logs; use Appwrite\Utopia\Response; @@ -17,7 +20,7 @@ use Utopia\Platform\Action; use Utopia\Platform\Scope\HTTP; use Utopia\Validator\Text; -class ListLogs extends Base +class XList extends Base { use HTTP; @@ -35,13 +38,18 @@ class ListLogs extends Base ->groups(['api', 'sites']) ->label('scope', 'log.read') ->label('resourceType', RESOURCE_TYPE_SITES) - ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) - ->label('sdk.namespace', 'sites') - ->label('sdk.method', 'listLogs') - ->label('sdk.description', '/docs/references/sites/list-logs.md') // TODO: add this file - ->label('sdk.response.code', Response::STATUS_CODE_OK) - ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) - ->label('sdk.response.model', Response::MODEL_EXECUTION_LIST) // TODO: Update this later + ->label('sdk', new Method( + namespace: 'sites', + name: 'listLogs', + description: '/docs/references/sites/get-log.md', + auth: [AuthType::KEY], + responses: [ + new SDKResponse( + code: Response::STATUS_CODE_OK, + model: Response::MODEL_EXECUTION_LIST, + ) + ] + )) ->param('siteId', '', new UID(), 'Site ID.') ->param('queries', [], new Logs(), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' queries are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long. You may filter on the following attributes: ' . implode(', ', Executions::ALLOWED_ATTRIBUTES), true) ->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true) diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Create.php similarity index 99% rename from src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php rename to src/Appwrite/Platform/Modules/Sites/Http/Sites/Create.php index 1fa4910a23..5d3e162af0 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Create.php @@ -32,7 +32,7 @@ use Utopia\Validator\Text; use Utopia\Validator\WhiteList; use Utopia\VCS\Adapter\Git\GitHub; -class CreateSite extends Base +class Create extends Base { use HTTP; @@ -55,7 +55,7 @@ class CreateSite extends Base ->label('sdk', new Method( namespace: 'site', name: 'create', - description: '/docs/references/sites/create-site.md', + description: '/docs/references/sites/create.md', auth: [AuthType::KEY], responses: [ new SDKResponse( diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/DeleteSite.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Delete.php similarity index 91% rename from src/Appwrite/Platform/Modules/Sites/Http/Sites/DeleteSite.php rename to src/Appwrite/Platform/Modules/Sites/Http/Sites/Delete.php index 7029aa8ea1..4ceb9b744c 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/DeleteSite.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Delete.php @@ -2,7 +2,7 @@ namespace Appwrite\Platform\Modules\Sites\Http\Sites; -use Appwrite\Event\Delete; +use Appwrite\Event\Delete as DeleteEvent; use Appwrite\Event\Event; use Appwrite\Extend\Exception; use Appwrite\Platform\Modules\Compute\Base; @@ -16,7 +16,7 @@ use Utopia\Database\Validator\UID; use Utopia\Platform\Action; use Utopia\Platform\Scope\HTTP; -class DeleteSite extends Base +class Delete extends Base { use HTTP; @@ -39,7 +39,7 @@ class DeleteSite extends Base ->label('sdk', new Method( namespace: 'sites', name: 'delete', - description: '/docs/references/sites/delete-site.md', + description: '/docs/references/sites/delete.md', auth: [AuthType::KEY], responses: [ new SDKResponse( @@ -57,7 +57,7 @@ class DeleteSite extends Base ->callback([$this, 'action']); } - public function action(string $siteId, Response $response, Database $dbForProject, Delete $queueForDeletes, Event $queueForEvents) + public function action(string $siteId, Response $response, Database $dbForProject, DeleteEvent $queueForDeletes, Event $queueForEvents) { $site = $dbForProject->getDocument('sites', $siteId); diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/GetSite.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Get.php similarity index 94% rename from src/Appwrite/Platform/Modules/Sites/Http/Sites/GetSite.php rename to src/Appwrite/Platform/Modules/Sites/Http/Sites/Get.php index ce08c2568c..c685fccfaf 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/GetSite.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Get.php @@ -13,7 +13,7 @@ use Utopia\Database\Validator\UID; use Utopia\Platform\Action; use Utopia\Platform\Scope\HTTP; -class GetSite extends Base +class Get extends Base { use HTTP; @@ -34,7 +34,7 @@ class GetSite extends Base ->label('sdk', new Method( namespace: 'sites', name: 'get', - description: '/docs/references/sites/get-site.md', + description: '/docs/references/sites/get.md', auth: [AuthType::KEY], responses: [ new SDKResponse( diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/UpdateSite.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php similarity index 98% rename from src/Appwrite/Platform/Modules/Sites/Http/Sites/UpdateSite.php rename to src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php index cd3df7e121..6a2bc00b1b 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/UpdateSite.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php @@ -31,7 +31,7 @@ use Utopia\Validator\Text; use Utopia\Validator\WhiteList; use Utopia\VCS\Adapter\Git\GitHub; -class UpdateSite extends Base +class Update extends Base { use HTTP; @@ -53,12 +53,12 @@ class UpdateSite extends Base ->label('sdk', new Method( namespace: 'sites', name: 'update', - description: '/docs/references/sites/update-site.md', + description: '/docs/references/sites/update.md', auth: [AuthType::KEY], responses: [ new SDKResponse( code: Response::STATUS_CODE_OK, - model: Response::MODEL_FUNCTION, + model: Response::MODEL_SITE, ) ] )) diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/ListSites.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/XList.php similarity index 97% rename from src/Appwrite/Platform/Modules/Sites/Http/Sites/ListSites.php rename to src/Appwrite/Platform/Modules/Sites/Http/Sites/XList.php index 98beb4f158..08d4adb474 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/ListSites.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/XList.php @@ -18,7 +18,7 @@ use Utopia\Platform\Action; use Utopia\Platform\Scope\HTTP; use Utopia\Validator\Text; -class ListSites extends Base +class XList extends Base { use HTTP; @@ -38,7 +38,7 @@ class ListSites extends Base ->label('sdk', new Method( namespace: 'sites', name: 'list', - description: '/docs/references/sites/list-sites.md', + description: '/docs/references/sites/list.md', auth: [AuthType::KEY], responses: [ new SDKResponse( diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/GetTemplate.php b/src/Appwrite/Platform/Modules/Sites/Http/Templates/Get.php similarity index 95% rename from src/Appwrite/Platform/Modules/Sites/Http/Sites/GetTemplate.php rename to src/Appwrite/Platform/Modules/Sites/Http/Templates/Get.php index 82ebf54d59..31e54070d2 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/GetTemplate.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Templates/Get.php @@ -1,6 +1,6 @@ label('scope', 'sites.read') ->label('sdk', new Method( namespace: 'sites', - name: 'getSiteUsage', - description: '/docs/references/sites/get-site-usage.md', + name: 'getUsage', + description: '/docs/references/sites/get-usage.md', auth: [AuthType::ADMIN], responses: [ new SDKResponse( diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/GetSitesUsage.php b/src/Appwrite/Platform/Modules/Sites/Http/Usage/XList.php similarity index 95% rename from src/Appwrite/Platform/Modules/Sites/Http/Sites/GetSitesUsage.php rename to src/Appwrite/Platform/Modules/Sites/Http/Usage/XList.php index 81babe71ee..1c8991d4b2 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/GetSitesUsage.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Usage/XList.php @@ -1,6 +1,6 @@ label('scope', 'sites.read') ->label('sdk', new Method( namespace: 'sites', - name: 'getUsage', - description: '/docs/references/sites/get-sites-usage.md', + name: 'listUsage', + description: '/docs/references/sites/list-usage.md', auth: [AuthType::ADMIN], responses: [ new SDKResponse( diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Variables/CreateVariable.php b/src/Appwrite/Platform/Modules/Sites/Http/Variables/Create.php similarity index 99% rename from src/Appwrite/Platform/Modules/Sites/Http/Variables/CreateVariable.php rename to src/Appwrite/Platform/Modules/Sites/Http/Variables/Create.php index 616cd19303..21d4452f13 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Variables/CreateVariable.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Variables/Create.php @@ -20,7 +20,7 @@ use Utopia\Platform\Scope\HTTP; use Utopia\Validator\Boolean; use Utopia\Validator\Text; -class CreateVariable extends Base +class Create extends Base { use HTTP; diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Variables/DeleteVariable.php b/src/Appwrite/Platform/Modules/Sites/Http/Variables/Delete.php similarity index 98% rename from src/Appwrite/Platform/Modules/Sites/Http/Variables/DeleteVariable.php rename to src/Appwrite/Platform/Modules/Sites/Http/Variables/Delete.php index 233c115190..bbea1a7611 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Variables/DeleteVariable.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Variables/Delete.php @@ -14,7 +14,7 @@ use Utopia\Database\Validator\UID; use Utopia\Platform\Action; use Utopia\Platform\Scope\HTTP; -class DeleteVariable extends Base +class Delete extends Base { use HTTP; diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Variables/GetVariable.php b/src/Appwrite/Platform/Modules/Sites/Http/Variables/Get.php similarity index 98% rename from src/Appwrite/Platform/Modules/Sites/Http/Variables/GetVariable.php rename to src/Appwrite/Platform/Modules/Sites/Http/Variables/Get.php index 751ae82af5..edde40a2aa 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Variables/GetVariable.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Variables/Get.php @@ -13,7 +13,7 @@ use Utopia\Database\Validator\UID; use Utopia\Platform\Action; use Utopia\Platform\Scope\HTTP; -class GetVariable extends Base +class Get extends Base { use HTTP; diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Variables/UpdateVariable.php b/src/Appwrite/Platform/Modules/Sites/Http/Variables/Update.php similarity index 98% rename from src/Appwrite/Platform/Modules/Sites/Http/Variables/UpdateVariable.php rename to src/Appwrite/Platform/Modules/Sites/Http/Variables/Update.php index 0c3ba74135..4c7ad023d6 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Variables/UpdateVariable.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Variables/Update.php @@ -15,7 +15,7 @@ use Utopia\Platform\Action; use Utopia\Platform\Scope\HTTP; use Utopia\Validator\Text; -class UpdateVariable extends Base +class Update extends Base { use HTTP; diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Variables/ListVariables.php b/src/Appwrite/Platform/Modules/Sites/Http/Variables/XList.php similarity index 98% rename from src/Appwrite/Platform/Modules/Sites/Http/Variables/ListVariables.php rename to src/Appwrite/Platform/Modules/Sites/Http/Variables/XList.php index 10dad0c119..3c48de949a 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Variables/ListVariables.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Variables/XList.php @@ -14,7 +14,7 @@ use Utopia\Database\Validator\UID; use Utopia\Platform\Action; use Utopia\Platform\Scope\HTTP; -class ListVariables extends Base +class XList extends Base { use HTTP; diff --git a/src/Appwrite/Platform/Modules/Sites/Services/Http.php b/src/Appwrite/Platform/Modules/Sites/Services/Http.php index 28b8fbeff8..d00a9831b9 100644 --- a/src/Appwrite/Platform/Modules/Sites/Services/Http.php +++ b/src/Appwrite/Platform/Modules/Sites/Services/Http.php @@ -2,33 +2,33 @@ namespace Appwrite\Platform\Modules\Sites\Services; -use Appwrite\Platform\Modules\Sites\Http\Deployments\CancelDeployment; -use Appwrite\Platform\Modules\Sites\Http\Deployments\CreateBuild; -use Appwrite\Platform\Modules\Sites\Http\Deployments\CreateDeployment; -use Appwrite\Platform\Modules\Sites\Http\Deployments\DeleteDeployment; -use Appwrite\Platform\Modules\Sites\Http\Deployments\DownloadBuild; -use Appwrite\Platform\Modules\Sites\Http\Deployments\DownloadDeployment; -use Appwrite\Platform\Modules\Sites\Http\Deployments\GetDeployment; -use Appwrite\Platform\Modules\Sites\Http\Deployments\ListDeployments; -use Appwrite\Platform\Modules\Sites\Http\Deployments\UpdateDeployment; -use Appwrite\Platform\Modules\Sites\Http\Logs\DeleteLog; -use Appwrite\Platform\Modules\Sites\Http\Logs\GetLog; -use Appwrite\Platform\Modules\Sites\Http\Logs\ListLogs; -use Appwrite\Platform\Modules\Sites\Http\Sites\CreateSite; -use Appwrite\Platform\Modules\Sites\Http\Sites\DeleteSite; -use Appwrite\Platform\Modules\Sites\Http\Sites\GetSite; -use Appwrite\Platform\Modules\Sites\Http\Sites\GetSitesUsage; -use Appwrite\Platform\Modules\Sites\Http\Sites\GetSiteUsage; -use Appwrite\Platform\Modules\Sites\Http\Sites\GetTemplate; -use Appwrite\Platform\Modules\Sites\Http\Sites\ListFrameworks; -use Appwrite\Platform\Modules\Sites\Http\Sites\ListSites; -use Appwrite\Platform\Modules\Sites\Http\Sites\ListTemplates; -use Appwrite\Platform\Modules\Sites\Http\Sites\UpdateSite; -use Appwrite\Platform\Modules\Sites\Http\Variables\CreateVariable; -use Appwrite\Platform\Modules\Sites\Http\Variables\DeleteVariable; -use Appwrite\Platform\Modules\Sites\Http\Variables\GetVariable; -use Appwrite\Platform\Modules\Sites\Http\Variables\ListVariables; -use Appwrite\Platform\Modules\Sites\Http\Variables\UpdateVariable; +use Appwrite\Platform\Modules\Sites\Http\Deployments\Builds\Update as UpdateBuild; +use Appwrite\Platform\Modules\Sites\Http\Deployments\Builds\Create as CreateBuild; +use Appwrite\Platform\Modules\Sites\Http\Deployments\Create as CreateDeployment; +use Appwrite\Platform\Modules\Sites\Http\Deployments\Delete as DeleteDeployment; +use Appwrite\Platform\Modules\Sites\Http\Deployments\Download\Get as DownloadDeployment; +use Appwrite\Platform\Modules\Sites\Http\Deployments\Builds\Download\Get as DownloadBuild; +use Appwrite\Platform\Modules\Sites\Http\Deployments\Get as GetDeployment; +use Appwrite\Platform\Modules\Sites\Http\Deployments\XList as ListDeployments; +use Appwrite\Platform\Modules\Sites\Http\Deployments\Update as UpdateDeployment; +use Appwrite\Platform\Modules\Sites\Http\Logs\Delete as DeleteLog; +use Appwrite\Platform\Modules\Sites\Http\Logs\Get as GetLog; +use Appwrite\Platform\Modules\Sites\Http\Logs\XList as ListLogs; +use Appwrite\Platform\Modules\Sites\Http\Sites\Create as CreateSite; +use Appwrite\Platform\Modules\Sites\Http\Sites\Delete as DeleteSite; +use Appwrite\Platform\Modules\Sites\Http\Sites\Get as GetSite; +use Appwrite\Platform\Modules\Sites\Http\Usage\Get as GetUsage; +use Appwrite\Platform\Modules\Sites\Http\Usage\XList as ListUsage; +use Appwrite\Platform\Modules\Sites\Http\Sites\XList as ListSites; +use Appwrite\Platform\Modules\Sites\Http\Sites\Update as UpdateSite; +use Appwrite\Platform\Modules\Sites\Http\Templates\Get as GetTemplate; +use Appwrite\Platform\Modules\Sites\Http\Templates\XList as ListTemplates; +use Appwrite\Platform\Modules\Sites\Http\Frameworks\XList as ListFrameworks; +use Appwrite\Platform\Modules\Sites\Http\Variables\Create as CreateVariable; +use Appwrite\Platform\Modules\Sites\Http\Variables\Delete as DeleteVariable; +use Appwrite\Platform\Modules\Sites\Http\Variables\Get as GetVariable; +use Appwrite\Platform\Modules\Sites\Http\Variables\XList as ListVariables; +use Appwrite\Platform\Modules\Sites\Http\Variables\Update as UpdateVariable; use Utopia\Platform\Service; class Http extends Service @@ -56,7 +56,7 @@ class Http extends Service $this->addAction(DownloadDeployment::getName(), new DownloadDeployment()); $this->addAction(DownloadBuild::getName(), new DownloadBuild()); $this->addAction(CreateBuild::getName(), new CreateBuild()); - $this->addAction(CancelDeployment::getName(), new CancelDeployment()); + $this->addAction(UpdateBuild::getName(), new UpdateBuild()); // Logs $this->addAction(GetLog::getName(), new GetLog()); @@ -75,7 +75,7 @@ class Http extends Service $this->addAction(GetTemplate::getName(), new GetTemplate()); // Usage - $this->addAction(GetSiteUsage::getName(), new GetSiteUsage()); - $this->addAction(GetSitesUsage::getName(), new GetSitesUsage()); + $this->addAction(ListUsage::getName(), new ListUsage()); + $this->addAction(GetUsage::getName(), new GetUsage()); } }