Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## 24.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

## 24.1.0

* Added: optional `state` parameter on `createOAuth2Token`, returned unchanged on the success and failure URLs
Expand Down
4 changes: 2 additions & 2 deletions appwrite/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ def __init__(self):
self._endpoint = 'https://cloud.appwrite.io/v1'
self._global_headers = {
'content-type': '',
'user-agent': f'AppwritePythonSDK/24.1.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})',
'user-agent': f'AppwritePythonSDK/24.2.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})',
'x-sdk-name': 'Python',
'x-sdk-platform': 'server',
'x-sdk-language': 'python',
'x-sdk-version': '24.1.0',
'x-sdk-version': '24.2.0',
'X-Appwrite-Response-Format': '2.0.0',
}
self._config = {}
Expand Down
3 changes: 3 additions & 0 deletions appwrite/models/billing_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ class BillingPlan(AppwriteModel):
Maximum function and site deployment size in MB
buildsize : float
Maximum function and site deployment size in MB
functionsintervalminimum : float
Shortest function schedule interval allowed, in minutes. 0 allows every interval.
databasesallowencrypt : bool
Does the plan support encrypted string attributes or not.
limits : Optional[BillingPlanLimits]
Expand Down Expand Up @@ -229,6 +231,7 @@ class BillingPlan(AppwriteModel):
backuppolicies: Optional[float] = Field(default=None, alias='backupPolicies')
deploymentsize: float = Field(..., alias='deploymentSize')
buildsize: float = Field(..., alias='buildSize')
functionsintervalminimum: float = Field(..., alias='functionsIntervalMinimum')
databasesallowencrypt: bool = Field(..., alias='databasesAllowEncrypt')
limits: Optional[BillingPlanLimits] = Field(default=None, alias='limits')
group: BillingPlanGroup = Field(..., alias='group')
Expand Down
3 changes: 3 additions & 0 deletions appwrite/models/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class Function(AppwriteModel):
Function trigger events.
schedule : str
Function execution schedule in CRON format.
interval : Optional[float]
Minutes between scheduled executions. 0 when the function has no interval.
timeout : float
Function execution timeout in seconds.
entrypoint : str
Expand Down Expand Up @@ -96,6 +98,7 @@ class Function(AppwriteModel):
vars: List[Variable] = Field(..., alias='vars')
events: List[Any] = Field(..., alias='events')
schedule: str = Field(..., alias='schedule')
interval: Optional[float] = Field(default=None, alias='interval')
timeout: float = Field(..., alias='timeout')
entrypoint: str = Field(..., alias='entrypoint')
commands: str = Field(..., alias='commands')
Expand Down
14 changes: 12 additions & 2 deletions appwrite/services/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def create(
build_specification: Optional[str] = None,
runtime_specification: Optional[str] = None,
deployment_retention: Optional[float] = None,
interval: Optional[float] = None,
) -> Function:
"""
Create a new function. You can pass a list of [permissions](https://appwrite.io/docs/permissions) to allow different project users or team with access to execute the function using the client API.
Expand All @@ -117,7 +118,7 @@ def create(
events : Optional[List[str]]
Events list. Maximum of 100 events are allowed.
schedule : Optional[str]
Schedule CRON syntax.
Schedule CRON syntax. Cannot be combined with interval.
timeout : Optional[float]
Function maximum execution time in seconds.
enabled : Optional[bool]
Expand Down Expand Up @@ -150,6 +151,8 @@ def create(
Runtime specification for the function executions.
deployment_retention : Optional[float]
Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept.
interval : Optional[float]
Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule.
Returns
-------
Function
Expand Down Expand Up @@ -210,6 +213,8 @@ def create(
api_params['runtimeSpecification'] = self._normalize_value(runtime_specification)
if deployment_retention is not None:
api_params['deploymentRetention'] = self._normalize_value(deployment_retention)
if interval is not None:
api_params['interval'] = self._normalize_value(interval)
Comment on lines +216 to +217

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add coverage for the interval request parameter

The existing function service tests call create and update without an interval and do not assert request parameters; their mocked Function responses also omit the new field. As a result, regressions in sending interval on either operation or parsing it from responses would pass unnoticed.

Prompt To Fix With AI
This is a comment left during a code review.
Path: appwrite/services/functions.py
Line: 216-217

Comment:
**Add coverage for the interval request parameter**

The existing function service tests call `create` and `update` without an interval and do not assert request parameters; their mocked Function responses also omit the new field. As a result, regressions in sending `interval` on either operation or parsing it from responses would pass unnoticed.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

🟡 Minor · testing · Reply if this doesn't apply.


response = self.client.call(
'post',
Expand Down Expand Up @@ -358,6 +363,7 @@ def update(
build_specification: Optional[str] = None,
runtime_specification: Optional[str] = None,
deployment_retention: Optional[float] = None,
interval: Optional[float] = None,
) -> Function:
"""
Update function by its unique ID.
Expand All @@ -375,7 +381,7 @@ def update(
events : Optional[List[str]]
Events list. Maximum of 100 events are allowed.
schedule : Optional[str]
Schedule CRON syntax.
Schedule CRON syntax. Cannot be combined with interval.
timeout : Optional[float]
Maximum execution time in seconds.
enabled : Optional[bool]
Expand Down Expand Up @@ -408,6 +414,8 @@ def update(
Runtime specification for the function executions.
deployment_retention : Optional[float]
Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept.
interval : Optional[float]
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.
Returns
-------
Function
Expand Down Expand Up @@ -467,6 +475,8 @@ def update(
api_params['runtimeSpecification'] = self._normalize_value(runtime_specification)
if deployment_retention is not None:
api_params['deploymentRetention'] = self._normalize_value(deployment_retention)
if interval is not None:
api_params['interval'] = self._normalize_value(interval)

response = self.client.call(
'put',
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/functions/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ result: Function = functions.create(
provider_paths = [], # optional
build_specification = 's-1vcpu-512mb', # optional
runtime_specification = 's-1vcpu-512mb', # optional
deployment_retention = 0 # optional
deployment_retention = 0, # optional
interval = 0 # optional
)

print(result.model_dump())
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/functions/update.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ result: Function = functions.update(
provider_paths = [], # optional
build_specification = 's-1vcpu-512mb', # optional
runtime_specification = 's-1vcpu-512mb', # optional
deployment_retention = 0 # optional
deployment_retention = 0, # optional
interval = 0 # optional
)

print(result.model_dump())
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "appwrite"
version = "24.1.0"
version = "24.2.0"
description = "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API"
readme = "README.md"
requires-python = ">=3.9"
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
setuptools.setup(
name='appwrite',
packages=setuptools.find_packages(),
version='24.1.0',
version='24.2.0',
license='BSD-3-Clause',
description='Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API',
long_description=long_description,
Expand All @@ -18,7 +18,7 @@
maintainer='Appwrite Team',
maintainer_email='team@appwrite.io',
url='https://appwrite.io/support',
download_url='https://github.com/appwrite/sdk-for-python/archive/24.1.0.tar.gz',
download_url='https://github.com/appwrite/sdk-for-python/archive/24.2.0.tar.gz',
install_requires=[
'requests',
'pydantic>=2,<3',
Expand Down
2 changes: 2 additions & 0 deletions test/services/test_organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ def test_get(self, m):
},
"deploymentSize": 30.0,
"buildSize": 2000.0,
"functionsIntervalMinimum": 60.0,
"databasesAllowEncrypt": True,
"group": "pro",
"databaseComputeCredit": 10,
Expand Down Expand Up @@ -325,6 +326,7 @@ def test_update(self, m):
},
"deploymentSize": 30.0,
"buildSize": 2000.0,
"functionsIntervalMinimum": 60.0,
"databasesAllowEncrypt": True,
"group": "pro",
"databaseComputeCredit": 10,
Expand Down
Loading