diff --git a/CHANGELOG.md b/CHANGELOG.md index 29f30f4..4ff97ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/appwrite/client.py b/appwrite/client.py index da48cc7..470508a 100644 --- a/appwrite/client.py +++ b/appwrite/client.py @@ -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 = {} diff --git a/appwrite/models/billing_plan.py b/appwrite/models/billing_plan.py index 7f78aab..a167b8e 100644 --- a/appwrite/models/billing_plan.py +++ b/appwrite/models/billing_plan.py @@ -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] @@ -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') diff --git a/appwrite/models/function.py b/appwrite/models/function.py index 052018f..c080c4b 100644 --- a/appwrite/models/function.py +++ b/appwrite/models/function.py @@ -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 @@ -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') diff --git a/appwrite/services/functions.py b/appwrite/services/functions.py index 594c0f6..b42734f 100644 --- a/appwrite/services/functions.py +++ b/appwrite/services/functions.py @@ -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. @@ -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] @@ -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 @@ -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) response = self.client.call( 'post', @@ -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. @@ -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] @@ -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 @@ -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', diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index e352048..9f61841 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -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()) diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index d7dd50d..4e81933 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -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()) diff --git a/pyproject.toml b/pyproject.toml index aee33de..e8e2aa0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" diff --git a/setup.py b/setup.py index 8529f8f..eb5e4ea 100644 --- a/setup.py +++ b/setup.py @@ -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, @@ -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', diff --git a/test/services/test_organization.py b/test/services/test_organization.py index bb81433..5a7df9d 100644 --- a/test/services/test_organization.py +++ b/test/services/test_organization.py @@ -156,6 +156,7 @@ def test_get(self, m): }, "deploymentSize": 30.0, "buildSize": 2000.0, + "functionsIntervalMinimum": 60.0, "databasesAllowEncrypt": True, "group": "pro", "databaseComputeCredit": 10, @@ -325,6 +326,7 @@ def test_update(self, m): }, "deploymentSize": 30.0, "buildSize": 2000.0, + "functionsIntervalMinimum": 60.0, "databasesAllowEncrypt": True, "group": "pro", "databaseComputeCredit": 10,