From 08630cd686dcf22b4f248f33929f70fc6cd6aab7 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Sat, 26 Oct 2024 11:01:14 +0200 Subject: [PATCH] Add timeout and add sites scopes --- .env | 1 + app/config/collections.php | 11 +++++++++++ app/config/roles.php | 2 ++ app/config/scopes.php | 6 ++++++ app/controllers/general.php | 4 ++-- docker-compose.yml | 1 + .../Sites/Http/Deployments/CancelDeployment.php | 2 +- .../Sites/Http/Deployments/CreateDeployment.php | 2 +- .../Sites/Http/Deployments/DeleteDeployment.php | 2 +- .../Modules/Sites/Http/Deployments/DownloadBuild.php | 2 +- .../Sites/Http/Deployments/DownloadDeployment.php | 2 +- .../Modules/Sites/Http/Deployments/GetDeployment.php | 2 +- .../Sites/Http/Deployments/ListDeployments.php | 2 +- .../Sites/Http/Deployments/RebuildDeployment.php | 2 +- .../Sites/Http/Deployments/UpdateDeployment.php | 2 +- .../Platform/Modules/Sites/Http/Sites/CreateSite.php | 7 +++++-- .../Platform/Modules/Sites/Http/Sites/DeleteSite.php | 2 +- .../Platform/Modules/Sites/Http/Sites/GetSite.php | 2 +- .../Modules/Sites/Http/Sites/GetSiteUsage.php | 2 +- .../Modules/Sites/Http/Sites/GetSitesUsage.php | 2 +- .../Modules/Sites/Http/Sites/ListFrameworks.php | 2 +- .../Platform/Modules/Sites/Http/Sites/ListSites.php | 2 +- .../Platform/Modules/Sites/Http/Sites/UpdateSite.php | 10 +++++++--- .../Modules/Sites/Http/Variables/CreateVariable.php | 2 +- .../Modules/Sites/Http/Variables/DeleteVariable.php | 2 +- .../Modules/Sites/Http/Variables/GetVariable.php | 2 +- .../Modules/Sites/Http/Variables/ListVariables.php | 2 +- .../Modules/Sites/Http/Variables/UpdateVariable.php | 2 +- src/Appwrite/Utopia/Response/Model/Site.php | 6 ++++++ 29 files changed, 61 insertions(+), 27 deletions(-) diff --git a/.env b/.env index a663c0d278..a6a3f90e00 100644 --- a/.env +++ b/.env @@ -70,6 +70,7 @@ _APP_STORAGE_PREVIEW_LIMIT=20000000 _APP_SITES_SIZE_LIMIT=30000000 _APP_FUNCTIONS_SIZE_LIMIT=30000000 _APP_FUNCTIONS_TIMEOUT=900 +_APP_SITES_TIMEOUT=900 _APP_FUNCTIONS_BUILD_TIMEOUT=900 _APP_FUNCTIONS_CPUS=8 _APP_FUNCTIONS_MEMORY=8192 diff --git a/app/config/collections.php b/app/config/collections.php index 8847c8279a..b609e11218 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -3380,6 +3380,17 @@ $projectCollections = array_merge([ 'array' => false, 'filters' => ['subQueryProjectVariables'], ], + [ + '$id' => ID::custom('timeout'), + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], [ '$id' => ID::custom('search'), 'type' => Database::VAR_STRING, diff --git a/app/config/roles.php b/app/config/roles.php index fae97895b8..e18d1c994a 100644 --- a/app/config/roles.php +++ b/app/config/roles.php @@ -58,6 +58,8 @@ $admins = [ 'health.read', 'functions.read', 'functions.write', + 'sites.read', + 'sites.write', 'execution.read', 'execution.write', 'rules.read', diff --git a/app/config/scopes.php b/app/config/scopes.php index 3765ab54fa..e8b605371b 100644 --- a/app/config/scopes.php +++ b/app/config/scopes.php @@ -64,6 +64,12 @@ return [ // List of publicly visible scopes 'functions.write' => [ 'description' => 'Access to create, update, and delete your project\'s functions and code deployments', ], + 'sites.read' => [ + 'description' => 'Access to read your project\'s sites and deployments', + ], + 'sites.write' => [ + 'description' => 'Access to create, update, and delete your project\'s sites and deployments', + ], 'execution.read' => [ 'description' => 'Access to read your project\'s execution logs', ], diff --git a/app/controllers/general.php b/app/controllers/general.php index 378cfbfd84..11a9c3bb2d 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -155,8 +155,8 @@ function router(App $utopia, Database $dbForConsole, callable $getProjectDB, Swo 'logo' => 'node.png', 'startCommand' => null, 'version' => 'v1', - 'base' => 'static:1.0', - 'image' => 'static:1.0', + 'base' => 'openruntimes/static:v4-:1.0', + 'image' => 'openruntimes/static:v4-:1.0', 'supports' => [System::X86, System::ARM64, System::ARMV7, System::ARMV8] ], default => null diff --git a/docker-compose.yml b/docker-compose.yml index 91f39ff944..52d598146b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -166,6 +166,7 @@ services: - _APP_SITES_CPUS - _APP_SITES_MEMORY - _APP_SITES_SIZE_LIMIT + - _APP_SITES_TIMEOUT - _APP_DOMAIN_SITES - _APP_EXECUTOR_SECRET - _APP_EXECUTOR_HOST diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/CancelDeployment.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/CancelDeployment.php index ef6acefdc5..ce26c174f8 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/CancelDeployment.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/CancelDeployment.php @@ -32,7 +32,7 @@ class CancelDeployment extends Action ->setHttpPath('/v1/sites/:siteId/deployments/:deploymentId/build') ->desc('Cancel deployment') ->groups(['api', 'sites']) - ->label('scope', 'functions.write') //TODO: Update the scope to sites later + ->label('scope', 'sites.write') ->label('audits.event', 'deployment.update') ->label('audits.resource', 'site/{request.siteId}') ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/CreateDeployment.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/CreateDeployment.php index b35708fb50..ba8a9c325e 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/CreateDeployment.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/CreateDeployment.php @@ -41,7 +41,7 @@ class CreateDeployment extends Action ->setHttpPath('/v1/sites/:siteId/deployments') ->desc('Create deployment') ->groups(['api', 'sites']) - ->label('scope', 'functions.write') //TODO: Update the scope to sites later + ->label('scope', 'sites.write') ->label('event', 'sites.[siteId].deployments.[deploymentId].create') ->label('audits.event', 'deployment.create') ->label('audits.resource', 'site/{request.siteId}') diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/DeleteDeployment.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/DeleteDeployment.php index 313870bb97..bd1be243bf 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/DeleteDeployment.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/DeleteDeployment.php @@ -29,7 +29,7 @@ class DeleteDeployment extends Action ->setHttpPath('/v1/sites/:siteId/deployments/:deploymentId') ->desc('Delete deployment') ->groups(['api', 'sites']) - ->label('scope', 'functions.write') //TODO: Update the scope to sites later + ->label('scope', 'sites.write') ->label('event', 'sites.[siteId].deployments.[deploymentId].delete') ->label('audits.event', 'deployment.delete') ->label('audits.resource', 'site/{request.siteId}') diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/DownloadBuild.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/DownloadBuild.php index caa6d2389e..5b266ad24f 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/DownloadBuild.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/DownloadBuild.php @@ -27,7 +27,7 @@ class DownloadBuild extends Action ->setHttpPath('/v1/sites/:siteId/deployments/:deploymentId/build/download') ->desc('Download build') ->groups(['api', 'sites']) - ->label('scope', 'functions.read') //TODO: Update the scope to sites later + ->label('scope', 'sites.read') ->label('sdk.auth', [APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT]) ->label('sdk.namespace', 'sites') ->label('sdk.method', 'getBuildDownload') diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/DownloadDeployment.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/DownloadDeployment.php index 0d748514b1..e9e2ab146f 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/DownloadDeployment.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/DownloadDeployment.php @@ -27,7 +27,7 @@ class DownloadDeployment extends Action ->setHttpPath('/v1/sites/:siteId/deployments/:deploymentId/download') ->desc('Download deployment') ->groups(['api', 'sites']) - ->label('scope', 'functions.read') //TODO: Update the scope to sites later + ->label('scope', 'sites.read') ->label('sdk.auth', [APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT]) ->label('sdk.namespace', 'sites') ->label('sdk.method', 'getDeploymentDownload') diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/GetDeployment.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/GetDeployment.php index b83aa75c6e..cbe4b21569 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/GetDeployment.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/GetDeployment.php @@ -25,7 +25,7 @@ class GetDeployment extends Action ->setHttpPath('/v1/sites/:siteId/deployments/:deploymentId') ->desc('Get deployment') ->groups(['api', 'sites']) - ->label('scope', 'functions.read') //TODO: Update the scope to sites later + ->label('scope', 'sites.read') ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'sites') ->label('sdk.method', 'getDeployment') diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/ListDeployments.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/ListDeployments.php index 2d2adb9572..c800f7245b 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/ListDeployments.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/ListDeployments.php @@ -31,7 +31,7 @@ class ListDeployments extends Action ->setHttpPath('/v1/sites/:siteId/deployments') ->desc('List deployments') ->groups(['api', 'sites']) - ->label('scope', 'functions.read') //TODO: Update the scope to sites later + ->label('scope', 'sites.read') ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'sites') ->label('sdk.method', 'listDeployments') diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/RebuildDeployment.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/RebuildDeployment.php index ee09cf9fd0..2be8d266d9 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/RebuildDeployment.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/RebuildDeployment.php @@ -29,7 +29,7 @@ class RebuildDeployment extends Action ->setHttpPath('/v1/sites/:siteId/deployments/:deploymentId/build') ->desc('Rebuild deployment') ->groups(['api', 'sites']) - ->label('scope', 'functions.write') //TODO: Update the scope to sites later + ->label('scope', 'sites.write') ->label('event', 'sites.[siteId].deployments.[deploymentId].update') ->label('audits.event', 'deployment.update') ->label('audits.resource', 'site/{request.siteId}') diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/UpdateDeployment.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/UpdateDeployment.php index ea798a1513..3a2ee13956 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/UpdateDeployment.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/UpdateDeployment.php @@ -27,7 +27,7 @@ class UpdateDeployment extends Action ->setHttpPath('/v1/sites/:siteId/deployments/:deploymentId') ->desc('Update deployment') ->groups(['api', 'sites']) - ->label('scope', 'functions.write') //TODO: Update the scope to sites later + ->label('scope', 'sites.write') ->label('event', 'sites.[siteId].deployments.[deploymentId].update') ->label('audits.event', 'deployment.update') ->label('audits.resource', 'site/{request.siteId}') diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php index c8e30a5ab9..b796a131e0 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/CreateSite.php @@ -25,6 +25,7 @@ use Utopia\Swoole\Request; use Utopia\System\System; use Utopia\Validator\ArrayList; use Utopia\Validator\Boolean; +use Utopia\Validator\Range; use Utopia\Validator\Text; use Utopia\Validator\WhiteList; use Utopia\VCS\Adapter\Git\GitHub; @@ -45,7 +46,7 @@ class CreateSite extends Base ->setHttpPath('/v1/sites') ->desc('Create site') ->groups(['api', 'sites']) - ->label('scope', 'functions.write') // TODO: Update scope to sites.write + ->label('scope', 'sites.write') ->label('event', 'sites.[siteId].create') ->label('audits.event', 'site.create') ->label('audits.resource', 'site/{response.$id}') @@ -60,6 +61,7 @@ class CreateSite extends Base ->param('name', '', new Text(128), 'Site name. Max length: 128 chars.') ->param('framework', '', new WhiteList(array_keys(Config::getParam('frameworks')), true), 'Sites framework.') ->param('enabled', true, new Boolean(), 'Is site enabled? When set to \'disabled\', users cannot access the site but Server SDKs with and API key can still access the site. No data is lost when this is toggled.', true) // TODO: Add logging param later + ->param('timeout', 15, new Range(1, (int) System::getEnv('_APP_SITES_TIMEOUT', 900)), 'Maximum request time in seconds.', true) ->param('installCommand', '', new Text(8192, 0), 'Install Command.', true) ->param('buildCommand', '', new Text(8192, 0), 'Build Command.', true) ->param('outputDirectory', '', new Text(8192, 0), 'Output Directory for site.', true) @@ -92,7 +94,7 @@ class CreateSite extends Base ->callback([$this, 'action']); } - public function action(string $siteId, string $name, string $framework, bool $enabled, string $installCommand, string $buildCommand, string $outputDirectory, string $fallbackRedirect, array $scopes, string $installationId, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $templateRepository, string $templateOwner, string $templateRootDirectory, string $templateVersion, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Document $user, Event $queueForEvents, Build $queueForBuilds, Database $dbForConsole, GitHub $github) + public function action(string $siteId, string $name, string $framework, bool $enabled, int $timeout, string $installCommand, string $buildCommand, string $outputDirectory, string $fallbackRedirect, array $scopes, string $installationId, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $templateRepository, string $templateOwner, string $templateRootDirectory, string $templateVersion, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Document $user, Event $queueForEvents, Build $queueForBuilds, Database $dbForConsole, GitHub $github) { $siteId = ($siteId == 'unique()') ? ID::unique() : $siteId; @@ -134,6 +136,7 @@ class CreateSite extends Base 'framework' => $framework, 'deploymentInternalId' => '', 'deploymentId' => '', + 'timeout' => $timeout, 'installCommand' => $installCommand, 'buildCommand' => $buildCommand, 'outputDirectory' => $outputDirectory, diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/DeleteSite.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/DeleteSite.php index c1ac277436..ba97f36b74 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/DeleteSite.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/DeleteSite.php @@ -28,7 +28,7 @@ class DeleteSite extends Base ->setHttpPath('/v1/sites/:siteId') ->desc('Delete site') ->groups(['api', 'sites']) - ->label('scope', 'functions.write') // TODO: Update scope to sites.write + ->label('scope', 'sites.write') ->label('event', 'sites.[siteId].delete') ->label('audits.event', 'site.delete') ->label('audits.resource', 'site/{request.siteId}') diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/GetSite.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/GetSite.php index 03c6e390e4..abab8d86a4 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/GetSite.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/GetSite.php @@ -26,7 +26,7 @@ class GetSite extends Base ->setHttpPath('/v1/sites/:siteId') ->desc('Get site') ->groups(['api', 'sites']) - ->label('scope', 'functions.read') // TODO: Update scope to sites.read + ->label('scope', 'sites.read') ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'sites') ->label('sdk.method', 'get') diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/GetSiteUsage.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/GetSiteUsage.php index a00f74a0ff..a6e91e1530 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/GetSiteUsage.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/GetSiteUsage.php @@ -31,7 +31,7 @@ class GetSiteUsage extends Base ->setHttpPath('/v1/sites/:siteId/usage') ->desc('Get site usage') ->groups(['api', 'sites', 'usage']) - ->label('scope', 'functions.read') // TODO: Update scope to sites.read + ->label('scope', 'sites.read') ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) ->label('sdk.namespace', 'sites') ->label('sdk.method', 'getSiteUsage') diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/GetSitesUsage.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/GetSitesUsage.php index 0c8b1f8e36..9c5da2ce2a 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/GetSitesUsage.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/GetSitesUsage.php @@ -29,7 +29,7 @@ class GetSitesUsage extends Base ->setHttpPath('/v1/sites/usage') ->desc('Get sites usage') ->groups(['api', 'sites', 'usage']) - ->label('scope', 'functions.read') // TODO: Update scope to sites.read + ->label('scope', 'sites.read') ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) ->label('sdk.namespace', 'sites') ->label('sdk.method', 'getUsage') diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/ListFrameworks.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/ListFrameworks.php index 2d55045548..6325ba2351 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/ListFrameworks.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/ListFrameworks.php @@ -26,7 +26,7 @@ class ListFrameworks extends Base ->setHttpPath('/v1/sites/frameworks') ->desc('List frameworks') ->groups(['api', 'sites']) - ->label('scope', 'functions.read') // TODO: Update scope to sites.read + ->label('scope', 'sites.read') ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'sites') ->label('sdk.method', 'listFrameworks') diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/ListSites.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/ListSites.php index df3715f3bd..d2de7a979b 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/ListSites.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/ListSites.php @@ -31,7 +31,7 @@ class ListSites extends Base ->setHttpPath('/v1/sites') ->desc('List sites') ->groups(['api', 'sites']) - ->label('scope', 'functions.write') // TODO: Update scope to sites.write + ->label('scope', 'sites.write') ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'sites') ->label('sdk.method', 'list') diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/UpdateSite.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/UpdateSite.php index b69eea7452..a826e8b316 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/UpdateSite.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/UpdateSite.php @@ -21,8 +21,10 @@ use Utopia\Database\Validator\UID; use Utopia\Platform\Action; use Utopia\Platform\Scope\HTTP; use Utopia\Swoole\Request; +use Utopia\System\System; use Utopia\Validator\ArrayList; use Utopia\Validator\Boolean; +use Utopia\Validator\Range; use Utopia\Validator\Text; use Utopia\Validator\WhiteList; use Utopia\VCS\Adapter\Git\GitHub; @@ -42,7 +44,7 @@ class UpdateSite extends Base ->setHttpPath('/v1/sites/:siteId') ->desc('Update site') ->groups(['api', 'sites']) - ->label('scope', 'functions.write') // TODO: update it to sites.write later + ->label('scope', 'sites.write') ->label('event', 'sites.[siteId].update') ->label('audits.event', 'sites.update') ->label('audits.resource', 'site/{response.$id}') @@ -57,6 +59,7 @@ class UpdateSite extends Base ->param('name', '', new Text(128), 'Site name. Max length: 128 chars.') ->param('framework', '', new WhiteList(array_keys(Config::getParam('frameworks')), true), 'Sites framework.') ->param('enabled', true, new Boolean(), 'Is site enabled? When set to \'disabled\', users cannot access the site but Server SDKs with and API key can still access the site. No data is lost when this is toggled.', true) // TODO: Add logging param later + ->param('timeout', 15, new Range(1, (int) System::getEnv('_APP_SITES_TIMEOUT', 900)), 'Maximum request time in seconds.', true) ->param('installCommand', '', new Text(8192, 0), 'Install Command.', true) ->param('buildCommand', '', new Text(8192, 0), 'Build Command.', true) ->param('outputDirectory', '', new Text(8192, 0), 'Output Directory for site.', true) @@ -84,7 +87,7 @@ class UpdateSite extends Base ->callback([$this, 'action']); } - public function action(string $siteId, string $name, string $framework, bool $enabled, string $installCommand, string $buildCommand, string $outputDirectory, string $fallbackRedirect, array $scopes, string $installationId, ?string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Event $queueForEvents, Build $queueForBuilds, Database $dbForConsole, GitHub $github) + public function action(string $siteId, string $name, string $framework, bool $enabled, int $timeout, string $installCommand, string $buildCommand, string $outputDirectory, string $fallbackRedirect, array $scopes, string $installationId, ?string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Event $queueForEvents, Build $queueForBuilds, Database $dbForConsole, GitHub $github) { // TODO: If only branch changes, re-deploy $site = $dbForProject->getDocument('sites', $siteId); @@ -202,8 +205,9 @@ class UpdateSite extends Base 'framework' => $framework, 'enabled' => $enabled, 'live' => $live, - 'buildCommand' => $buildCommand, + 'timeout' => $timeout, 'installCommand' => $installCommand, + 'buildCommand' => $buildCommand, 'outputDirectory' => $outputDirectory, 'fallbackRedirect' => $fallbackRedirect, 'scopes' => $scopes, diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Variables/CreateVariable.php b/src/Appwrite/Platform/Modules/Sites/Http/Variables/CreateVariable.php index b0d7983a1d..30aec7e140 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Variables/CreateVariable.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Variables/CreateVariable.php @@ -33,7 +33,7 @@ class CreateVariable extends Base ->setHttpPath('/v1/sites/:siteId/variables') ->desc('Create variable') ->groups(['api', 'sites']) - ->label('scope', 'functions.write') // TODO: Update scope to sites.write + ->label('scope', 'sites.write') ->label('audits.event', 'variable.create') ->label('audits.resource', 'site/{request.siteId}') ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Variables/DeleteVariable.php b/src/Appwrite/Platform/Modules/Sites/Http/Variables/DeleteVariable.php index 45f6905763..c2cfd34207 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Variables/DeleteVariable.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Variables/DeleteVariable.php @@ -26,7 +26,7 @@ class DeleteVariable extends Base ->setHttpPath('/v1/sites/:siteId/variables/:variableId') ->desc('Delete variable') ->groups(['api', 'sites']) - ->label('scope', 'functions.write') // TODO: Update scope to sites + ->label('scope', 'sites.write') ->label('audits.event', 'variable.delete') ->label('audits.resource', 'site/{request.siteId}') ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Variables/GetVariable.php b/src/Appwrite/Platform/Modules/Sites/Http/Variables/GetVariable.php index cb9a57a2e8..b2afcb8248 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Variables/GetVariable.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Variables/GetVariable.php @@ -26,7 +26,7 @@ class GetVariable extends Base ->setHttpPath('/v1/sites/:siteId/variables/:variableId') ->desc('Get variable') ->groups(['api', 'sites']) - ->label('scope', 'functions.read') // TODO: Update scope to sites + ->label('scope', 'sites.read') ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'sites') ->label('sdk.method', 'getVariable') diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Variables/ListVariables.php b/src/Appwrite/Platform/Modules/Sites/Http/Variables/ListVariables.php index 7233cb234b..5dc2810d6a 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Variables/ListVariables.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Variables/ListVariables.php @@ -27,7 +27,7 @@ class ListVariables extends Base ->setHttpPath('/v1/sites/:siteId/variables') ->desc('List variables') ->groups(['api', 'sites']) - ->label('scope', 'functions.read') // TODO: Update scope to sites + ->label('scope', 'sites.read') ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'sites') ->label('sdk.method', 'listVariables') diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Variables/UpdateVariable.php b/src/Appwrite/Platform/Modules/Sites/Http/Variables/UpdateVariable.php index abd023e182..81841f39ae 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Variables/UpdateVariable.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Variables/UpdateVariable.php @@ -28,7 +28,7 @@ class UpdateVariable extends Base ->setHttpPath('/v1/sites/:siteId/variables/:variableId') ->desc('Update variable') ->groups(['api', 'sites']) - ->label('scope', 'functions.write') // TODO: Update scope to sites + ->label('scope', 'sites.write') ->label('audits.event', 'variable.update') ->label('audits.resource', 'site/{request.siteId}') ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) diff --git a/src/Appwrite/Utopia/Response/Model/Site.php b/src/Appwrite/Utopia/Response/Model/Site.php index 7c4a9a265d..5ec6ae069a 100644 --- a/src/Appwrite/Utopia/Response/Model/Site.php +++ b/src/Appwrite/Utopia/Response/Model/Site.php @@ -72,6 +72,12 @@ class Site extends Model 'example' => [], 'array' => true ]) + ->addRule('timeout', [ + 'type' => self::TYPE_INTEGER, + 'description' => 'Site request timeout in seconds.', + 'default' => 15, + 'example' => 300, + ]) ->addRule('installCommand', [ 'type' => self::TYPE_STRING, 'description' => 'The install command used to install the site dependencies.',