From 57e5bf8f4797a7ee518c6abab94036a65964e079 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Fri, 9 Oct 2026 14:25:49 +0100 Subject: [PATCH] feat: SDK update for version 30.2.0 --- CHANGELOG.md | 5 +++++ docs/examples/functions/create.md | 3 ++- docs/examples/functions/update.md | 3 ++- docs/functions.md | 6 ++++-- src/Appwrite/Client.php | 4 ++-- src/Appwrite/Models/BillingPlan.php | 7 +++++++ src/Appwrite/Models/FunctionModel.php | 8 ++++++-- src/Appwrite/Services/Functions.php | 9 +++++++-- tests/Appwrite/Services/OrganizationTest.php | 2 ++ 9 files changed, 37 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e7c8673..ad3da518 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## 30.2.0 + +* Added: optional `interval` parameter on `functions.create` and `functions.update` to run a function every N minutes +* Added: `interval` on the `Function` model and `functionsIntervalMinimum` on the `BillingPlan` model + ## 30.1.0 * Added: optional `state` parameter on `createOAuth2Token`, returned unchanged on the success and failure URLs diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index 0fcac581..1f09b2fb 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -35,6 +35,7 @@ $result = $functions->create( providerPaths: [], // optional buildSpecification: 's-1vcpu-512mb', // optional runtimeSpecification: 's-1vcpu-512mb', // optional - deploymentRetention: 0 // optional + deploymentRetention: 0, // optional + interval: 0 // optional ); ``` diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index e13ede1f..d4863701 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -35,6 +35,7 @@ $result = $functions->update( providerPaths: [], // optional buildSpecification: 's-1vcpu-512mb', // optional runtimeSpecification: 's-1vcpu-512mb', // optional - deploymentRetention: 0 // optional + deploymentRetention: 0, // optional + interval: 0 // optional ); ``` diff --git a/docs/functions.md b/docs/functions.md index 00ae7360..e0214e58 100644 --- a/docs/functions.md +++ b/docs/functions.md @@ -31,7 +31,7 @@ POST https://cloud.appwrite.io/v1/functions | runtime | string | Execution runtime. | | | execute | array | An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. | [] | | events | array | Events list. Maximum of 100 events are allowed. | [] | -| schedule | string | Schedule CRON syntax. | | +| schedule | string | Schedule CRON syntax. Cannot be combined with interval. | | | timeout | integer | Function maximum execution time in seconds. | 15 | | enabled | boolean | Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. | 1 | | logging | boolean | When disabled, executions will exclude logs and errors, and will be slightly faster. | 1 | @@ -48,6 +48,7 @@ POST https://cloud.appwrite.io/v1/functions | buildSpecification | string | Build specification for the function deployments. | [] | | runtimeSpecification | string | Runtime specification for the function executions. | [] | | deploymentRetention | integer | Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. | 0 | +| interval | integer | Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. | 0 | ```http request @@ -98,7 +99,7 @@ PUT https://cloud.appwrite.io/v1/functions/{functionId} | runtime | string | Execution runtime. | | | execute | array | An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. | [] | | events | array | Events list. Maximum of 100 events are allowed. | [] | -| schedule | string | Schedule CRON syntax. | | +| schedule | string | Schedule CRON syntax. Cannot be combined with interval. | | | timeout | integer | Maximum execution time in seconds. | 15 | | enabled | boolean | Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. | 1 | | logging | boolean | When disabled, executions will exclude logs and errors, and will be slightly faster. | 1 | @@ -115,6 +116,7 @@ PUT https://cloud.appwrite.io/v1/functions/{functionId} | buildSpecification | string | Build specification for the function deployments. | | | runtimeSpecification | string | Runtime specification for the function executions. | | | deploymentRetention | integer | Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. | 0 | +| interval | integer | Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. When omitted, the current interval is kept unless schedule is set. | | ```http request diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index 18f5f9d8..8ced412e 100644 --- a/src/Appwrite/Client.php +++ b/src/Appwrite/Client.php @@ -43,11 +43,11 @@ class Client * */ protected array $headers = [ - 'user-agent' => 'AppwritePHPSDK/30.1.0 ()', + 'user-agent' => 'AppwritePHPSDK/30.2.0 ()', 'x-sdk-name' => 'PHP', 'x-sdk-platform' => 'server', 'x-sdk-language' => 'php', - 'x-sdk-version' => '30.1.0', + 'x-sdk-version' => '30.2.0', ]; /** diff --git a/src/Appwrite/Models/BillingPlan.php b/src/Appwrite/Models/BillingPlan.php index add36cb8..f7a61a7d 100644 --- a/src/Appwrite/Models/BillingPlan.php +++ b/src/Appwrite/Models/BillingPlan.php @@ -78,6 +78,7 @@ * @param BillingPlanSupportedAddons $supportedAddons supported addons for this plan * @param int $deploymentSize maximum function and site deployment size in mb * @param int $buildSize maximum function and site deployment size in mb + * @param int $functionsIntervalMinimum shortest function schedule interval allowed, in minutes. 0 allows every interval. * @param bool $databasesAllowEncrypt does the plan support encrypted string attributes or not. * @param BillingPlanGroup $group group of this billing plan for variants * @param float $databaseComputeCredit included monthly dedicated-database compute credit in usd. resets each billing cycle with no roll-over. @@ -152,6 +153,7 @@ public function __construct( public BillingPlanSupportedAddons $supportedAddons, public int $deploymentSize, public int $buildSize, + public int $functionsIntervalMinimum, public bool $databasesAllowEncrypt, public BillingPlanGroup $group, public float $databaseComputeCredit, @@ -352,6 +354,9 @@ public static function from(array $data): static if (!array_key_exists('buildSize', $data)) { throw new \InvalidArgumentException('Missing required field "buildSize" for ' . static::class . '.'); } + if (!array_key_exists('functionsIntervalMinimum', $data)) { + throw new \InvalidArgumentException('Missing required field "functionsIntervalMinimum" for ' . static::class . '.'); + } if (!array_key_exists('databasesAllowEncrypt', $data)) { throw new \InvalidArgumentException('Missing required field "databasesAllowEncrypt" for ' . static::class . '.'); } @@ -423,6 +428,7 @@ functions: $data['functions'], supportedAddons: static::hydrateTypedValue(BillingPlanSupportedAddons::class, $data['supportedAddons']), deploymentSize: $data['deploymentSize'], buildSize: $data['buildSize'], + functionsIntervalMinimum: $data['functionsIntervalMinimum'], databasesAllowEncrypt: $data['databasesAllowEncrypt'], group: static::hydrateTypedValue(BillingPlanGroup::class, $data['group']), databaseComputeCredit: $data['databaseComputeCredit'], @@ -510,6 +516,7 @@ public function toArray(): array 'backupPolicies' => static::serializeValue($this->backupPolicies), 'deploymentSize' => static::serializeValue($this->deploymentSize), 'buildSize' => static::serializeValue($this->buildSize), + 'functionsIntervalMinimum' => static::serializeValue($this->functionsIntervalMinimum), 'databasesAllowEncrypt' => static::serializeValue($this->databasesAllowEncrypt), 'limits' => static::serializeValue($this->limits), 'group' => static::serializeValue($this->group), diff --git a/src/Appwrite/Models/FunctionModel.php b/src/Appwrite/Models/FunctionModel.php index 48dd3e3d..c661b8b4 100644 --- a/src/Appwrite/Models/FunctionModel.php +++ b/src/Appwrite/Models/FunctionModel.php @@ -48,6 +48,7 @@ * @param array $providerPaths list of file path patterns that trigger automatic deployments. supports glob wildcards. empty list deploys on all file changes. * @param string $buildSpecification machine specification for deployment builds. * @param string $runtimeSpecification machine specification for executions. + * @param int|null $interval minutes between scheduled executions. 0 when the function has no interval. */ public function __construct( public string $id, @@ -81,7 +82,8 @@ public function __construct( public array $providerBranches, public array $providerPaths, public string $buildSpecification, - public string $runtimeSpecification + public string $runtimeSpecification, + public ?int $interval = null ) { } @@ -224,7 +226,8 @@ public static function from(array $data): static providerBranches: $data['providerBranches'], providerPaths: $data['providerPaths'], buildSpecification: $data['buildSpecification'], - runtimeSpecification: $data['runtimeSpecification'] + runtimeSpecification: $data['runtimeSpecification'], + interval: $data['interval'] ?? null ); } @@ -253,6 +256,7 @@ public function toArray(): array 'vars' => static::serializeValue($this->vars), 'events' => static::serializeValue($this->events), 'schedule' => static::serializeValue($this->schedule), + 'interval' => static::serializeValue($this->interval), 'timeout' => static::serializeValue($this->timeout), 'entrypoint' => static::serializeValue($this->entrypoint), 'commands' => static::serializeValue($this->commands), diff --git a/src/Appwrite/Services/Functions.php b/src/Appwrite/Services/Functions.php index 6058a67f..da2e8250 100644 --- a/src/Appwrite/Services/Functions.php +++ b/src/Appwrite/Services/Functions.php @@ -71,7 +71,7 @@ public function list(?array $queries = null, ?string $search = null, ?bool $tota * * @throws AppwriteException */ - public function create(string $functionId, string $name, Runtime $runtime, ?array $execute = null, ?array $events = null, ?string $schedule = null, ?int $timeout = null, ?bool $enabled = null, ?bool $logging = null, ?string $entrypoint = null, ?string $commands = null, ?array $scopes = null, ?string $installationId = null, ?string $providerRepositoryId = null, ?string $providerBranch = null, ?bool $providerSilentMode = null, ?string $providerRootDirectory = null, ?array $providerBranches = null, ?array $providerPaths = null, ?string $buildSpecification = null, ?string $runtimeSpecification = null, ?int $deploymentRetention = null): \Appwrite\Models\FunctionModel + public function create(string $functionId, string $name, Runtime $runtime, ?array $execute = null, ?array $events = null, ?string $schedule = null, ?int $timeout = null, ?bool $enabled = null, ?bool $logging = null, ?string $entrypoint = null, ?string $commands = null, ?array $scopes = null, ?string $installationId = null, ?string $providerRepositoryId = null, ?string $providerBranch = null, ?bool $providerSilentMode = null, ?string $providerRootDirectory = null, ?array $providerBranches = null, ?array $providerPaths = null, ?string $buildSpecification = null, ?string $runtimeSpecification = null, ?int $deploymentRetention = null, ?int $interval = null): \Appwrite\Models\FunctionModel { $apiPath = str_replace( [], @@ -160,6 +160,10 @@ public function create(string $functionId, string $name, Runtime $runtime, ?arra $apiParams['deploymentRetention'] = $deploymentRetention; } + if (!is_null($interval)) { + $apiParams['interval'] = $interval; + } + $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; @@ -288,7 +292,7 @@ public function get(string $functionId): \Appwrite\Models\FunctionModel * * @throws AppwriteException */ - public function update(string $functionId, string $name, ?Runtime $runtime = null, ?array $execute = null, ?array $events = null, ?string $schedule = null, ?int $timeout = null, ?bool $enabled = null, ?bool $logging = null, ?string $entrypoint = null, ?string $commands = null, ?array $scopes = null, ?string $installationId = null, ?string $providerRepositoryId = null, ?string $providerBranch = null, ?bool $providerSilentMode = null, ?string $providerRootDirectory = null, ?array $providerBranches = null, ?array $providerPaths = null, ?string $buildSpecification = null, ?string $runtimeSpecification = null, ?int $deploymentRetention = null): \Appwrite\Models\FunctionModel + public function update(string $functionId, string $name, ?Runtime $runtime = null, ?array $execute = null, ?array $events = null, ?string $schedule = null, ?int $timeout = null, ?bool $enabled = null, ?bool $logging = null, ?string $entrypoint = null, ?string $commands = null, ?array $scopes = null, ?string $installationId = null, ?string $providerRepositoryId = null, ?string $providerBranch = null, ?bool $providerSilentMode = null, ?string $providerRootDirectory = null, ?array $providerBranches = null, ?array $providerPaths = null, ?string $buildSpecification = null, ?string $runtimeSpecification = null, ?int $deploymentRetention = null, ?int $interval = null): \Appwrite\Models\FunctionModel { $apiPath = str_replace( ['{functionId}'], @@ -364,6 +368,7 @@ public function update(string $functionId, string $name, ?Runtime $runtime = nul if (!is_null($deploymentRetention)) { $apiParams['deploymentRetention'] = $deploymentRetention; } + $apiParams['interval'] = $interval; $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); diff --git a/tests/Appwrite/Services/OrganizationTest.php b/tests/Appwrite/Services/OrganizationTest.php index 7d97f8fe..316f69ca 100644 --- a/tests/Appwrite/Services/OrganizationTest.php +++ b/tests/Appwrite/Services/OrganizationTest.php @@ -163,6 +163,7 @@ public function testMethodGet(): void ], "deploymentSize" => 30, "buildSize" => 2000, + "functionsIntervalMinimum" => 60, "databasesAllowEncrypt" => true, "group" => "starter", "databaseComputeCredit" => 10 @@ -334,6 +335,7 @@ public function testMethodUpdate(): void ], "deploymentSize" => 30, "buildSize" => 2000, + "functionsIntervalMinimum" => 60, "databasesAllowEncrypt" => true, "group" => "starter", "databaseComputeCredit" => 10