diff --git a/.github/workflows/autoclose.yml b/.github/workflows/autoclose.yml new file mode 100644 index 0000000..3e2b3cb --- /dev/null +++ b/.github/workflows/autoclose.yml @@ -0,0 +1,11 @@ +name: Auto-close External Pull Requests + +on: + pull_request_target: + types: [opened, reopened] + +jobs: + auto_close: + uses: appwrite/.github/.github/workflows/autoclose.yml@main + secrets: + GH_AUTO_CLOSE_PR_TOKEN: ${{ secrets.GH_AUTO_CLOSE_PR_TOKEN }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..d84d143 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,31 @@ +name: Publish to PyPI +on: + release: + types: [published] + +jobs: + publish: + name: Release build and publish + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.9' + + - name: Build package + run: | + python -m pip install setuptools wheel build + python setup.py sdist bdist_wheel + + - name: Publish package + run: | + python -m pip install twine + python -m twine upload -r pypi dist/* + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} + TWINE_NON_INTERACTIVE: true diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 712f791..0000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -language: python - -python: - - "3.8" - -jobs: - include: - - stage: pypi release - python: "3.8" - script: echo "Deploying to pypi ..." - deploy: - provider: pypi - username: "__token__" - password: $PYPI_TOKEN - on: - tags: true \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index fa4d35e..ff63134 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1,28 @@ -# Change Log \ No newline at end of file +# Change Log + +## 11.1.0 + +* Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service +* Add `dart38` and `flutter332` support to runtime models +* Add `gif` support to `ImageFormat` enum +* Add `upsertDocument` support to `Databases` service + +## 11.0.0 + +* Add `` to doc examples due to the new multi region endpoints +* Add doc examples and methods for bulk api transactions: `createDocuments`, `deleteDocuments` etc. +* Add doc examples, class and methods for new `Sites` service +* Add doc examples, class and methods for new `Tokens` service +* Add enums for `BuildRuntime `, `Adapter`, `Framework`, `DeploymentDownloadType` and `VCSDeploymentType` +* Update enum for `runtimes` with Pythonml312, Dart219, Flutter327 and Flutter329 +* Add `token` param to `getFilePreview` and `getFileView` for File tokens usage +* Add `queries` and `search` params to `listMemberships` method +* Remove `search` param from `listExecutions` method + +## 10.0.0 + +* Fix requests failing by removing `Content-Type` header from `GET` and `HEAD` requests + +## 9.0.3 + +* Update sdk to use Numpy-style docstrings diff --git a/LICENSE b/LICENSE index 96201c4..c1602fc 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2022 Appwrite (https://appwrite.io) and individual contributors. +Copyright (c) 2025 Appwrite (https://appwrite.io) and individual contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -7,6 +7,6 @@ Redistribution and use in source and binary forms, with or without modification, 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - 3. Neither the name Appwrite nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/README.md b/README.md index 2e7cbd3..a68a5ae 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,16 @@ # Appwrite Python SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-python.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-0.12.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.7.4-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK is compatible with Appwrite server version 0.12.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-python/releases).** +**This SDK is compatible with Appwrite server version 1.7.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-python/releases).** Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Python SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) -![Appwrite](https://appwrite.io/images/github.png) +![Appwrite](https://github.com/appwrite/appwrite/raw/main/public/images/github.png) ## Installation @@ -24,7 +24,7 @@ pip install appwrite ## Getting Started ### Init your SDK -Initialize your SDK with your Appwrite server API endpoint and project ID which can be found in your project settings page and your new API secret Key from project's API keys section. +Initialize your SDK with your Appwrite server API endpoint and project ID which can be found on your project settings page and your new API secret Key from project's API keys section. ```python from appwrite.client import Client @@ -46,13 +46,14 @@ Once your SDK object is set, create any of the Appwrite service objects and choo ```python users = Users(client) -result = users.create('[USER_ID]', 'email@example.com', 'password') +result = users.create(ID.unique(), email = "email@example.com", phone = "+123456789", password = "password", name = "Walter O'Brien") ``` ### Full Example ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.id import ID client = Client() @@ -65,7 +66,7 @@ client = Client() users = Users(client) -result = users.create('[USER_ID]', 'email@example.com', 'password') +result = users.create(ID.unique(), email = "email@example.com", phone = "+123456789", password = "password", name = "Walter O'Brien") ``` ### Error Handling @@ -74,7 +75,7 @@ The Appwrite Python SDK raises `AppwriteException` object with `message`, `code` ```python users = Users(client) try: - result = users.create('[USER_ID]', 'email@example.com', 'password') + result = users.create(ID.unique(), email = "email@example.com", phone = "+123456789", password = "password", name = "Walter O'Brien") except AppwriteException as e: print(e.message) ``` diff --git a/appwrite/client.py b/appwrite/client.py index 4d007ca..ed4d4b5 100644 --- a/appwrite/client.py +++ b/appwrite/client.py @@ -1,15 +1,25 @@ import io +import json +import os +import platform import requests +from .input_file import InputFile from .exception import AppwriteException +from .encoders.value_class_encoder import ValueClassEncoder class Client: def __init__(self): + self._chunk_size = 5*1024*1024 self._self_signed = False - self._endpoint = 'https://HOSTNAME/v1' + self._endpoint = 'https://cloud.appwrite.io/v1' self._global_headers = { 'content-type': '', - 'x-sdk-version': 'appwrite:python:0.6.1', - 'X-Appwrite-Response-Format' : '0.12.0', + 'user-agent' : f'AppwritePythonSDK/11.1.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': '11.1.0', + 'X-Appwrite-Response-Format' : '1.7.0', } def set_self_signed(self, status=True): @@ -17,6 +27,9 @@ def set_self_signed(self, status=True): return self def set_endpoint(self, endpoint): + if not endpoint.startswith('http://') and not endpoint.startswith('https://'): + raise AppwriteException('Invalid endpoint URL: ' + endpoint) + self._endpoint = endpoint return self @@ -46,17 +59,31 @@ def set_locale(self, value): self._global_headers['x-appwrite-locale'] = value return self - def call(self, method, path='', headers=None, params=None): + def set_session(self, value): + """The user session to authenticate with""" + + self._global_headers['x-appwrite-session'] = value + return self + + def set_forwarded_user_agent(self, value): + """The user agent string of the client that made the request""" + + self._global_headers['x-forwarded-user-agent'] = value + return self + + def call(self, method, path='', headers=None, params=None, response_type='json'): if headers is None: headers = {} if params is None: params = {} + params = {k: v for k, v in params.items() if v is not None} # Remove None values from params dictionary + data = {} - json = {} files = {} - + stringify = False + headers = {**self._global_headers, **headers} if method != 'get': @@ -64,33 +91,42 @@ def call(self, method, path='', headers=None, params=None): params = {} if headers['content-type'].startswith('application/json'): - json = data - data = {} + data = json.dumps(data, cls=ValueClassEncoder) if headers['content-type'].startswith('multipart/form-data'): del headers['content-type'] - + stringify = True for key in data.copy(): - if isinstance(data[key], io.BufferedIOBase): - files[key] = data[key] + if isinstance(data[key], InputFile): + files[key] = (data[key].filename, data[key].data) del data[key] + data = self.flatten(data, stringify=stringify) + response = None try: response = requests.request( # call method dynamically https://stackoverflow.com/a/4246075/2299554 method=method, url=self._endpoint + path, - params=self.flatten(params), - data=self.flatten(data), - json=json, + params=self.flatten(params, stringify=stringify), + data=data, files=files, headers=headers, verify=(not self._self_signed), + allow_redirects=False if response_type == 'location' else True ) response.raise_for_status() + warnings = response.headers.get('x-appwrite-warning') + if warnings: + for warning in warnings.split(';'): + print(f'Warning: {warning}') + content_type = response.headers['Content-Type'] + if response_type == 'location': + return response.headers.get('Location') + if content_type.startswith('application/json'): return response.json() @@ -99,13 +135,95 @@ def call(self, method, path='', headers=None, params=None): if response != None: content_type = response.headers['Content-Type'] if content_type.startswith('application/json'): - raise AppwriteException(response.json()['message'], response.status_code, response.json()) + raise AppwriteException(response.json()['message'], response.status_code, response.json().get('type'), response.text) else: - raise AppwriteException(response.text, response.status_code) + raise AppwriteException(response.text, response.status_code, None, response.text) else: raise AppwriteException(e) - def flatten(self, data, prefix=''): + def chunked_upload( + self, + path, + headers = None, + params = None, + param_name = '', + on_progress = None, + upload_id = '' + ): + input_file = params[param_name] + + if input_file.source_type == 'path': + size = os.stat(input_file.path).st_size + input = open(input_file.path, 'rb') + elif input_file.source_type == 'bytes': + size = len(input_file.data) + input = input_file.data + + if size < self._chunk_size: + if input_file.source_type == 'path': + input_file.data = input.read() + + params[param_name] = input_file + return self.call( + 'post', + path, + headers, + params + ) + + offset = 0 + counter = 0 + + try: + result = self.call('get', path + '/' + upload_id, headers) + counter = result['chunksUploaded'] + except: + pass + + if counter > 0: + offset = counter * self._chunk_size + input.seek(offset) + + while offset < size: + if input_file.source_type == 'path': + input_file.data = input.read(self._chunk_size) or input.read(size - offset) + elif input_file.source_type == 'bytes': + if offset + self._chunk_size < size: + end = offset + self._chunk_size + else: + end = size + input_file.data = input[offset:end] + + params[param_name] = input_file + headers["content-range"] = f'bytes {offset}-{min((offset + self._chunk_size) - 1, size - 1)}/{size}' + + result = self.call( + 'post', + path, + headers, + params, + ) + + offset = offset + self._chunk_size + + if "$id" in result: + headers["x-appwrite-id"] = result["$id"] + + if on_progress is not None: + end = min((((counter * self._chunk_size) + self._chunk_size) - 1), size - 1) + on_progress({ + "$id": result["$id"], + "progress": min(offset, size)/size * 100, + "sizeUploaded": end+1, + "chunksTotal": result["chunksTotal"], + "chunksUploaded": result["chunksUploaded"], + }) + + counter = counter + 1 + + return result + + def flatten(self, data, prefix='', stringify=False): output = {} i = 0 @@ -114,11 +232,13 @@ def flatten(self, data, prefix=''): finalKey = prefix + '[' + key +']' if prefix else key finalKey = prefix + '[' + str(i) +']' if isinstance(data, list) else finalKey i += 1 - + if isinstance(value, list) or isinstance(value, dict): - output = {**output, **self.flatten(value, finalKey)} + output = {**output, **self.flatten(value, finalKey, stringify)} else: - output[finalKey] = value + if stringify: + output[finalKey] = str(value) + else: + output[finalKey] = value return output - diff --git a/appwrite/encoders/__init__.py b/appwrite/encoders/__init__.py new file mode 100644 index 0000000..0519ecb --- /dev/null +++ b/appwrite/encoders/__init__.py @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/appwrite/encoders/value_class_encoder.py b/appwrite/encoders/value_class_encoder.py new file mode 100644 index 0000000..72297a5 --- /dev/null +++ b/appwrite/encoders/value_class_encoder.py @@ -0,0 +1,101 @@ +import json +from ..enums.authenticator_type import AuthenticatorType +from ..enums.authentication_factor import AuthenticationFactor +from ..enums.o_auth_provider import OAuthProvider +from ..enums.browser import Browser +from ..enums.credit_card import CreditCard +from ..enums.flag import Flag +from ..enums.relationship_type import RelationshipType +from ..enums.relation_mutate import RelationMutate +from ..enums.index_type import IndexType +from ..enums.runtime import Runtime +from ..enums.vcs_deployment_type import VCSDeploymentType +from ..enums.deployment_download_type import DeploymentDownloadType +from ..enums.execution_method import ExecutionMethod +from ..enums.name import Name +from ..enums.message_priority import MessagePriority +from ..enums.smtp_encryption import SmtpEncryption +from ..enums.framework import Framework +from ..enums.build_runtime import BuildRuntime +from ..enums.adapter import Adapter +from ..enums.compression import Compression +from ..enums.image_gravity import ImageGravity +from ..enums.image_format import ImageFormat +from ..enums.password_hash import PasswordHash +from ..enums.messaging_provider_type import MessagingProviderType + +class ValueClassEncoder(json.JSONEncoder): + def default(self, o): + if isinstance(o, AuthenticatorType): + return o.value + + if isinstance(o, AuthenticationFactor): + return o.value + + if isinstance(o, OAuthProvider): + return o.value + + if isinstance(o, Browser): + return o.value + + if isinstance(o, CreditCard): + return o.value + + if isinstance(o, Flag): + return o.value + + if isinstance(o, RelationshipType): + return o.value + + if isinstance(o, RelationMutate): + return o.value + + if isinstance(o, IndexType): + return o.value + + if isinstance(o, Runtime): + return o.value + + if isinstance(o, VCSDeploymentType): + return o.value + + if isinstance(o, DeploymentDownloadType): + return o.value + + if isinstance(o, ExecutionMethod): + return o.value + + if isinstance(o, Name): + return o.value + + if isinstance(o, MessagePriority): + return o.value + + if isinstance(o, SmtpEncryption): + return o.value + + if isinstance(o, Framework): + return o.value + + if isinstance(o, BuildRuntime): + return o.value + + if isinstance(o, Adapter): + return o.value + + if isinstance(o, Compression): + return o.value + + if isinstance(o, ImageGravity): + return o.value + + if isinstance(o, ImageFormat): + return o.value + + if isinstance(o, PasswordHash): + return o.value + + if isinstance(o, MessagingProviderType): + return o.value + + return super().default(o) \ No newline at end of file diff --git a/appwrite/enums/__init__.py b/appwrite/enums/__init__.py new file mode 100644 index 0000000..0519ecb --- /dev/null +++ b/appwrite/enums/__init__.py @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/appwrite/enums/adapter.py b/appwrite/enums/adapter.py new file mode 100644 index 0000000..821aa24 --- /dev/null +++ b/appwrite/enums/adapter.py @@ -0,0 +1,5 @@ +from enum import Enum + +class Adapter(Enum): + STATIC = "static" + SSR = "ssr" diff --git a/appwrite/enums/authentication_factor.py b/appwrite/enums/authentication_factor.py new file mode 100644 index 0000000..a5b8cf2 --- /dev/null +++ b/appwrite/enums/authentication_factor.py @@ -0,0 +1,7 @@ +from enum import Enum + +class AuthenticationFactor(Enum): + EMAIL = "email" + PHONE = "phone" + TOTP = "totp" + RECOVERYCODE = "recoverycode" diff --git a/appwrite/enums/authenticator_type.py b/appwrite/enums/authenticator_type.py new file mode 100644 index 0000000..ee9f94a --- /dev/null +++ b/appwrite/enums/authenticator_type.py @@ -0,0 +1,4 @@ +from enum import Enum + +class AuthenticatorType(Enum): + TOTP = "totp" diff --git a/appwrite/enums/browser.py b/appwrite/enums/browser.py new file mode 100644 index 0000000..02974ec --- /dev/null +++ b/appwrite/enums/browser.py @@ -0,0 +1,17 @@ +from enum import Enum + +class Browser(Enum): + AVANT_BROWSER = "aa" + ANDROID_WEBVIEW_BETA = "an" + GOOGLE_CHROME = "ch" + GOOGLE_CHROME_IOS = "ci" + GOOGLE_CHROME_MOBILE = "cm" + CHROMIUM = "cr" + MOZILLA_FIREFOX = "ff" + SAFARI = "sf" + MOBILE_SAFARI = "mf" + MICROSOFT_EDGE = "ps" + MICROSOFT_EDGE_IOS = "oi" + OPERA_MINI = "om" + OPERA = "op" + OPERA_NEXT = "on" diff --git a/appwrite/enums/build_runtime.py b/appwrite/enums/build_runtime.py new file mode 100644 index 0000000..aded697 --- /dev/null +++ b/appwrite/enums/build_runtime.py @@ -0,0 +1,68 @@ +from enum import Enum + +class BuildRuntime(Enum): + NODE_14_5 = "node-14.5" + NODE_16_0 = "node-16.0" + NODE_18_0 = "node-18.0" + NODE_19_0 = "node-19.0" + NODE_20_0 = "node-20.0" + NODE_21_0 = "node-21.0" + NODE_22 = "node-22" + PHP_8_0 = "php-8.0" + PHP_8_1 = "php-8.1" + PHP_8_2 = "php-8.2" + PHP_8_3 = "php-8.3" + RUBY_3_0 = "ruby-3.0" + RUBY_3_1 = "ruby-3.1" + RUBY_3_2 = "ruby-3.2" + RUBY_3_3 = "ruby-3.3" + PYTHON_3_8 = "python-3.8" + PYTHON_3_9 = "python-3.9" + PYTHON_3_10 = "python-3.10" + PYTHON_3_11 = "python-3.11" + PYTHON_3_12 = "python-3.12" + PYTHON_ML_3_11 = "python-ml-3.11" + PYTHON_ML_3_12 = "python-ml-3.12" + DENO_1_21 = "deno-1.21" + DENO_1_24 = "deno-1.24" + DENO_1_35 = "deno-1.35" + DENO_1_40 = "deno-1.40" + DENO_1_46 = "deno-1.46" + DENO_2_0 = "deno-2.0" + DART_2_15 = "dart-2.15" + DART_2_16 = "dart-2.16" + DART_2_17 = "dart-2.17" + DART_2_18 = "dart-2.18" + DART_2_19 = "dart-2.19" + DART_3_0 = "dart-3.0" + DART_3_1 = "dart-3.1" + DART_3_3 = "dart-3.3" + DART_3_5 = "dart-3.5" + DART_3_8 = "dart-3.8" + DOTNET_6_0 = "dotnet-6.0" + DOTNET_7_0 = "dotnet-7.0" + DOTNET_8_0 = "dotnet-8.0" + JAVA_8_0 = "java-8.0" + JAVA_11_0 = "java-11.0" + JAVA_17_0 = "java-17.0" + JAVA_18_0 = "java-18.0" + JAVA_21_0 = "java-21.0" + JAVA_22 = "java-22" + SWIFT_5_5 = "swift-5.5" + SWIFT_5_8 = "swift-5.8" + SWIFT_5_9 = "swift-5.9" + SWIFT_5_10 = "swift-5.10" + KOTLIN_1_6 = "kotlin-1.6" + KOTLIN_1_8 = "kotlin-1.8" + KOTLIN_1_9 = "kotlin-1.9" + KOTLIN_2_0 = "kotlin-2.0" + CPP_17 = "cpp-17" + CPP_20 = "cpp-20" + BUN_1_0 = "bun-1.0" + BUN_1_1 = "bun-1.1" + GO_1_23 = "go-1.23" + STATIC_1 = "static-1" + FLUTTER_3_24 = "flutter-3.24" + FLUTTER_3_27 = "flutter-3.27" + FLUTTER_3_29 = "flutter-3.29" + FLUTTER_3_32 = "flutter-3.32" diff --git a/appwrite/enums/compression.py b/appwrite/enums/compression.py new file mode 100644 index 0000000..6d2d21a --- /dev/null +++ b/appwrite/enums/compression.py @@ -0,0 +1,6 @@ +from enum import Enum + +class Compression(Enum): + NONE = "none" + GZIP = "gzip" + ZSTD = "zstd" diff --git a/appwrite/enums/credit_card.py b/appwrite/enums/credit_card.py new file mode 100644 index 0000000..3f770a3 --- /dev/null +++ b/appwrite/enums/credit_card.py @@ -0,0 +1,20 @@ +from enum import Enum + +class CreditCard(Enum): + AMERICAN_EXPRESS = "amex" + ARGENCARD = "argencard" + CABAL = "cabal" + CENCOSUD = "cencosud" + DINERS_CLUB = "diners" + DISCOVER = "discover" + ELO = "elo" + HIPERCARD = "hipercard" + JCB = "jcb" + MASTERCARD = "mastercard" + NARANJA = "naranja" + TARJETA_SHOPPING = "targeta-shopping" + UNION_CHINA_PAY = "union-china-pay" + VISA = "visa" + MIR = "mir" + MAESTRO = "maestro" + RUPAY = "rupay" diff --git a/appwrite/enums/deployment_download_type.py b/appwrite/enums/deployment_download_type.py new file mode 100644 index 0000000..e26e2d5 --- /dev/null +++ b/appwrite/enums/deployment_download_type.py @@ -0,0 +1,5 @@ +from enum import Enum + +class DeploymentDownloadType(Enum): + SOURCE = "source" + OUTPUT = "output" diff --git a/appwrite/enums/execution_method.py b/appwrite/enums/execution_method.py new file mode 100644 index 0000000..23df3b9 --- /dev/null +++ b/appwrite/enums/execution_method.py @@ -0,0 +1,9 @@ +from enum import Enum + +class ExecutionMethod(Enum): + GET = "GET" + POST = "POST" + PUT = "PUT" + PATCH = "PATCH" + DELETE = "DELETE" + OPTIONS = "OPTIONS" diff --git a/appwrite/enums/flag.py b/appwrite/enums/flag.py new file mode 100644 index 0000000..7dd0a30 --- /dev/null +++ b/appwrite/enums/flag.py @@ -0,0 +1,198 @@ +from enum import Enum + +class Flag(Enum): + AFGHANISTAN = "af" + ANGOLA = "ao" + ALBANIA = "al" + ANDORRA = "ad" + UNITED_ARAB_EMIRATES = "ae" + ARGENTINA = "ar" + ARMENIA = "am" + ANTIGUA_AND_BARBUDA = "ag" + AUSTRALIA = "au" + AUSTRIA = "at" + AZERBAIJAN = "az" + BURUNDI = "bi" + BELGIUM = "be" + BENIN = "bj" + BURKINA_FASO = "bf" + BANGLADESH = "bd" + BULGARIA = "bg" + BAHRAIN = "bh" + BAHAMAS = "bs" + BOSNIA_AND_HERZEGOVINA = "ba" + BELARUS = "by" + BELIZE = "bz" + BOLIVIA = "bo" + BRAZIL = "br" + BARBADOS = "bb" + BRUNEI_DARUSSALAM = "bn" + BHUTAN = "bt" + BOTSWANA = "bw" + CENTRAL_AFRICAN_REPUBLIC = "cf" + CANADA = "ca" + SWITZERLAND = "ch" + CHILE = "cl" + CHINA = "cn" + COTE_DIVOIRE = "ci" + CAMEROON = "cm" + DEMOCRATIC_REPUBLIC_OF_THE_CONGO = "cd" + REPUBLIC_OF_THE_CONGO = "cg" + COLOMBIA = "co" + COMOROS = "km" + CAPE_VERDE = "cv" + COSTA_RICA = "cr" + CUBA = "cu" + CYPRUS = "cy" + CZECH_REPUBLIC = "cz" + GERMANY = "de" + DJIBOUTI = "dj" + DOMINICA = "dm" + DENMARK = "dk" + DOMINICAN_REPUBLIC = "do" + ALGERIA = "dz" + ECUADOR = "ec" + EGYPT = "eg" + ERITREA = "er" + SPAIN = "es" + ESTONIA = "ee" + ETHIOPIA = "et" + FINLAND = "fi" + FIJI = "fj" + FRANCE = "fr" + MICRONESIA_FEDERATED_STATES_OF = "fm" + GABON = "ga" + UNITED_KINGDOM = "gb" + GEORGIA = "ge" + GHANA = "gh" + GUINEA = "gn" + GAMBIA = "gm" + GUINEA_BISSAU = "gw" + EQUATORIAL_GUINEA = "gq" + GREECE = "gr" + GRENADA = "gd" + GUATEMALA = "gt" + GUYANA = "gy" + HONDURAS = "hn" + CROATIA = "hr" + HAITI = "ht" + HUNGARY = "hu" + INDONESIA = "id" + INDIA = "in" + IRELAND = "ie" + IRAN_ISLAMIC_REPUBLIC_OF = "ir" + IRAQ = "iq" + ICELAND = "is" + ISRAEL = "il" + ITALY = "it" + JAMAICA = "jm" + JORDAN = "jo" + JAPAN = "jp" + KAZAKHSTAN = "kz" + KENYA = "ke" + KYRGYZSTAN = "kg" + CAMBODIA = "kh" + KIRIBATI = "ki" + SAINT_KITTS_AND_NEVIS = "kn" + SOUTH_KOREA = "kr" + KUWAIT = "kw" + LAO_PEOPLES_DEMOCRATIC_REPUBLIC = "la" + LEBANON = "lb" + LIBERIA = "lr" + LIBYA = "ly" + SAINT_LUCIA = "lc" + LIECHTENSTEIN = "li" + SRI_LANKA = "lk" + LESOTHO = "ls" + LITHUANIA = "lt" + LUXEMBOURG = "lu" + LATVIA = "lv" + MOROCCO = "ma" + MONACO = "mc" + MOLDOVA = "md" + MADAGASCAR = "mg" + MALDIVES = "mv" + MEXICO = "mx" + MARSHALL_ISLANDS = "mh" + NORTH_MACEDONIA = "mk" + MALI = "ml" + MALTA = "mt" + MYANMAR = "mm" + MONTENEGRO = "me" + MONGOLIA = "mn" + MOZAMBIQUE = "mz" + MAURITANIA = "mr" + MAURITIUS = "mu" + MALAWI = "mw" + MALAYSIA = "my" + NAMIBIA = "na" + NIGER = "ne" + NIGERIA = "ng" + NICARAGUA = "ni" + NETHERLANDS = "nl" + NORWAY = "no" + NEPAL = "np" + NAURU = "nr" + NEW_ZEALAND = "nz" + OMAN = "om" + PAKISTAN = "pk" + PANAMA = "pa" + PERU = "pe" + PHILIPPINES = "ph" + PALAU = "pw" + PAPUA_NEW_GUINEA = "pg" + POLAND = "pl" + FRENCH_POLYNESIA = "pf" + NORTH_KOREA = "kp" + PORTUGAL = "pt" + PARAGUAY = "py" + QATAR = "qa" + ROMANIA = "ro" + RUSSIA = "ru" + RWANDA = "rw" + SAUDI_ARABIA = "sa" + SUDAN = "sd" + SENEGAL = "sn" + SINGAPORE = "sg" + SOLOMON_ISLANDS = "sb" + SIERRA_LEONE = "sl" + EL_SALVADOR = "sv" + SAN_MARINO = "sm" + SOMALIA = "so" + SERBIA = "rs" + SOUTH_SUDAN = "ss" + SAO_TOME_AND_PRINCIPE = "st" + SURINAME = "sr" + SLOVAKIA = "sk" + SLOVENIA = "si" + SWEDEN = "se" + ESWATINI = "sz" + SEYCHELLES = "sc" + SYRIA = "sy" + CHAD = "td" + TOGO = "tg" + THAILAND = "th" + TAJIKISTAN = "tj" + TURKMENISTAN = "tm" + TIMOR_LESTE = "tl" + TONGA = "to" + TRINIDAD_AND_TOBAGO = "tt" + TUNISIA = "tn" + TURKEY = "tr" + TUVALU = "tv" + TANZANIA = "tz" + UGANDA = "ug" + UKRAINE = "ua" + URUGUAY = "uy" + UNITED_STATES = "us" + UZBEKISTAN = "uz" + VATICAN_CITY = "va" + SAINT_VINCENT_AND_THE_GRENADINES = "vc" + VENEZUELA = "ve" + VIETNAM = "vn" + VANUATU = "vu" + SAMOA = "ws" + YEMEN = "ye" + SOUTH_AFRICA = "za" + ZAMBIA = "zm" + ZIMBABWE = "zw" diff --git a/appwrite/enums/framework.py b/appwrite/enums/framework.py new file mode 100644 index 0000000..b3a9fb6 --- /dev/null +++ b/appwrite/enums/framework.py @@ -0,0 +1,17 @@ +from enum import Enum + +class Framework(Enum): + ANALOG = "analog" + ANGULAR = "angular" + NEXTJS = "nextjs" + REACT = "react" + NUXT = "nuxt" + VUE = "vue" + SVELTEKIT = "sveltekit" + ASTRO = "astro" + REMIX = "remix" + LYNX = "lynx" + FLUTTER = "flutter" + REACT_NATIVE = "react-native" + VITE = "vite" + OTHER = "other" diff --git a/appwrite/enums/image_format.py b/appwrite/enums/image_format.py new file mode 100644 index 0000000..332f646 --- /dev/null +++ b/appwrite/enums/image_format.py @@ -0,0 +1,10 @@ +from enum import Enum + +class ImageFormat(Enum): + JPG = "jpg" + JPEG = "jpeg" + PNG = "png" + WEBP = "webp" + HEIC = "heic" + AVIF = "avif" + GIF = "gif" diff --git a/appwrite/enums/image_gravity.py b/appwrite/enums/image_gravity.py new file mode 100644 index 0000000..c73678d --- /dev/null +++ b/appwrite/enums/image_gravity.py @@ -0,0 +1,12 @@ +from enum import Enum + +class ImageGravity(Enum): + CENTER = "center" + TOP_LEFT = "top-left" + TOP = "top" + TOP_RIGHT = "top-right" + LEFT = "left" + RIGHT = "right" + BOTTOM_LEFT = "bottom-left" + BOTTOM = "bottom" + BOTTOM_RIGHT = "bottom-right" diff --git a/appwrite/enums/index_type.py b/appwrite/enums/index_type.py new file mode 100644 index 0000000..f4c9e4c --- /dev/null +++ b/appwrite/enums/index_type.py @@ -0,0 +1,6 @@ +from enum import Enum + +class IndexType(Enum): + KEY = "key" + FULLTEXT = "fulltext" + UNIQUE = "unique" diff --git a/appwrite/enums/message_priority.py b/appwrite/enums/message_priority.py new file mode 100644 index 0000000..0010a35 --- /dev/null +++ b/appwrite/enums/message_priority.py @@ -0,0 +1,5 @@ +from enum import Enum + +class MessagePriority(Enum): + NORMAL = "normal" + HIGH = "high" diff --git a/appwrite/enums/messaging_provider_type.py b/appwrite/enums/messaging_provider_type.py new file mode 100644 index 0000000..e6e7c07 --- /dev/null +++ b/appwrite/enums/messaging_provider_type.py @@ -0,0 +1,6 @@ +from enum import Enum + +class MessagingProviderType(Enum): + EMAIL = "email" + SMS = "sms" + PUSH = "push" diff --git a/appwrite/enums/name.py b/appwrite/enums/name.py new file mode 100644 index 0000000..c4b981e --- /dev/null +++ b/appwrite/enums/name.py @@ -0,0 +1,15 @@ +from enum import Enum + +class Name(Enum): + V1_DATABASE = "v1-database" + V1_DELETES = "v1-deletes" + V1_AUDITS = "v1-audits" + V1_MAILS = "v1-mails" + V1_FUNCTIONS = "v1-functions" + V1_STATS_RESOURCES = "v1-stats-resources" + V1_STATS_USAGE = "v1-stats-usage" + V1_WEBHOOKS = "v1-webhooks" + V1_CERTIFICATES = "v1-certificates" + V1_BUILDS = "v1-builds" + V1_MESSAGING = "v1-messaging" + V1_MIGRATIONS = "v1-migrations" diff --git a/appwrite/enums/o_auth_provider.py b/appwrite/enums/o_auth_provider.py new file mode 100644 index 0000000..6c1e6bd --- /dev/null +++ b/appwrite/enums/o_auth_provider.py @@ -0,0 +1,43 @@ +from enum import Enum + +class OAuthProvider(Enum): + AMAZON = "amazon" + APPLE = "apple" + AUTH0 = "auth0" + AUTHENTIK = "authentik" + AUTODESK = "autodesk" + BITBUCKET = "bitbucket" + BITLY = "bitly" + BOX = "box" + DAILYMOTION = "dailymotion" + DISCORD = "discord" + DISQUS = "disqus" + DROPBOX = "dropbox" + ETSY = "etsy" + FACEBOOK = "facebook" + FIGMA = "figma" + GITHUB = "github" + GITLAB = "gitlab" + GOOGLE = "google" + LINKEDIN = "linkedin" + MICROSOFT = "microsoft" + NOTION = "notion" + OIDC = "oidc" + OKTA = "okta" + PAYPAL = "paypal" + PAYPALSANDBOX = "paypalSandbox" + PODIO = "podio" + SALESFORCE = "salesforce" + SLACK = "slack" + SPOTIFY = "spotify" + STRIPE = "stripe" + TRADESHIFT = "tradeshift" + TRADESHIFTBOX = "tradeshiftBox" + TWITCH = "twitch" + WORDPRESS = "wordpress" + YAHOO = "yahoo" + YAMMER = "yammer" + YANDEX = "yandex" + ZOHO = "zoho" + ZOOM = "zoom" + MOCK = "mock" diff --git a/appwrite/enums/password_hash.py b/appwrite/enums/password_hash.py new file mode 100644 index 0000000..8dcf212 --- /dev/null +++ b/appwrite/enums/password_hash.py @@ -0,0 +1,14 @@ +from enum import Enum + +class PasswordHash(Enum): + SHA1 = "sha1" + SHA224 = "sha224" + SHA256 = "sha256" + SHA384 = "sha384" + SHA512_224 = "sha512/224" + SHA512_256 = "sha512/256" + SHA512 = "sha512" + SHA3_224 = "sha3-224" + SHA3_256 = "sha3-256" + SHA3_384 = "sha3-384" + SHA3_512 = "sha3-512" diff --git a/appwrite/enums/relation_mutate.py b/appwrite/enums/relation_mutate.py new file mode 100644 index 0000000..ae52aa7 --- /dev/null +++ b/appwrite/enums/relation_mutate.py @@ -0,0 +1,6 @@ +from enum import Enum + +class RelationMutate(Enum): + CASCADE = "cascade" + RESTRICT = "restrict" + SETNULL = "setNull" diff --git a/appwrite/enums/relationship_type.py b/appwrite/enums/relationship_type.py new file mode 100644 index 0000000..7866ca6 --- /dev/null +++ b/appwrite/enums/relationship_type.py @@ -0,0 +1,7 @@ +from enum import Enum + +class RelationshipType(Enum): + ONETOONE = "oneToOne" + MANYTOONE = "manyToOne" + MANYTOMANY = "manyToMany" + ONETOMANY = "oneToMany" diff --git a/appwrite/enums/runtime.py b/appwrite/enums/runtime.py new file mode 100644 index 0000000..b0e307a --- /dev/null +++ b/appwrite/enums/runtime.py @@ -0,0 +1,68 @@ +from enum import Enum + +class Runtime(Enum): + NODE_14_5 = "node-14.5" + NODE_16_0 = "node-16.0" + NODE_18_0 = "node-18.0" + NODE_19_0 = "node-19.0" + NODE_20_0 = "node-20.0" + NODE_21_0 = "node-21.0" + NODE_22 = "node-22" + PHP_8_0 = "php-8.0" + PHP_8_1 = "php-8.1" + PHP_8_2 = "php-8.2" + PHP_8_3 = "php-8.3" + RUBY_3_0 = "ruby-3.0" + RUBY_3_1 = "ruby-3.1" + RUBY_3_2 = "ruby-3.2" + RUBY_3_3 = "ruby-3.3" + PYTHON_3_8 = "python-3.8" + PYTHON_3_9 = "python-3.9" + PYTHON_3_10 = "python-3.10" + PYTHON_3_11 = "python-3.11" + PYTHON_3_12 = "python-3.12" + PYTHON_ML_3_11 = "python-ml-3.11" + PYTHON_ML_3_12 = "python-ml-3.12" + DENO_1_21 = "deno-1.21" + DENO_1_24 = "deno-1.24" + DENO_1_35 = "deno-1.35" + DENO_1_40 = "deno-1.40" + DENO_1_46 = "deno-1.46" + DENO_2_0 = "deno-2.0" + DART_2_15 = "dart-2.15" + DART_2_16 = "dart-2.16" + DART_2_17 = "dart-2.17" + DART_2_18 = "dart-2.18" + DART_2_19 = "dart-2.19" + DART_3_0 = "dart-3.0" + DART_3_1 = "dart-3.1" + DART_3_3 = "dart-3.3" + DART_3_5 = "dart-3.5" + DART_3_8 = "dart-3.8" + DOTNET_6_0 = "dotnet-6.0" + DOTNET_7_0 = "dotnet-7.0" + DOTNET_8_0 = "dotnet-8.0" + JAVA_8_0 = "java-8.0" + JAVA_11_0 = "java-11.0" + JAVA_17_0 = "java-17.0" + JAVA_18_0 = "java-18.0" + JAVA_21_0 = "java-21.0" + JAVA_22 = "java-22" + SWIFT_5_5 = "swift-5.5" + SWIFT_5_8 = "swift-5.8" + SWIFT_5_9 = "swift-5.9" + SWIFT_5_10 = "swift-5.10" + KOTLIN_1_6 = "kotlin-1.6" + KOTLIN_1_8 = "kotlin-1.8" + KOTLIN_1_9 = "kotlin-1.9" + KOTLIN_2_0 = "kotlin-2.0" + CPP_17 = "cpp-17" + CPP_20 = "cpp-20" + BUN_1_0 = "bun-1.0" + BUN_1_1 = "bun-1.1" + GO_1_23 = "go-1.23" + STATIC_1 = "static-1" + FLUTTER_3_24 = "flutter-3.24" + FLUTTER_3_27 = "flutter-3.27" + FLUTTER_3_29 = "flutter-3.29" + FLUTTER_3_32 = "flutter-3.32" diff --git a/appwrite/enums/smtp_encryption.py b/appwrite/enums/smtp_encryption.py new file mode 100644 index 0000000..213330e --- /dev/null +++ b/appwrite/enums/smtp_encryption.py @@ -0,0 +1,6 @@ +from enum import Enum + +class SmtpEncryption(Enum): + NONE = "none" + SSL = "ssl" + TLS = "tls" diff --git a/appwrite/enums/vcs_deployment_type.py b/appwrite/enums/vcs_deployment_type.py new file mode 100644 index 0000000..d78e99f --- /dev/null +++ b/appwrite/enums/vcs_deployment_type.py @@ -0,0 +1,6 @@ +from enum import Enum + +class VCSDeploymentType(Enum): + BRANCH = "branch" + COMMIT = "commit" + TAG = "tag" diff --git a/appwrite/exception.py b/appwrite/exception.py index 0e08703..146e7a7 100644 --- a/appwrite/exception.py +++ b/appwrite/exception.py @@ -1,6 +1,7 @@ class AppwriteException(Exception): - def __init__(self, message, code = 0, response = None): + def __init__(self, message, code = 0, type = None, response = None): self.message = message self.code = code + self.type = type self.response = response super().__init__(self.message) \ No newline at end of file diff --git a/appwrite/id.py b/appwrite/id.py new file mode 100644 index 0000000..0be3040 --- /dev/null +++ b/appwrite/id.py @@ -0,0 +1,26 @@ +from datetime import datetime +import math +import os + +class ID: + # Generate an hex ID based on timestamp + # Recreated from https://www.php.net/manual/en/function.uniqid.php + @staticmethod + def __hex_timestamp(): + now = datetime.now() + sec = int(now.timestamp()) + usec = (now.microsecond % 1000) + hex_timestamp = f'{sec:08x}{usec:05x}' + return hex_timestamp + + @staticmethod + def custom(id): + return id + + # Generate a unique ID with padding to have a longer ID + @staticmethod + def unique(padding = 7): + base_id = ID.__hex_timestamp() + random_bytes = os.urandom(math.ceil(padding / 2)) + random_padding = random_bytes.hex()[:padding] + return base_id + random_padding diff --git a/appwrite/input_file.py b/appwrite/input_file.py new file mode 100644 index 0000000..33d5a77 --- /dev/null +++ b/appwrite/input_file.py @@ -0,0 +1,21 @@ +import os +import mimetypes + +class InputFile: + @classmethod + def from_path(cls, path): + instance = cls() + instance.path = path + instance.filename = os.path.basename(path) + instance.mime_type = mimetypes.guess_type(path) + instance.source_type = 'path' + return instance + + @classmethod + def from_bytes(cls, bytes, filename, mime_type = None): + instance = cls() + instance.data = bytes + instance.filename = filename + instance.mime_type = mime_type + instance.source_type = 'bytes' + return instance \ No newline at end of file diff --git a/appwrite/permission.py b/appwrite/permission.py new file mode 100644 index 0000000..7178b8c --- /dev/null +++ b/appwrite/permission.py @@ -0,0 +1,21 @@ +class Permission: + + @staticmethod + def read(role): + return f'read("{role}")' + + @staticmethod + def write(role): + return f'write("{role}")' + + @staticmethod + def create(role): + return f'create("{role}")' + + @staticmethod + def update(role): + return f'update("{role}")' + + @staticmethod + def delete(role): + return f'delete("{role}")' diff --git a/appwrite/query.py b/appwrite/query.py index 3a6179d..f25e33d 100644 --- a/appwrite/query.py +++ b/appwrite/query.py @@ -1,42 +1,108 @@ -class Query: +import json + + +# Inherit from dict to allow for easy serialization +class Query(): + def __init__(self, method, attribute=None, values=None): + self.method = method + + if attribute is not None: + self.attribute = attribute + + if values is not None: + self.values = values if isinstance(values, list) else [values] + + def __str__(self): + return json.dumps( + self.__dict__, + separators=(",", ":"), + default=lambda obj: obj.__dict__ + ) + @staticmethod def equal(attribute, value): - return Query.addQuery(attribute, "equal", value) + return str(Query("equal", attribute, value)) + + @staticmethod + def not_equal(attribute, value): + return str(Query("notEqual", attribute, value)) + + @staticmethod + def less_than(attribute, value): + return str(Query("lessThan", attribute, value)) + + @staticmethod + def less_than_equal(attribute, value): + return str(Query("lessThanEqual", attribute, value)) + + @staticmethod + def greater_than(attribute, value): + return str(Query("greaterThan", attribute, value)) + + @staticmethod + def greater_than_equal(attribute, value): + return str(Query("greaterThanEqual", attribute, value)) + + @staticmethod + def is_null(attribute): + return str(Query("isNull", attribute, None)) @staticmethod - def notEqual(attribute, value): - return Query.addQuery(attribute, "notEqual", value) - + def is_not_null(attribute): + return str(Query("isNotNull", attribute, None)) + @staticmethod - def lesser(attribute, value): - return Query.addQuery(attribute, "lesser", value) - + def between(attribute, start, end): + return str(Query("between", attribute, [start, end])) + @staticmethod - def lesserEqual(attribute, value): - return Query.addQuery(attribute, "lesserEqual", value) - + def starts_with(attribute, value): + return str(Query("startsWith", attribute, value)) + @staticmethod - def greater(attribute, value): - return Query.addQuery(attribute, "greater", value) - + def ends_with(attribute, value): + return str(Query("endsWith", attribute, value)) + @staticmethod - def greaterEqual(attribute, value): - return Query.addQuery(attribute, "greaterEqual", value) + def select(attributes): + return str(Query("select", None, attributes)) @staticmethod def search(attribute, value): - return Query.addQuery(attribute, "search", value) + return str(Query("search", attribute, value)) + + @staticmethod + def order_asc(attribute): + return str(Query("orderAsc", attribute, None)) + + @staticmethod + def order_desc(attribute): + return str(Query("orderDesc", attribute, None)) + + @staticmethod + def cursor_before(id): + return str(Query("cursorBefore", None, id)) + + @staticmethod + def cursor_after(id): + return str(Query("cursorAfter", None, id)) + + @staticmethod + def limit(limit): + return str(Query("limit", None, limit)) + + @staticmethod + def offset(offset): + return str(Query("offset", None, offset)) + + @staticmethod + def contains(attribute, value): + return str(Query("contains", attribute, value)) @staticmethod - def addQuery(attribute, oper, value): - if type(value) == list: - return '{}.{}({})'.format(attribute,oper, ','.join(map(Query.parseValues, value))) - else: - return '{}.{}({})'.format(attribute,oper, Query.parseValues(value)) + def or_queries(queries): + return str(Query("or", None, [json.loads(query) for query in queries])) @staticmethod - def parseValues(value): - if type(value) == str: - return '"{}"'.format(value) - else: - return value \ No newline at end of file + def and_queries(queries): + return str(Query("and", None, [json.loads(query) for query in queries])) diff --git a/appwrite/role.py b/appwrite/role.py new file mode 100644 index 0000000..8506fe1 --- /dev/null +++ b/appwrite/role.py @@ -0,0 +1,111 @@ +class Role: + """Helper class to generate role strings for `Permission`.""" + @staticmethod + def any(): + """Grants access to anyone. + + This includes authenticated and unauthenticated users. + """ + return 'any' + + @staticmethod + def user(id, status = ""): + """Grants access to a specific user by user ID. + + You can optionally pass verified or unverified for + `status` to target specific types of users. + + Parameters + ---------- + id : str + status : str, optional + + Returns + ------- + str + """ + if status: + return f'user:{id}/{status}' + return f'user:{id}' + + @staticmethod + def users(status = ""): + """Grants access to any authenticated or anonymous user. + + You can optionally pass verified or unverified for + `status` to target specific types of users. + + Parameters + ---------- + status : str, optional + + Returns + ------- + str + """ + if status: + return f'users/{status}' + return 'users' + + @staticmethod + def guests(): + """Grants access to any guest user without a session. + + Authenticated users don't have access to this role. + + Returns + ------- + str + """ + return 'guests' + + @staticmethod + def team(id, role = ""): + """Grants access to a team by team ID. + + You can optionally pass a role for `role` to target + team members with the specified role. + + Parameters + ---------- + id : str + role : str, optional + + Returns + ------- + str + """ + if role: + return f'team:{id}/{role}' + return f'team:{id}' + + @staticmethod + def member(id): + """Grants access to a specific member of a team. + + When the member is removed from the team, they will + no longer have access. + + Parameters + ---------- + id : str + + Returns + ------- + str + """ + return f'member:{id}' + + @staticmethod + def label(name): + """Grants access to a user with the specified label. + + Parameters + ---------- + name : str + + Returns + ------- + str + """ + return f'label:{name}' \ No newline at end of file diff --git a/appwrite/services/account.py b/appwrite/services/account.py index dfddcf0..6062ad4 100644 --- a/appwrite/services/account.py +++ b/appwrite/services/account.py @@ -1,268 +1,1435 @@ from ..service import Service +from typing import List, Dict, Any from ..exception import AppwriteException +from ..enums.authenticator_type import AuthenticatorType; +from ..enums.authentication_factor import AuthenticationFactor; +from ..enums.o_auth_provider import OAuthProvider; class Account(Service): - def __init__(self, client): + def __init__(self, client) -> None: super(Account, self).__init__(client) - def get(self): - """Get Account""" + def get(self) -> Dict[str, Any]: + """ + Get the currently logged in user. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account' + api_params = {} + + return self.client.call('get', api_path, { + }, api_params) + + def create(self, user_id: str, email: str, password: str, name: str = None) -> Dict[str, Any]: + """ + Use this endpoint to allow a new user to register a new account in your project. After the user registration completes successfully, you can use the [/account/verfication](https://appwrite.io/docs/references/cloud/client-web/account#createVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). + + + Parameters + ---------- + user_id : str + User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + email : str + User email. + password : str + New user password. Must be between 8 and 256 chars. + name : str + User name. Max length: 128 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') - params = {} - path = '/account' + if email is None: + raise AppwriteException('Missing required parameter: "email"') - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) + if password is None: + raise AppwriteException('Missing required parameter: "password"') - def delete(self): - """Delete Account""" - params = {} - path = '/account' + api_params['userId'] = user_id + api_params['email'] = email + api_params['password'] = password + api_params['name'] = name - return self.client.call('delete', path, { + return self.client.call('post', api_path, { 'content-type': 'application/json', - }, params) - - def update_email(self, email, password): - """Update Account Email""" - - if email is None: + }, api_params) + + def update_email(self, email: str, password: str) -> Dict[str, Any]: + """ + Update currently logged in user account email address. After changing user address, the user confirmation status will get reset. A new confirmation email is not sent automatically however you can use the send confirmation email endpoint again to send the confirmation email. For security measures, user password is required to complete this request. + This endpoint can also be used to convert an anonymous account to a normal one, by passing an email address and a new password. + + + + Parameters + ---------- + email : str + User email. + password : str + User password. Must be at least 8 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/email' + api_params = {} + if email is None: raise AppwriteException('Missing required parameter: "email"') - if password is None: + if password is None: raise AppwriteException('Missing required parameter: "password"') - params = {} - path = '/account/email' - - if email is not None: - params['email'] = email - if password is not None: - params['password'] = password + api_params['email'] = email + api_params['password'] = password - return self.client.call('patch', path, { + return self.client.call('patch', api_path, { 'content-type': 'application/json', - }, params) - - def get_logs(self, limit = None, offset = None): - """Get Account Logs""" - - params = {} - path = '/account/logs' + }, api_params) + + def list_identities(self, queries: List[str] = None) -> Dict[str, Any]: + """ + Get the list of identities for the currently logged in user. + + + Parameters + ---------- + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, provider, providerUid, providerEmail, providerAccessTokenExpiry + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/identities' + api_params = {} + + api_params['queries'] = queries + + return self.client.call('get', api_path, { + }, api_params) + + def delete_identity(self, identity_id: str) -> Dict[str, Any]: + """ + Delete an identity by its unique ID. + + + Parameters + ---------- + identity_id : str + Identity ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/identities/{identityId}' + api_params = {} + if identity_id is None: + raise AppwriteException('Missing required parameter: "identity_id"') + + api_path = api_path.replace('{identityId}', identity_id) + + + return self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_jwt(self) -> Dict[str, Any]: + """ + Use this endpoint to create a JSON Web Token. You can use the resulting JWT to authenticate on behalf of the current user when working with the Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes from its creation and will be invalid if the user will logout in that time frame. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/jwts' + api_params = {} + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def list_logs(self, queries: List[str] = None) -> Dict[str, Any]: + """ + Get the list of latest security activity logs for the currently logged in user. Each log returns user IP address, location and date and time of log. + + + Parameters + ---------- + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/logs' + api_params = {} + + api_params['queries'] = queries + + return self.client.call('get', api_path, { + }, api_params) + + def update_mfa(self, mfa: bool) -> Dict[str, Any]: + """ + Enable or disable MFA on an account. + + + Parameters + ---------- + mfa : bool + Enable or disable MFA. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/mfa' + api_params = {} + if mfa is None: + raise AppwriteException('Missing required parameter: "mfa"') + + + api_params['mfa'] = mfa + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_mfa_authenticator(self, type: AuthenticatorType) -> Dict[str, Any]: + """ + Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method. + + + Parameters + ---------- + type : AuthenticatorType + Type of authenticator. Must be `totp` + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/mfa/authenticators/{type}' + api_params = {} + if type is None: + raise AppwriteException('Missing required parameter: "type"') + + api_path = api_path.replace('{type}', type) + + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_mfa_authenticator(self, type: AuthenticatorType, otp: str) -> Dict[str, Any]: + """ + Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. + + + Parameters + ---------- + type : AuthenticatorType + Type of authenticator. + otp : str + Valid verification token. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/mfa/authenticators/{type}' + api_params = {} + if type is None: + raise AppwriteException('Missing required parameter: "type"') + + if otp is None: + raise AppwriteException('Missing required parameter: "otp"') + + api_path = api_path.replace('{type}', type) + + api_params['otp'] = otp + + return self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + def delete_mfa_authenticator(self, type: AuthenticatorType) -> Dict[str, Any]: + """ + Delete an authenticator for a user by ID. + + + Parameters + ---------- + type : AuthenticatorType + Type of authenticator. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/mfa/authenticators/{type}' + api_params = {} + if type is None: + raise AppwriteException('Missing required parameter: "type"') + + api_path = api_path.replace('{type}', type) + + + return self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_mfa_challenge(self, factor: AuthenticationFactor) -> Dict[str, Any]: + """ + Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method. + + + Parameters + ---------- + factor : AuthenticationFactor + Factor used for verification. Must be one of following: `email`, `phone`, `totp`, `recoveryCode`. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/mfa/challenge' + api_params = {} + if factor is None: + raise AppwriteException('Missing required parameter: "factor"') + + + api_params['factor'] = factor + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_mfa_challenge(self, challenge_id: str, otp: str) -> Dict[str, Any]: + """ + Complete the MFA challenge by providing the one-time password. Finish the process of MFA verification by providing the one-time password. To begin the flow, use [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. + + + Parameters + ---------- + challenge_id : str + ID of the challenge. + otp : str + Valid verification token. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/mfa/challenge' + api_params = {} + if challenge_id is None: + raise AppwriteException('Missing required parameter: "challenge_id"') + + if otp is None: + raise AppwriteException('Missing required parameter: "otp"') + + + api_params['challengeId'] = challenge_id + api_params['otp'] = otp + + return self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + def list_mfa_factors(self) -> Dict[str, Any]: + """ + List the factors available on the account to be used as a MFA challange. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/mfa/factors' + api_params = {} + + return self.client.call('get', api_path, { + }, api_params) + + def get_mfa_recovery_codes(self) -> Dict[str, Any]: + """ + Get recovery codes that can be used as backup for MFA flow. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to read recovery codes. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/mfa/recovery-codes' + api_params = {} + + return self.client.call('get', api_path, { + }, api_params) + + def create_mfa_recovery_codes(self) -> Dict[str, Any]: + """ + Generate recovery codes as backup for MFA flow. It's recommended to generate and show then immediately after user successfully adds their authehticator. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/mfa/recovery-codes' + api_params = {} + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_mfa_recovery_codes(self) -> Dict[str, Any]: + """ + Regenerate recovery codes that can be used as backup for MFA flow. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to regenreate recovery codes. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/mfa/recovery-codes' + api_params = {} + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_name(self, name: str) -> Dict[str, Any]: + """ + Update currently logged in user account name. + + + Parameters + ---------- + name : str + User name. Max length: 128 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/name' + api_params = {} + if name is None: + raise AppwriteException('Missing required parameter: "name"') - if limit is not None: - params['limit'] = limit - if offset is not None: - params['offset'] = offset + api_params['name'] = name - return self.client.call('get', path, { + return self.client.call('patch', api_path, { 'content-type': 'application/json', - }, params) - - def update_name(self, name): - """Update Account Name""" - - if name is None: - raise AppwriteException('Missing required parameter: "name"') + }, api_params) + + def update_password(self, password: str, old_password: str = None) -> Dict[str, Any]: + """ + Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth, Team Invites and Magic URL, oldPassword is optional. + + + Parameters + ---------- + password : str + New user password. Must be at least 8 chars. + old_password : str + Current user password. Must be at least 8 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/password' + api_params = {} + if password is None: + raise AppwriteException('Missing required parameter: "password"') - params = {} - path = '/account/name' - if name is not None: - params['name'] = name + api_params['password'] = password + api_params['oldPassword'] = old_password - return self.client.call('patch', path, { + return self.client.call('patch', api_path, { 'content-type': 'application/json', - }, params) + }, api_params) + + def update_phone(self, phone: str, password: str) -> Dict[str, Any]: + """ + Update the currently logged in user's phone number. After updating the phone number, the phone verification status will be reset. A confirmation SMS is not sent automatically, however you can use the [POST /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) endpoint to send a confirmation SMS. + + + Parameters + ---------- + phone : str + Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + password : str + User password. Must be at least 8 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/phone' + api_params = {} + if phone is None: + raise AppwriteException('Missing required parameter: "phone"') + + if password is None: + raise AppwriteException('Missing required parameter: "password"') - def update_password(self, password, old_password = None): - """Update Account Password""" - if password is None: - raise AppwriteException('Missing required parameter: "password"') + api_params['phone'] = phone + api_params['password'] = password - params = {} - path = '/account/password' + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def get_prefs(self) -> Dict[str, Any]: + """ + Get the preferences as a key-value object for the currently logged in user. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/prefs' + api_params = {} + + return self.client.call('get', api_path, { + }, api_params) + + def update_prefs(self, prefs: dict) -> Dict[str, Any]: + """ + Update currently logged in user account preferences. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded. + + + Parameters + ---------- + prefs : dict + Prefs key-value JSON object. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/prefs' + api_params = {} + if prefs is None: + raise AppwriteException('Missing required parameter: "prefs"') - if password is not None: - params['password'] = password - if old_password is not None: - params['oldPassword'] = old_password + api_params['prefs'] = prefs - return self.client.call('patch', path, { + return self.client.call('patch', api_path, { 'content-type': 'application/json', - }, params) + }, api_params) + + def create_recovery(self, email: str, url: str) -> Dict[str, Any]: + """ + Sends the user an email with a temporary secret key for password reset. When the user clicks the confirmation link he is redirected back to your app password reset URL with the secret key and email address values attached to the URL query string. Use the query string params to submit a request to the [PUT /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery) endpoint to complete the process. The verification link sent to the user's email address is valid for 1 hour. + + + Parameters + ---------- + email : str + User email. + url : str + URL to redirect the user back to your app from the recovery email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/recovery' + api_params = {} + if email is None: + raise AppwriteException('Missing required parameter: "email"') + + if url is None: + raise AppwriteException('Missing required parameter: "url"') - def get_prefs(self): - """Get Account Preferences""" - params = {} - path = '/account/prefs' + api_params['email'] = email + api_params['url'] = url - return self.client.call('get', path, { + return self.client.call('post', api_path, { 'content-type': 'application/json', - }, params) + }, api_params) + + def update_recovery(self, user_id: str, secret: str, password: str) -> Dict[str, Any]: + """ + Use this endpoint to complete the user account password reset. Both the **userId** and **secret** arguments will be passed as query parameters to the redirect URL you have provided when sending your request to the [POST /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery) endpoint. + + Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. + + + Parameters + ---------- + user_id : str + User ID. + secret : str + Valid reset token. + password : str + New user password. Must be between 8 and 256 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/recovery' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') - def update_prefs(self, prefs): - """Update Account Preferences""" + if secret is None: + raise AppwriteException('Missing required parameter: "secret"') - if prefs is None: - raise AppwriteException('Missing required parameter: "prefs"') + if password is None: + raise AppwriteException('Missing required parameter: "password"') - params = {} - path = '/account/prefs' - if prefs is not None: - params['prefs'] = prefs + api_params['userId'] = user_id + api_params['secret'] = secret + api_params['password'] = password - return self.client.call('patch', path, { + return self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + def list_sessions(self) -> Dict[str, Any]: + """ + Get the list of active sessions across different devices for the currently logged in user. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/sessions' + api_params = {} + + return self.client.call('get', api_path, { + }, api_params) + + def delete_sessions(self) -> Dict[str, Any]: + """ + Delete all sessions from the user account and remove any sessions cookies from the end client. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/sessions' + api_params = {} + + return self.client.call('delete', api_path, { 'content-type': 'application/json', - }, params) + }, api_params) + + def create_anonymous_session(self) -> Dict[str, Any]: + """ + Use this endpoint to allow a new user to register an anonymous account in your project. This route will also create a new session for the user. To allow the new user to convert an anonymous account to a normal account, you need to update its [email and password](https://appwrite.io/docs/references/cloud/client-web/account#updateEmail) or create an [OAuth2 session](https://appwrite.io/docs/references/cloud/client-web/account#CreateOAuth2Session). + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/sessions/anonymous' + api_params = {} + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_email_password_session(self, email: str, password: str) -> Dict[str, Any]: + """ + Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user. + + A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + + + Parameters + ---------- + email : str + User email. + password : str + User password. Must be at least 8 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/sessions/email' + api_params = {} + if email is None: + raise AppwriteException('Missing required parameter: "email"') - def create_recovery(self, email, url): - """Create Password Recovery""" + if password is None: + raise AppwriteException('Missing required parameter: "password"') - if email is None: - raise AppwriteException('Missing required parameter: "email"') - if url is None: - raise AppwriteException('Missing required parameter: "url"') + api_params['email'] = email + api_params['password'] = password + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_magic_url_session(self, user_id: str, secret: str) -> Dict[str, Any]: + """ + Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. + + + Parameters + ---------- + user_id : str + User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + secret : str + Valid verification token. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/sessions/magic-url' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') - params = {} - path = '/account/recovery' + if secret is None: + raise AppwriteException('Missing required parameter: "secret"') - if email is not None: - params['email'] = email - if url is not None: - params['url'] = url + api_params['userId'] = user_id + api_params['secret'] = secret - return self.client.call('post', path, { + return self.client.call('put', api_path, { 'content-type': 'application/json', - }, params) + }, api_params) + + def update_phone_session(self, user_id: str, secret: str) -> Dict[str, Any]: + """ + Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. + + + Parameters + ---------- + user_id : str + User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + secret : str + Valid verification token. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/sessions/phone' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') + + if secret is None: + raise AppwriteException('Missing required parameter: "secret"') - def update_recovery(self, user_id, secret, password, password_again): - """Create Password Recovery (confirmation)""" - if user_id is None: + api_params['userId'] = user_id + api_params['secret'] = secret + + return self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_session(self, user_id: str, secret: str) -> Dict[str, Any]: + """ + Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. + + + Parameters + ---------- + user_id : str + User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + secret : str + Secret of a token generated by login methods. For example, the `createMagicURLToken` or `createPhoneToken` methods. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/sessions/token' + api_params = {} + if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') - if secret is None: + if secret is None: raise AppwriteException('Missing required parameter: "secret"') - if password is None: - raise AppwriteException('Missing required parameter: "password"') - if password_again is None: - raise AppwriteException('Missing required parameter: "password_again"') + api_params['userId'] = user_id + api_params['secret'] = secret - params = {} - path = '/account/recovery' + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def get_session(self, session_id: str) -> Dict[str, Any]: + """ + Use this endpoint to get a logged in user's session using a Session ID. Inputting 'current' will return the current session being used. + + + Parameters + ---------- + session_id : str + Session ID. Use the string 'current' to get the current device session. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/sessions/{sessionId}' + api_params = {} + if session_id is None: + raise AppwriteException('Missing required parameter: "session_id"') - if user_id is not None: - params['userId'] = user_id + api_path = api_path.replace('{sessionId}', session_id) - if secret is not None: - params['secret'] = secret - if password is not None: - params['password'] = password + return self.client.call('get', api_path, { + }, api_params) - if password_again is not None: - params['passwordAgain'] = password_again + def update_session(self, session_id: str) -> Dict[str, Any]: + """ + Use this endpoint to extend a session's length. Extending a session is useful when session expiry is short. If the session was created using an OAuth provider, this endpoint refreshes the access token from the provider. - return self.client.call('put', path, { - 'content-type': 'application/json', - }, params) - def get_sessions(self): - """Get Account Sessions""" + Parameters + ---------- + session_id : str + Session ID. Use the string 'current' to update the current device session. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/sessions/{sessionId}' + api_params = {} + if session_id is None: + raise AppwriteException('Missing required parameter: "session_id"') + + api_path = api_path.replace('{sessionId}', session_id) - params = {} - path = '/account/sessions' - return self.client.call('get', path, { + return self.client.call('patch', api_path, { 'content-type': 'application/json', - }, params) + }, api_params) + + def delete_session(self, session_id: str) -> Dict[str, Any]: + """ + Logout the user. Use 'current' as the session ID to logout on this device, use a session ID to logout on another device. If you're looking to logout the user on all devices, use [Delete Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions) instead. + + + Parameters + ---------- + session_id : str + Session ID. Use the string 'current' to delete the current device session. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/sessions/{sessionId}' + api_params = {} + if session_id is None: + raise AppwriteException('Missing required parameter: "session_id"') - def delete_sessions(self): - """Delete All Account Sessions""" + api_path = api_path.replace('{sessionId}', session_id) - params = {} - path = '/account/sessions' - return self.client.call('delete', path, { + return self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_status(self) -> Dict[str, Any]: + """ + Block the currently logged in user account. Behind the scene, the user record is not deleted but permanently blocked from any access. To completely delete a user, use the Users API instead. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/status' + api_params = {} + + return self.client.call('patch', api_path, { 'content-type': 'application/json', - }, params) + }, api_params) + + def create_email_token(self, user_id: str, email: str, phrase: bool = None) -> Dict[str, Any]: + """ + Sends the user an email with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's email is valid for 15 minutes. + + A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + + + Parameters + ---------- + user_id : str + User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + email : str + User email. + phrase : bool + Toggle for security phrase. If enabled, email will be send with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/tokens/email' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') - def get_session(self, session_id): - """Get Session By ID""" + if email is None: + raise AppwriteException('Missing required parameter: "email"') - if session_id is None: - raise AppwriteException('Missing required parameter: "session_id"') - params = {} - path = '/account/sessions/{sessionId}' - path = path.replace('{sessionId}', session_id) + api_params['userId'] = user_id + api_params['email'] = email + api_params['phrase'] = phrase - return self.client.call('get', path, { + return self.client.call('post', api_path, { 'content-type': 'application/json', - }, params) + }, api_params) + + def create_magic_url_token(self, user_id: str, email: str, url: str = None, phrase: bool = None) -> Dict[str, Any]: + """ + Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. + + A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + + + + Parameters + ---------- + user_id : str + Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + email : str + User email. + url : str + URL to redirect the user back to your app from the magic URL login. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. + phrase : bool + Toggle for security phrase. If enabled, email will be send with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/tokens/magic-url' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') - def delete_session(self, session_id): - """Delete Account Session""" + if email is None: + raise AppwriteException('Missing required parameter: "email"') - if session_id is None: - raise AppwriteException('Missing required parameter: "session_id"') - params = {} - path = '/account/sessions/{sessionId}' - path = path.replace('{sessionId}', session_id) + api_params['userId'] = user_id + api_params['email'] = email + api_params['url'] = url + api_params['phrase'] = phrase - return self.client.call('delete', path, { + return self.client.call('post', api_path, { 'content-type': 'application/json', - }, params) + }, api_params) + + def create_o_auth2_token(self, provider: OAuthProvider, success: str = None, failure: str = None, scopes: List[str] = None) -> str: + """ + Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed. + + If authentication succeeds, `userId` and `secret` of a token will be appended to the success URL as query parameters. These can be used to create a new session using the [Create session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint. + + A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + + + Parameters + ---------- + provider : OAuthProvider + OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom. + success : str + URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. + failure : str + URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. + scopes : List[str] + A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long. + + Returns + ------- + str + Authentication response as a string + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/tokens/oauth2/{provider}' + api_params = {} + if provider is None: + raise AppwriteException('Missing required parameter: "provider"') + + api_path = api_path.replace('{provider}', provider) + + api_params['success'] = success + api_params['failure'] = failure + api_params['scopes'] = scopes + + return self.client.call('get', api_path, { + }, api_params, response_type='location') + + def create_phone_token(self, user_id: str, phone: str) -> Dict[str, Any]: + """ + Sends the user an SMS with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes. + + A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + + + Parameters + ---------- + user_id : str + Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + phone : str + Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/tokens/phone' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') + + if phone is None: + raise AppwriteException('Missing required parameter: "phone"') - def create_verification(self, url): - """Create Email Verification""" - if url is None: + api_params['userId'] = user_id + api_params['phone'] = phone + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_verification(self, url: str) -> Dict[str, Any]: + """ + Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days. + + Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. + + + + Parameters + ---------- + url : str + URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/verification' + api_params = {} + if url is None: raise AppwriteException('Missing required parameter: "url"') - params = {} - path = '/account/verification' - if url is not None: - params['url'] = url + api_params['url'] = url - return self.client.call('post', path, { + return self.client.call('post', api_path, { 'content-type': 'application/json', - }, params) + }, api_params) + + def update_verification(self, user_id: str, secret: str) -> Dict[str, Any]: + """ + Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. + + + Parameters + ---------- + user_id : str + User ID. + secret : str + Valid verification token. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/verification' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') + + if secret is None: + raise AppwriteException('Missing required parameter: "secret"') - def update_verification(self, user_id, secret): - """Create Email Verification (confirmation)""" - if user_id is None: + api_params['userId'] = user_id + api_params['secret'] = secret + + return self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_phone_verification(self) -> Dict[str, Any]: + """ + Use this endpoint to send a verification SMS to the currently logged in user. This endpoint is meant for use after updating a user's phone number using the [accountUpdatePhone](https://appwrite.io/docs/references/cloud/client-web/account#updatePhone) endpoint. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneVerification). The verification code sent to the user's phone number is valid for 15 minutes. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/verification/phone' + api_params = {} + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_phone_verification(self, user_id: str, secret: str) -> Dict[str, Any]: + """ + Use this endpoint to complete the user phone verification process. Use the **userId** and **secret** that were sent to your user's phone number to verify the user email ownership. If confirmed this route will return a 200 status code. + + + Parameters + ---------- + user_id : str + User ID. + secret : str + Valid verification token. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/verification/phone' + api_params = {} + if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') - if secret is None: + if secret is None: raise AppwriteException('Missing required parameter: "secret"') - params = {} - path = '/account/verification' - - if user_id is not None: - params['userId'] = user_id - if secret is not None: - params['secret'] = secret + api_params['userId'] = user_id + api_params['secret'] = secret - return self.client.call('put', path, { + return self.client.call('put', api_path, { 'content-type': 'application/json', - }, params) + }, api_params) diff --git a/appwrite/services/avatars.py b/appwrite/services/avatars.py index bc56aaa..2bd32f7 100644 --- a/appwrite/services/avatars.py +++ b/appwrite/services/avatars.py @@ -1,164 +1,303 @@ from ..service import Service +from typing import List, Dict, Any from ..exception import AppwriteException +from ..enums.browser import Browser; +from ..enums.credit_card import CreditCard; +from ..enums.flag import Flag; class Avatars(Service): - def __init__(self, client): + def __init__(self, client) -> None: super(Avatars, self).__init__(client) - def get_browser(self, code, width = None, height = None, quality = None): - """Get Browser Icon""" - - if code is None: + def get_browser(self, code: Browser, width: float = None, height: float = None, quality: float = None) -> bytes: + """ + You can use this endpoint to show different browser icons to your users. The code argument receives the browser code as it appears in your user [GET /account/sessions](https://appwrite.io/docs/references/cloud/client-web/account#getSessions) endpoint. Use width, height and quality arguments to change the output settings. + + When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. + + + Parameters + ---------- + code : Browser + Browser Code. + width : float + Image width. Pass an integer between 0 to 2000. Defaults to 100. + height : float + Image height. Pass an integer between 0 to 2000. Defaults to 100. + quality : float + Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. + + Returns + ------- + bytes + Response as bytes + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/avatars/browsers/{code}' + api_params = {} + if code is None: raise AppwriteException('Missing required parameter: "code"') - params = {} - path = '/avatars/browsers/{code}' - path = path.replace('{code}', code) - - if width is not None: - params['width'] = width - - if height is not None: - params['height'] = height - - if quality is not None: - params['quality'] = quality - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_credit_card(self, code, width = None, height = None, quality = None): - """Get Credit Card Icon""" - - if code is None: + api_path = api_path.replace('{code}', code) + + api_params['width'] = width + api_params['height'] = height + api_params['quality'] = quality + + return self.client.call('get', api_path, { + }, api_params) + + def get_credit_card(self, code: CreditCard, width: float = None, height: float = None, quality: float = None) -> bytes: + """ + The credit card endpoint will return you the icon of the credit card provider you need. Use width, height and quality arguments to change the output settings. + + When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. + + + + Parameters + ---------- + code : CreditCard + Credit Card Code. Possible values: amex, argencard, cabal, cencosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro, rupay. + width : float + Image width. Pass an integer between 0 to 2000. Defaults to 100. + height : float + Image height. Pass an integer between 0 to 2000. Defaults to 100. + quality : float + Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. + + Returns + ------- + bytes + Response as bytes + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/avatars/credit-cards/{code}' + api_params = {} + if code is None: raise AppwriteException('Missing required parameter: "code"') - params = {} - path = '/avatars/credit-cards/{code}' - path = path.replace('{code}', code) - - if width is not None: - params['width'] = width - - if height is not None: - params['height'] = height - - if quality is not None: - params['quality'] = quality - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_favicon(self, url): - """Get Favicon""" - - if url is None: + api_path = api_path.replace('{code}', code) + + api_params['width'] = width + api_params['height'] = height + api_params['quality'] = quality + + return self.client.call('get', api_path, { + }, api_params) + + def get_favicon(self, url: str) -> bytes: + """ + Use this endpoint to fetch the favorite icon (AKA favicon) of any remote website URL. + + This endpoint does not follow HTTP redirects. + + + Parameters + ---------- + url : str + Website URL which you want to fetch the favicon from. + + Returns + ------- + bytes + Response as bytes + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/avatars/favicon' + api_params = {} + if url is None: raise AppwriteException('Missing required parameter: "url"') - params = {} - path = '/avatars/favicon' - - if url is not None: - params['url'] = url - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - def get_flag(self, code, width = None, height = None, quality = None): - """Get Country Flag""" - - if code is None: + api_params['url'] = url + + return self.client.call('get', api_path, { + }, api_params) + + def get_flag(self, code: Flag, width: float = None, height: float = None, quality: float = None) -> bytes: + """ + You can use this endpoint to show different country flags icons to your users. The code argument receives the 2 letter country code. Use width, height and quality arguments to change the output settings. Country codes follow the [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard. + + When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. + + + + Parameters + ---------- + code : Flag + Country Code. ISO Alpha-2 country code format. + width : float + Image width. Pass an integer between 0 to 2000. Defaults to 100. + height : float + Image height. Pass an integer between 0 to 2000. Defaults to 100. + quality : float + Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. + + Returns + ------- + bytes + Response as bytes + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/avatars/flags/{code}' + api_params = {} + if code is None: raise AppwriteException('Missing required parameter: "code"') - params = {} - path = '/avatars/flags/{code}' - path = path.replace('{code}', code) - - if width is not None: - params['width'] = width - - if height is not None: - params['height'] = height - - if quality is not None: - params['quality'] = quality - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_image(self, url, width = None, height = None): - """Get Image from URL""" - - if url is None: + api_path = api_path.replace('{code}', code) + + api_params['width'] = width + api_params['height'] = height + api_params['quality'] = quality + + return self.client.call('get', api_path, { + }, api_params) + + def get_image(self, url: str, width: float = None, height: float = None) -> bytes: + """ + Use this endpoint to fetch a remote image URL and crop it to any image size you want. This endpoint is very useful if you need to crop and display remote images in your app or in case you want to make sure a 3rd party image is properly served using a TLS protocol. + + When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 400x400px. + + This endpoint does not follow HTTP redirects. + + + Parameters + ---------- + url : str + Image URL which you want to crop. + width : float + Resize preview image width, Pass an integer between 0 to 2000. Defaults to 400. + height : float + Resize preview image height, Pass an integer between 0 to 2000. Defaults to 400. + + Returns + ------- + bytes + Response as bytes + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/avatars/image' + api_params = {} + if url is None: raise AppwriteException('Missing required parameter: "url"') - params = {} - path = '/avatars/image' - - if url is not None: - params['url'] = url - - if width is not None: - params['width'] = width - - if height is not None: - params['height'] = height - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_initials(self, name = None, width = None, height = None, color = None, background = None): - """Get User Initials""" - - params = {} - path = '/avatars/initials' - - if name is not None: - params['name'] = name - if width is not None: - params['width'] = width - - if height is not None: - params['height'] = height - - if color is not None: - params['color'] = color - - if background is not None: - params['background'] = background - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_qr(self, text, size = None, margin = None, download = None): - """Get QR Code""" - - if text is None: + api_params['url'] = url + api_params['width'] = width + api_params['height'] = height + + return self.client.call('get', api_path, { + }, api_params) + + def get_initials(self, name: str = None, width: float = None, height: float = None, background: str = None) -> bytes: + """ + Use this endpoint to show your user initials avatar icon on your website or app. By default, this route will try to print your logged-in user name or email initials. You can also overwrite the user name if you pass the 'name' parameter. If no name is given and no user is logged, an empty avatar will be returned. + + You can use the color and background params to change the avatar colors. By default, a random theme will be selected. The random theme will persist for the user's initials when reloading the same theme will always return for the same initials. + + When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. + + + + Parameters + ---------- + name : str + Full Name. When empty, current user name or email will be used. Max length: 128 chars. + width : float + Image width. Pass an integer between 0 to 2000. Defaults to 100. + height : float + Image height. Pass an integer between 0 to 2000. Defaults to 100. + background : str + Changes background color. By default a random color will be picked and stay will persistent to the given name. + + Returns + ------- + bytes + Response as bytes + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/avatars/initials' + api_params = {} + + api_params['name'] = name + api_params['width'] = width + api_params['height'] = height + api_params['background'] = background + + return self.client.call('get', api_path, { + }, api_params) + + def get_qr(self, text: str, size: float = None, margin: float = None, download: bool = None) -> bytes: + """ + Converts a given plain text to a QR code image. You can use the query parameters to change the size and style of the resulting image. + + + + Parameters + ---------- + text : str + Plain text to be converted to QR code image. + size : float + QR code size. Pass an integer between 1 to 1000. Defaults to 400. + margin : float + Margin from edge. Pass an integer between 0 to 10. Defaults to 1. + download : bool + Return resulting image with 'Content-Disposition: attachment ' headers for the browser to start downloading it. Pass 0 for no header, or 1 for otherwise. Default value is set to 0. + + Returns + ------- + bytes + Response as bytes + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/avatars/qr' + api_params = {} + if text is None: raise AppwriteException('Missing required parameter: "text"') - params = {} - path = '/avatars/qr' - - if text is not None: - params['text'] = text - - if size is not None: - params['size'] = size - - if margin is not None: - params['margin'] = margin - if download is not None: - params['download'] = download + api_params['text'] = text + api_params['size'] = size + api_params['margin'] = margin + api_params['download'] = download - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) + return self.client.call('get', api_path, { + }, api_params) diff --git a/appwrite/services/database.py b/appwrite/services/database.py deleted file mode 100644 index 729163c..0000000 --- a/appwrite/services/database.py +++ /dev/null @@ -1,686 +0,0 @@ -from ..service import Service -from ..exception import AppwriteException - -class Database(Service): - - def __init__(self, client): - super(Database, self).__init__(client) - - def list_collections(self, search = None, limit = None, offset = None, cursor = None, cursor_direction = None, order_type = None): - """List Collections""" - - params = {} - path = '/database/collections' - - if search is not None: - params['search'] = search - - if limit is not None: - params['limit'] = limit - - if offset is not None: - params['offset'] = offset - - if cursor is not None: - params['cursor'] = cursor - - if cursor_direction is not None: - params['cursorDirection'] = cursor_direction - - if order_type is not None: - params['orderType'] = order_type - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def create_collection(self, collection_id, name, permission, read, write): - """Create Collection""" - - if collection_id is None: - raise AppwriteException('Missing required parameter: "collection_id"') - - if name is None: - raise AppwriteException('Missing required parameter: "name"') - - if permission is None: - raise AppwriteException('Missing required parameter: "permission"') - - if read is None: - raise AppwriteException('Missing required parameter: "read"') - - if write is None: - raise AppwriteException('Missing required parameter: "write"') - - params = {} - path = '/database/collections' - - if collection_id is not None: - params['collectionId'] = collection_id - - if name is not None: - params['name'] = name - - if permission is not None: - params['permission'] = permission - - if read is not None: - params['read'] = read - - if write is not None: - params['write'] = write - - return self.client.call('post', path, { - 'content-type': 'application/json', - }, params) - - def get_collection(self, collection_id): - """Get Collection""" - - if collection_id is None: - raise AppwriteException('Missing required parameter: "collection_id"') - - params = {} - path = '/database/collections/{collectionId}' - path = path.replace('{collectionId}', collection_id) - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def update_collection(self, collection_id, name, permission, read = None, write = None, enabled = None): - """Update Collection""" - - if collection_id is None: - raise AppwriteException('Missing required parameter: "collection_id"') - - if name is None: - raise AppwriteException('Missing required parameter: "name"') - - if permission is None: - raise AppwriteException('Missing required parameter: "permission"') - - params = {} - path = '/database/collections/{collectionId}' - path = path.replace('{collectionId}', collection_id) - - if name is not None: - params['name'] = name - - if permission is not None: - params['permission'] = permission - - if read is not None: - params['read'] = read - - if write is not None: - params['write'] = write - - if enabled is not None: - params['enabled'] = enabled - - return self.client.call('put', path, { - 'content-type': 'application/json', - }, params) - - def delete_collection(self, collection_id): - """Delete Collection""" - - if collection_id is None: - raise AppwriteException('Missing required parameter: "collection_id"') - - params = {} - path = '/database/collections/{collectionId}' - path = path.replace('{collectionId}', collection_id) - - return self.client.call('delete', path, { - 'content-type': 'application/json', - }, params) - - def list_attributes(self, collection_id): - """List Attributes""" - - if collection_id is None: - raise AppwriteException('Missing required parameter: "collection_id"') - - params = {} - path = '/database/collections/{collectionId}/attributes' - path = path.replace('{collectionId}', collection_id) - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def create_boolean_attribute(self, collection_id, key, required, default = None, array = None): - """Create Boolean Attribute""" - - if collection_id is None: - raise AppwriteException('Missing required parameter: "collection_id"') - - if key is None: - raise AppwriteException('Missing required parameter: "key"') - - if required is None: - raise AppwriteException('Missing required parameter: "required"') - - params = {} - path = '/database/collections/{collectionId}/attributes/boolean' - path = path.replace('{collectionId}', collection_id) - - if key is not None: - params['key'] = key - - if required is not None: - params['required'] = required - - if default is not None: - params['default'] = default - - if array is not None: - params['array'] = array - - return self.client.call('post', path, { - 'content-type': 'application/json', - }, params) - - def create_email_attribute(self, collection_id, key, required, default = None, array = None): - """Create Email Attribute""" - - if collection_id is None: - raise AppwriteException('Missing required parameter: "collection_id"') - - if key is None: - raise AppwriteException('Missing required parameter: "key"') - - if required is None: - raise AppwriteException('Missing required parameter: "required"') - - params = {} - path = '/database/collections/{collectionId}/attributes/email' - path = path.replace('{collectionId}', collection_id) - - if key is not None: - params['key'] = key - - if required is not None: - params['required'] = required - - if default is not None: - params['default'] = default - - if array is not None: - params['array'] = array - - return self.client.call('post', path, { - 'content-type': 'application/json', - }, params) - - def create_enum_attribute(self, collection_id, key, elements, required, default = None, array = None): - """Create Enum Attribute""" - - if collection_id is None: - raise AppwriteException('Missing required parameter: "collection_id"') - - if key is None: - raise AppwriteException('Missing required parameter: "key"') - - if elements is None: - raise AppwriteException('Missing required parameter: "elements"') - - if required is None: - raise AppwriteException('Missing required parameter: "required"') - - params = {} - path = '/database/collections/{collectionId}/attributes/enum' - path = path.replace('{collectionId}', collection_id) - - if key is not None: - params['key'] = key - - if elements is not None: - params['elements'] = elements - - if required is not None: - params['required'] = required - - if default is not None: - params['default'] = default - - if array is not None: - params['array'] = array - - return self.client.call('post', path, { - 'content-type': 'application/json', - }, params) - - def create_float_attribute(self, collection_id, key, required, min = None, max = None, default = None, array = None): - """Create Float Attribute""" - - if collection_id is None: - raise AppwriteException('Missing required parameter: "collection_id"') - - if key is None: - raise AppwriteException('Missing required parameter: "key"') - - if required is None: - raise AppwriteException('Missing required parameter: "required"') - - params = {} - path = '/database/collections/{collectionId}/attributes/float' - path = path.replace('{collectionId}', collection_id) - - if key is not None: - params['key'] = key - - if required is not None: - params['required'] = required - - if min is not None: - params['min'] = min - - if max is not None: - params['max'] = max - - if default is not None: - params['default'] = default - - if array is not None: - params['array'] = array - - return self.client.call('post', path, { - 'content-type': 'application/json', - }, params) - - def create_integer_attribute(self, collection_id, key, required, min = None, max = None, default = None, array = None): - """Create Integer Attribute""" - - if collection_id is None: - raise AppwriteException('Missing required parameter: "collection_id"') - - if key is None: - raise AppwriteException('Missing required parameter: "key"') - - if required is None: - raise AppwriteException('Missing required parameter: "required"') - - params = {} - path = '/database/collections/{collectionId}/attributes/integer' - path = path.replace('{collectionId}', collection_id) - - if key is not None: - params['key'] = key - - if required is not None: - params['required'] = required - - if min is not None: - params['min'] = min - - if max is not None: - params['max'] = max - - if default is not None: - params['default'] = default - - if array is not None: - params['array'] = array - - return self.client.call('post', path, { - 'content-type': 'application/json', - }, params) - - def create_ip_attribute(self, collection_id, key, required, default = None, array = None): - """Create IP Address Attribute""" - - if collection_id is None: - raise AppwriteException('Missing required parameter: "collection_id"') - - if key is None: - raise AppwriteException('Missing required parameter: "key"') - - if required is None: - raise AppwriteException('Missing required parameter: "required"') - - params = {} - path = '/database/collections/{collectionId}/attributes/ip' - path = path.replace('{collectionId}', collection_id) - - if key is not None: - params['key'] = key - - if required is not None: - params['required'] = required - - if default is not None: - params['default'] = default - - if array is not None: - params['array'] = array - - return self.client.call('post', path, { - 'content-type': 'application/json', - }, params) - - def create_string_attribute(self, collection_id, key, size, required, default = None, array = None): - """Create String Attribute""" - - if collection_id is None: - raise AppwriteException('Missing required parameter: "collection_id"') - - if key is None: - raise AppwriteException('Missing required parameter: "key"') - - if size is None: - raise AppwriteException('Missing required parameter: "size"') - - if required is None: - raise AppwriteException('Missing required parameter: "required"') - - params = {} - path = '/database/collections/{collectionId}/attributes/string' - path = path.replace('{collectionId}', collection_id) - - if key is not None: - params['key'] = key - - if size is not None: - params['size'] = size - - if required is not None: - params['required'] = required - - if default is not None: - params['default'] = default - - if array is not None: - params['array'] = array - - return self.client.call('post', path, { - 'content-type': 'application/json', - }, params) - - def create_url_attribute(self, collection_id, key, required, default = None, array = None): - """Create URL Attribute""" - - if collection_id is None: - raise AppwriteException('Missing required parameter: "collection_id"') - - if key is None: - raise AppwriteException('Missing required parameter: "key"') - - if required is None: - raise AppwriteException('Missing required parameter: "required"') - - params = {} - path = '/database/collections/{collectionId}/attributes/url' - path = path.replace('{collectionId}', collection_id) - - if key is not None: - params['key'] = key - - if required is not None: - params['required'] = required - - if default is not None: - params['default'] = default - - if array is not None: - params['array'] = array - - return self.client.call('post', path, { - 'content-type': 'application/json', - }, params) - - def get_attribute(self, collection_id, key): - """Get Attribute""" - - if collection_id is None: - raise AppwriteException('Missing required parameter: "collection_id"') - - if key is None: - raise AppwriteException('Missing required parameter: "key"') - - params = {} - path = '/database/collections/{collectionId}/attributes/{key}' - path = path.replace('{collectionId}', collection_id) - path = path.replace('{key}', key) - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def delete_attribute(self, collection_id, key): - """Delete Attribute""" - - if collection_id is None: - raise AppwriteException('Missing required parameter: "collection_id"') - - if key is None: - raise AppwriteException('Missing required parameter: "key"') - - params = {} - path = '/database/collections/{collectionId}/attributes/{key}' - path = path.replace('{collectionId}', collection_id) - path = path.replace('{key}', key) - - return self.client.call('delete', path, { - 'content-type': 'application/json', - }, params) - - def list_documents(self, collection_id, queries = None, limit = None, offset = None, cursor = None, cursor_direction = None, order_attributes = None, order_types = None): - """List Documents""" - - if collection_id is None: - raise AppwriteException('Missing required parameter: "collection_id"') - - params = {} - path = '/database/collections/{collectionId}/documents' - path = path.replace('{collectionId}', collection_id) - - if queries is not None: - params['queries'] = queries - - if limit is not None: - params['limit'] = limit - - if offset is not None: - params['offset'] = offset - - if cursor is not None: - params['cursor'] = cursor - - if cursor_direction is not None: - params['cursorDirection'] = cursor_direction - - if order_attributes is not None: - params['orderAttributes'] = order_attributes - - if order_types is not None: - params['orderTypes'] = order_types - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def create_document(self, collection_id, document_id, data, read = None, write = None): - """Create Document""" - - if collection_id is None: - raise AppwriteException('Missing required parameter: "collection_id"') - - if document_id is None: - raise AppwriteException('Missing required parameter: "document_id"') - - if data is None: - raise AppwriteException('Missing required parameter: "data"') - - params = {} - path = '/database/collections/{collectionId}/documents' - path = path.replace('{collectionId}', collection_id) - - if document_id is not None: - params['documentId'] = document_id - - if data is not None: - params['data'] = data - - if read is not None: - params['read'] = read - - if write is not None: - params['write'] = write - - return self.client.call('post', path, { - 'content-type': 'application/json', - }, params) - - def get_document(self, collection_id, document_id): - """Get Document""" - - if collection_id is None: - raise AppwriteException('Missing required parameter: "collection_id"') - - if document_id is None: - raise AppwriteException('Missing required parameter: "document_id"') - - params = {} - path = '/database/collections/{collectionId}/documents/{documentId}' - path = path.replace('{collectionId}', collection_id) - path = path.replace('{documentId}', document_id) - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def update_document(self, collection_id, document_id, data, read = None, write = None): - """Update Document""" - - if collection_id is None: - raise AppwriteException('Missing required parameter: "collection_id"') - - if document_id is None: - raise AppwriteException('Missing required parameter: "document_id"') - - if data is None: - raise AppwriteException('Missing required parameter: "data"') - - params = {} - path = '/database/collections/{collectionId}/documents/{documentId}' - path = path.replace('{collectionId}', collection_id) - path = path.replace('{documentId}', document_id) - - if data is not None: - params['data'] = data - - if read is not None: - params['read'] = read - - if write is not None: - params['write'] = write - - return self.client.call('patch', path, { - 'content-type': 'application/json', - }, params) - - def delete_document(self, collection_id, document_id): - """Delete Document""" - - if collection_id is None: - raise AppwriteException('Missing required parameter: "collection_id"') - - if document_id is None: - raise AppwriteException('Missing required parameter: "document_id"') - - params = {} - path = '/database/collections/{collectionId}/documents/{documentId}' - path = path.replace('{collectionId}', collection_id) - path = path.replace('{documentId}', document_id) - - return self.client.call('delete', path, { - 'content-type': 'application/json', - }, params) - - def list_indexes(self, collection_id): - """List Indexes""" - - if collection_id is None: - raise AppwriteException('Missing required parameter: "collection_id"') - - params = {} - path = '/database/collections/{collectionId}/indexes' - path = path.replace('{collectionId}', collection_id) - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def create_index(self, collection_id, key, type, attributes, orders = None): - """Create Index""" - - if collection_id is None: - raise AppwriteException('Missing required parameter: "collection_id"') - - if key is None: - raise AppwriteException('Missing required parameter: "key"') - - if type is None: - raise AppwriteException('Missing required parameter: "type"') - - if attributes is None: - raise AppwriteException('Missing required parameter: "attributes"') - - params = {} - path = '/database/collections/{collectionId}/indexes' - path = path.replace('{collectionId}', collection_id) - - if key is not None: - params['key'] = key - - if type is not None: - params['type'] = type - - if attributes is not None: - params['attributes'] = attributes - - if orders is not None: - params['orders'] = orders - - return self.client.call('post', path, { - 'content-type': 'application/json', - }, params) - - def get_index(self, collection_id, key): - """Get Index""" - - if collection_id is None: - raise AppwriteException('Missing required parameter: "collection_id"') - - if key is None: - raise AppwriteException('Missing required parameter: "key"') - - params = {} - path = '/database/collections/{collectionId}/indexes/{key}' - path = path.replace('{collectionId}', collection_id) - path = path.replace('{key}', key) - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def delete_index(self, collection_id, key): - """Delete Index""" - - if collection_id is None: - raise AppwriteException('Missing required parameter: "collection_id"') - - if key is None: - raise AppwriteException('Missing required parameter: "key"') - - params = {} - path = '/database/collections/{collectionId}/indexes/{key}' - path = path.replace('{collectionId}', collection_id) - path = path.replace('{key}', key) - - return self.client.call('delete', path, { - 'content-type': 'application/json', - }, params) diff --git a/appwrite/services/databases.py b/appwrite/services/databases.py new file mode 100644 index 0000000..40b7372 --- /dev/null +++ b/appwrite/services/databases.py @@ -0,0 +1,2539 @@ +from ..service import Service +from typing import List, Dict, Any +from ..exception import AppwriteException +from ..enums.relationship_type import RelationshipType; +from ..enums.relation_mutate import RelationMutate; +from ..enums.index_type import IndexType; + +class Databases(Service): + + def __init__(self, client) -> None: + super(Databases, self).__init__(client) + + def list(self, queries: List[str] = None, search: str = None) -> Dict[str, Any]: + """ + Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. + + + Parameters + ---------- + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name + search : str + Search term to filter your list results. Max length: 256 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases' + api_params = {} + + api_params['queries'] = queries + api_params['search'] = search + + return self.client.call('get', api_path, { + }, api_params) + + def create(self, database_id: str, name: str, enabled: bool = None) -> Dict[str, Any]: + """ + Create a new Database. + + + + Parameters + ---------- + database_id : str + Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + name : str + Database name. Max length: 128 chars. + enabled : bool + Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + + api_params['databaseId'] = database_id + api_params['name'] = name + api_params['enabled'] = enabled + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def get(self, database_id: str) -> Dict[str, Any]: + """ + Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. + + + Parameters + ---------- + database_id : str + Database ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + api_path = api_path.replace('{databaseId}', database_id) + + + return self.client.call('get', api_path, { + }, api_params) + + def update(self, database_id: str, name: str, enabled: bool = None) -> Dict[str, Any]: + """ + Update a database by its unique ID. + + + Parameters + ---------- + database_id : str + Database ID. + name : str + Database name. Max length: 128 chars. + enabled : bool + Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + api_path = api_path.replace('{databaseId}', database_id) + + api_params['name'] = name + api_params['enabled'] = enabled + + return self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + def delete(self, database_id: str) -> Dict[str, Any]: + """ + Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database. + + + Parameters + ---------- + database_id : str + Database ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + api_path = api_path.replace('{databaseId}', database_id) + + + return self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + def list_collections(self, database_id: str, queries: List[str] = None, search: str = None) -> Dict[str, Any]: + """ + Get a list of all collections that belong to the provided databaseId. You can use the search parameter to filter your results. + + + Parameters + ---------- + database_id : str + Database ID. + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, documentSecurity + search : str + Search term to filter your list results. Max length: 256 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + api_path = api_path.replace('{databaseId}', database_id) + + api_params['queries'] = queries + api_params['search'] = search + + return self.client.call('get', api_path, { + }, api_params) + + def create_collection(self, database_id: str, collection_id: str, name: str, permissions: List[str] = None, document_security: bool = None, enabled: bool = None) -> Dict[str, Any]: + """ + Create a new Collection. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + name : str + Collection name. Max length: 128 chars. + permissions : List[str] + An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + document_security : bool + Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + enabled : bool + Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + api_path = api_path.replace('{databaseId}', database_id) + + api_params['collectionId'] = collection_id + api_params['name'] = name + api_params['permissions'] = permissions + api_params['documentSecurity'] = document_security + api_params['enabled'] = enabled + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def get_collection(self, database_id: str, collection_id: str) -> Dict[str, Any]: + """ + Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + + + return self.client.call('get', api_path, { + }, api_params) + + def update_collection(self, database_id: str, collection_id: str, name: str, permissions: List[str] = None, document_security: bool = None, enabled: bool = None) -> Dict[str, Any]: + """ + Update a collection by its unique ID. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. + name : str + Collection name. Max length: 128 chars. + permissions : List[str] + An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + document_security : bool + Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + enabled : bool + Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + + api_params['name'] = name + api_params['permissions'] = permissions + api_params['documentSecurity'] = document_security + api_params['enabled'] = enabled + + return self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + def delete_collection(self, database_id: str, collection_id: str) -> Dict[str, Any]: + """ + Delete a collection by its unique ID. Only users with write permissions have access to delete this resource. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + + + return self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + def list_attributes(self, database_id: str, collection_id: str, queries: List[str] = None) -> Dict[str, Any]: + """ + List attributes in the collection. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, type, size, required, array, status, error + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + + api_params['queries'] = queries + + return self.client.call('get', api_path, { + }, api_params) + + def create_boolean_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: bool = None, array: bool = None) -> Dict[str, Any]: + """ + Create a boolean attribute. + + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Attribute Key. + required : bool + Is attribute required? + default : bool + Default value for attribute when not provided. Cannot be set when attribute is required. + array : bool + Is attribute an array? + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + + api_params['key'] = key + api_params['required'] = required + api_params['default'] = default + api_params['array'] = array + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_boolean_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: bool, new_key: str = None) -> Dict[str, Any]: + """ + Update a boolean attribute. Changing the `default` value will not update already existing documents. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Attribute Key. + required : bool + Is attribute required? + default : bool + Default value for attribute when not provided. Cannot be set when attribute is required. + new_key : str + New attribute key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{key}', key) + + api_params['required'] = required + api_params['default'] = default + api_params['newKey'] = new_key + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_datetime_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: str = None, array: bool = None) -> Dict[str, Any]: + """ + Create a date time attribute according to the ISO 8601 standard. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Attribute Key. + required : bool + Is attribute required? + default : str + Default value for the attribute in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when attribute is required. + array : bool + Is attribute an array? + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + + api_params['key'] = key + api_params['required'] = required + api_params['default'] = default + api_params['array'] = array + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_datetime_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: str, new_key: str = None) -> Dict[str, Any]: + """ + Update a date time attribute. Changing the `default` value will not update already existing documents. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Attribute Key. + required : bool + Is attribute required? + default : str + Default value for attribute when not provided. Cannot be set when attribute is required. + new_key : str + New attribute key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{key}', key) + + api_params['required'] = required + api_params['default'] = default + api_params['newKey'] = new_key + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_email_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: str = None, array: bool = None) -> Dict[str, Any]: + """ + Create an email attribute. + + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Attribute Key. + required : bool + Is attribute required? + default : str + Default value for attribute when not provided. Cannot be set when attribute is required. + array : bool + Is attribute an array? + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/email' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + + api_params['key'] = key + api_params['required'] = required + api_params['default'] = default + api_params['array'] = array + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_email_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: str, new_key: str = None) -> Dict[str, Any]: + """ + Update an email attribute. Changing the `default` value will not update already existing documents. + + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Attribute Key. + required : bool + Is attribute required? + default : str + Default value for attribute when not provided. Cannot be set when attribute is required. + new_key : str + New attribute key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{key}', key) + + api_params['required'] = required + api_params['default'] = default + api_params['newKey'] = new_key + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_enum_attribute(self, database_id: str, collection_id: str, key: str, elements: List[str], required: bool, default: str = None, array: bool = None) -> Dict[str, Any]: + """ + Create an enumeration attribute. The `elements` param acts as a white-list of accepted values for this attribute. + + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Attribute Key. + elements : List[str] + Array of elements in enumerated type. Uses length of longest element to determine size. Maximum of 100 elements are allowed, each 255 characters long. + required : bool + Is attribute required? + default : str + Default value for attribute when not provided. Cannot be set when attribute is required. + array : bool + Is attribute an array? + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if elements is None: + raise AppwriteException('Missing required parameter: "elements"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + + api_params['key'] = key + api_params['elements'] = elements + api_params['required'] = required + api_params['default'] = default + api_params['array'] = array + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_enum_attribute(self, database_id: str, collection_id: str, key: str, elements: List[str], required: bool, default: str, new_key: str = None) -> Dict[str, Any]: + """ + Update an enum attribute. Changing the `default` value will not update already existing documents. + + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Attribute Key. + elements : List[str] + Array of elements in enumerated type. Uses length of longest element to determine size. Maximum of 100 elements are allowed, each 255 characters long. + required : bool + Is attribute required? + default : str + Default value for attribute when not provided. Cannot be set when attribute is required. + new_key : str + New attribute key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if elements is None: + raise AppwriteException('Missing required parameter: "elements"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{key}', key) + + api_params['elements'] = elements + api_params['required'] = required + api_params['default'] = default + api_params['newKey'] = new_key + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_float_attribute(self, database_id: str, collection_id: str, key: str, required: bool, min: float = None, max: float = None, default: float = None, array: bool = None) -> Dict[str, Any]: + """ + Create a float attribute. Optionally, minimum and maximum values can be provided. + + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Attribute Key. + required : bool + Is attribute required? + min : float + Minimum value to enforce on new documents + max : float + Maximum value to enforce on new documents + default : float + Default value for attribute when not provided. Cannot be set when attribute is required. + array : bool + Is attribute an array? + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/float' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + + api_params['key'] = key + api_params['required'] = required + api_params['min'] = min + api_params['max'] = max + api_params['default'] = default + api_params['array'] = array + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_float_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: float, min: float = None, max: float = None, new_key: str = None) -> Dict[str, Any]: + """ + Update a float attribute. Changing the `default` value will not update already existing documents. + + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Attribute Key. + required : bool + Is attribute required? + default : float + Default value for attribute when not provided. Cannot be set when attribute is required. + min : float + Minimum value to enforce on new documents + max : float + Maximum value to enforce on new documents + new_key : str + New attribute key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{key}', key) + + api_params['required'] = required + api_params['min'] = min + api_params['max'] = max + api_params['default'] = default + api_params['newKey'] = new_key + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_integer_attribute(self, database_id: str, collection_id: str, key: str, required: bool, min: float = None, max: float = None, default: float = None, array: bool = None) -> Dict[str, Any]: + """ + Create an integer attribute. Optionally, minimum and maximum values can be provided. + + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Attribute Key. + required : bool + Is attribute required? + min : float + Minimum value to enforce on new documents + max : float + Maximum value to enforce on new documents + default : float + Default value for attribute when not provided. Cannot be set when attribute is required. + array : bool + Is attribute an array? + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + + api_params['key'] = key + api_params['required'] = required + api_params['min'] = min + api_params['max'] = max + api_params['default'] = default + api_params['array'] = array + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_integer_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: float, min: float = None, max: float = None, new_key: str = None) -> Dict[str, Any]: + """ + Update an integer attribute. Changing the `default` value will not update already existing documents. + + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Attribute Key. + required : bool + Is attribute required? + default : float + Default value for attribute when not provided. Cannot be set when attribute is required. + min : float + Minimum value to enforce on new documents + max : float + Maximum value to enforce on new documents + new_key : str + New attribute key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{key}', key) + + api_params['required'] = required + api_params['min'] = min + api_params['max'] = max + api_params['default'] = default + api_params['newKey'] = new_key + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_ip_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: str = None, array: bool = None) -> Dict[str, Any]: + """ + Create IP address attribute. + + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Attribute Key. + required : bool + Is attribute required? + default : str + Default value for attribute when not provided. Cannot be set when attribute is required. + array : bool + Is attribute an array? + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + + api_params['key'] = key + api_params['required'] = required + api_params['default'] = default + api_params['array'] = array + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_ip_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: str, new_key: str = None) -> Dict[str, Any]: + """ + Update an ip attribute. Changing the `default` value will not update already existing documents. + + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Attribute Key. + required : bool + Is attribute required? + default : str + Default value for attribute when not provided. Cannot be set when attribute is required. + new_key : str + New attribute key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{key}', key) + + api_params['required'] = required + api_params['default'] = default + api_params['newKey'] = new_key + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_relationship_attribute(self, database_id: str, collection_id: str, related_collection_id: str, type: RelationshipType, two_way: bool = None, key: str = None, two_way_key: str = None, on_delete: RelationMutate = None) -> Dict[str, Any]: + """ + Create relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). + + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + related_collection_id : str + Related Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + type : RelationshipType + Relation type + two_way : bool + Is Two Way? + key : str + Attribute Key. + two_way_key : str + Two Way Attribute Key. + on_delete : RelationMutate + Constraints option + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if related_collection_id is None: + raise AppwriteException('Missing required parameter: "related_collection_id"') + + if type is None: + raise AppwriteException('Missing required parameter: "type"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + + api_params['relatedCollectionId'] = related_collection_id + api_params['type'] = type + api_params['twoWay'] = two_way + api_params['key'] = key + api_params['twoWayKey'] = two_way_key + api_params['onDelete'] = on_delete + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_string_attribute(self, database_id: str, collection_id: str, key: str, size: float, required: bool, default: str = None, array: bool = None, encrypt: bool = None) -> Dict[str, Any]: + """ + Create a string attribute. + + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Attribute Key. + size : float + Attribute size for text attributes, in number of characters. + required : bool + Is attribute required? + default : str + Default value for attribute when not provided. Cannot be set when attribute is required. + array : bool + Is attribute an array? + encrypt : bool + Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/string' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if size is None: + raise AppwriteException('Missing required parameter: "size"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + + api_params['key'] = key + api_params['size'] = size + api_params['required'] = required + api_params['default'] = default + api_params['array'] = array + api_params['encrypt'] = encrypt + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_string_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: str, size: float = None, new_key: str = None) -> Dict[str, Any]: + """ + Update a string attribute. Changing the `default` value will not update already existing documents. + + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Attribute Key. + required : bool + Is attribute required? + default : str + Default value for attribute when not provided. Cannot be set when attribute is required. + size : float + Maximum size of the string attribute. + new_key : str + New attribute key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{key}', key) + + api_params['required'] = required + api_params['default'] = default + api_params['size'] = size + api_params['newKey'] = new_key + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_url_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: str = None, array: bool = None) -> Dict[str, Any]: + """ + Create a URL attribute. + + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Attribute Key. + required : bool + Is attribute required? + default : str + Default value for attribute when not provided. Cannot be set when attribute is required. + array : bool + Is attribute an array? + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/url' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + + api_params['key'] = key + api_params['required'] = required + api_params['default'] = default + api_params['array'] = array + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_url_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: str, new_key: str = None) -> Dict[str, Any]: + """ + Update an url attribute. Changing the `default` value will not update already existing documents. + + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Attribute Key. + required : bool + Is attribute required? + default : str + Default value for attribute when not provided. Cannot be set when attribute is required. + new_key : str + New attribute key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{key}', key) + + api_params['required'] = required + api_params['default'] = default + api_params['newKey'] = new_key + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def get_attribute(self, database_id: str, collection_id: str, key: str) -> Dict[str, Any]: + """ + Get attribute by ID. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Attribute Key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{key}', key) + + + return self.client.call('get', api_path, { + }, api_params) + + def delete_attribute(self, database_id: str, collection_id: str, key: str) -> Dict[str, Any]: + """ + Deletes an attribute. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Attribute Key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{key}', key) + + + return self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_relationship_attribute(self, database_id: str, collection_id: str, key: str, on_delete: RelationMutate = None, new_key: str = None) -> Dict[str, Any]: + """ + Update relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). + + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Attribute Key. + on_delete : RelationMutate + Constraints option + new_key : str + New attribute key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{key}', key) + + api_params['onDelete'] = on_delete + api_params['newKey'] = new_key + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def list_documents(self, database_id: str, collection_id: str, queries: List[str] = None) -> Dict[str, Any]: + """ + Get a list of all the user's documents in a given collection. You can use the query params to filter your results. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/documents' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + + api_params['queries'] = queries + + return self.client.call('get', api_path, { + }, api_params) + + def create_document(self, database_id: str, collection_id: str, document_id: str, data: dict, permissions: List[str] = None) -> Dict[str, Any]: + """ + Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. + document_id : str + Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + data : dict + Document data as JSON object. + permissions : List[str] + An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/documents' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if document_id is None: + raise AppwriteException('Missing required parameter: "document_id"') + + if data is None: + raise AppwriteException('Missing required parameter: "data"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + + api_params['documentId'] = document_id + api_params['data'] = data + api_params['permissions'] = permissions + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_documents(self, database_id: str, collection_id: str, documents: List[dict]) -> Dict[str, Any]: + """ + **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions. + + Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. + documents : List[dict] + Array of documents data as JSON objects. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/documents' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if documents is None: + raise AppwriteException('Missing required parameter: "documents"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + + api_params['documents'] = documents + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def upsert_documents(self, database_id: str, collection_id: str, documents: List[dict]) -> Dict[str, Any]: + """ + **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions. + + Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. + + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. + documents : List[dict] + Array of document data as JSON objects. May contain partial documents. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/documents' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if documents is None: + raise AppwriteException('Missing required parameter: "documents"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + + api_params['documents'] = documents + + return self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_documents(self, database_id: str, collection_id: str, data: dict = None, queries: List[str] = None) -> Dict[str, Any]: + """ + **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions. + + Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. + data : dict + Document data as JSON object. Include only attribute and value pairs to be updated. + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/documents' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + + api_params['data'] = data + api_params['queries'] = queries + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def delete_documents(self, database_id: str, collection_id: str, queries: List[str] = None) -> Dict[str, Any]: + """ + **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions. + + Bulk delete documents using queries, if no queries are passed then all documents are deleted. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/documents' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + + api_params['queries'] = queries + + return self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + def get_document(self, database_id: str, collection_id: str, document_id: str, queries: List[str] = None) -> Dict[str, Any]: + """ + Get a document by its unique ID. This endpoint response returns a JSON object with the document data. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + document_id : str + Document ID. + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if document_id is None: + raise AppwriteException('Missing required parameter: "document_id"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{documentId}', document_id) + + api_params['queries'] = queries + + return self.client.call('get', api_path, { + }, api_params) + + def upsert_document(self, database_id: str, collection_id: str, document_id: str, data: dict, permissions: List[str] = None) -> Dict[str, Any]: + """ + **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions. + + Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. + document_id : str + Document ID. + data : dict + Document data as JSON object. Include all required attributes of the document to be created or updated. + permissions : List[str] + An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if document_id is None: + raise AppwriteException('Missing required parameter: "document_id"') + + if data is None: + raise AppwriteException('Missing required parameter: "data"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{documentId}', document_id) + + api_params['data'] = data + api_params['permissions'] = permissions + + return self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_document(self, database_id: str, collection_id: str, document_id: str, data: dict = None, permissions: List[str] = None) -> Dict[str, Any]: + """ + Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. + document_id : str + Document ID. + data : dict + Document data as JSON object. Include only attribute and value pairs to be updated. + permissions : List[str] + An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if document_id is None: + raise AppwriteException('Missing required parameter: "document_id"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{documentId}', document_id) + + api_params['data'] = data + api_params['permissions'] = permissions + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def delete_document(self, database_id: str, collection_id: str, document_id: str) -> Dict[str, Any]: + """ + Delete a document by its unique ID. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + document_id : str + Document ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if document_id is None: + raise AppwriteException('Missing required parameter: "document_id"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{documentId}', document_id) + + + return self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + def decrement_document_attribute(self, database_id: str, collection_id: str, document_id: str, attribute: str, value: float = None, min: float = None) -> Dict[str, Any]: + """ + Decrement a specific attribute of a document by a given value. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. + document_id : str + Document ID. + attribute : str + Attribute key. + value : float + Value to decrement the attribute by. The value must be a number. + min : float + Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if document_id is None: + raise AppwriteException('Missing required parameter: "document_id"') + + if attribute is None: + raise AppwriteException('Missing required parameter: "attribute"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{documentId}', document_id) + api_path = api_path.replace('{attribute}', attribute) + + api_params['value'] = value + api_params['min'] = min + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def increment_document_attribute(self, database_id: str, collection_id: str, document_id: str, attribute: str, value: float = None, max: float = None) -> Dict[str, Any]: + """ + Increment a specific attribute of a document by a given value. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. + document_id : str + Document ID. + attribute : str + Attribute key. + value : float + Value to increment the attribute by. The value must be a number. + max : float + Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if document_id is None: + raise AppwriteException('Missing required parameter: "document_id"') + + if attribute is None: + raise AppwriteException('Missing required parameter: "attribute"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{documentId}', document_id) + api_path = api_path.replace('{attribute}', attribute) + + api_params['value'] = value + api_params['max'] = max + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def list_indexes(self, database_id: str, collection_id: str, queries: List[str] = None) -> Dict[str, Any]: + """ + List indexes in the collection. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, type, status, attributes, error + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/indexes' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + + api_params['queries'] = queries + + return self.client.call('get', api_path, { + }, api_params) + + def create_index(self, database_id: str, collection_id: str, key: str, type: IndexType, attributes: List[str], orders: List[str] = None, lengths: List[float] = None) -> Dict[str, Any]: + """ + Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. + Attributes can be `key`, `fulltext`, and `unique`. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Index Key. + type : IndexType + Index type. + attributes : List[str] + Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long. + orders : List[str] + Array of index orders. Maximum of 100 orders are allowed. + lengths : List[float] + Length of index. Maximum of 100 + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/indexes' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if type is None: + raise AppwriteException('Missing required parameter: "type"') + + if attributes is None: + raise AppwriteException('Missing required parameter: "attributes"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + + api_params['key'] = key + api_params['type'] = type + api_params['attributes'] = attributes + api_params['orders'] = orders + api_params['lengths'] = lengths + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def get_index(self, database_id: str, collection_id: str, key: str) -> Dict[str, Any]: + """ + Get index by ID. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Index Key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{key}', key) + + + return self.client.call('get', api_path, { + }, api_params) + + def delete_index(self, database_id: str, collection_id: str, key: str) -> Dict[str, Any]: + """ + Delete an index. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Index Key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{key}', key) + + + return self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) diff --git a/appwrite/services/functions.py b/appwrite/services/functions.py index aa0bec7..3dd2459 100644 --- a/appwrite/services/functions.py +++ b/appwrite/services/functions.py @@ -1,335 +1,1150 @@ from ..service import Service +from typing import List, Dict, Any from ..exception import AppwriteException +from ..enums.runtime import Runtime; +from ..input_file import InputFile +from ..enums.vcs_deployment_type import VCSDeploymentType; +from ..enums.deployment_download_type import DeploymentDownloadType; +from ..enums.execution_method import ExecutionMethod; class Functions(Service): - def __init__(self, client): + def __init__(self, client) -> None: super(Functions, self).__init__(client) - def list(self, search = None, limit = None, offset = None, cursor = None, cursor_direction = None, order_type = None): - """List Functions""" - - params = {} - path = '/functions' - - if search is not None: - params['search'] = search - - if limit is not None: - params['limit'] = limit - - if offset is not None: - params['offset'] = offset - - if cursor is not None: - params['cursor'] = cursor - - if cursor_direction is not None: - params['cursorDirection'] = cursor_direction - - if order_type is not None: - params['orderType'] = order_type - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def create(self, function_id, name, execute, runtime, vars = None, events = None, schedule = None, timeout = None): - """Create Function""" - - if function_id is None: + def list(self, queries: List[str] = None, search: str = None) -> Dict[str, Any]: + """ + Get a list of all the project's functions. You can use the query params to filter your results. + + + Parameters + ---------- + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, runtime, deploymentId, schedule, scheduleNext, schedulePrevious, timeout, entrypoint, commands, installationId + search : str + Search term to filter your list results. Max length: 256 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/functions' + api_params = {} + + api_params['queries'] = queries + api_params['search'] = search + + return self.client.call('get', api_path, { + }, api_params) + + def create(self, function_id: str, name: str, runtime: Runtime, execute: List[str] = None, events: List[str] = None, schedule: str = None, timeout: float = None, enabled: bool = None, logging: bool = None, entrypoint: str = None, commands: str = None, scopes: List[str] = None, installation_id: str = None, provider_repository_id: str = None, provider_branch: str = None, provider_silent_mode: bool = None, provider_root_directory: str = None, specification: str = None) -> Dict[str, Any]: + """ + 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. + + + Parameters + ---------- + function_id : str + Function ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + name : str + Function name. Max length: 128 chars. + runtime : Runtime + Execution runtime. + execute : List[str] + 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 : List[str] + Events list. Maximum of 100 events are allowed. + schedule : str + Schedule CRON syntax. + timeout : float + Function maximum execution time in seconds. + enabled : bool + 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. + logging : bool + When disabled, executions will exclude logs and errors, and will be slightly faster. + entrypoint : str + Entrypoint File. This path is relative to the "providerRootDirectory". + commands : str + Build Commands. + scopes : List[str] + List of scopes allowed for API key auto-generated for every execution. Maximum of 100 scopes are allowed. + installation_id : str + Appwrite Installation ID for VCS (Version Control System) deployment. + provider_repository_id : str + Repository ID of the repo linked to the function. + provider_branch : str + Production branch for the repo linked to the function. + provider_silent_mode : bool + Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. + provider_root_directory : str + Path to function code in the linked repo. + specification : str + Runtime specification for the function and builds. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/functions' + api_params = {} + if function_id is None: raise AppwriteException('Missing required parameter: "function_id"') - if name is None: + if name is None: raise AppwriteException('Missing required parameter: "name"') - if execute is None: - raise AppwriteException('Missing required parameter: "execute"') - - if runtime is None: + if runtime is None: raise AppwriteException('Missing required parameter: "runtime"') - params = {} - path = '/functions' - - if function_id is not None: - params['functionId'] = function_id - - if name is not None: - params['name'] = name - - if execute is not None: - params['execute'] = execute - - if runtime is not None: - params['runtime'] = runtime - if vars is not None: - params['vars'] = vars - - if events is not None: - params['events'] = events + api_params['functionId'] = function_id + api_params['name'] = name + api_params['runtime'] = runtime + api_params['execute'] = execute + api_params['events'] = events + api_params['schedule'] = schedule + api_params['timeout'] = timeout + api_params['enabled'] = enabled + api_params['logging'] = logging + api_params['entrypoint'] = entrypoint + api_params['commands'] = commands + api_params['scopes'] = scopes + api_params['installationId'] = installation_id + api_params['providerRepositoryId'] = provider_repository_id + api_params['providerBranch'] = provider_branch + api_params['providerSilentMode'] = provider_silent_mode + api_params['providerRootDirectory'] = provider_root_directory + api_params['specification'] = specification + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def list_runtimes(self) -> Dict[str, Any]: + """ + Get a list of all runtimes that are currently active on your instance. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/functions/runtimes' + api_params = {} + + return self.client.call('get', api_path, { + }, api_params) + + def list_specifications(self) -> Dict[str, Any]: + """ + List allowed function specifications for this instance. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/functions/specifications' + api_params = {} + + return self.client.call('get', api_path, { + }, api_params) + + def get(self, function_id: str) -> Dict[str, Any]: + """ + Get a function by its unique ID. + + + Parameters + ---------- + function_id : str + Function ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/functions/{functionId}' + api_params = {} + if function_id is None: + raise AppwriteException('Missing required parameter: "function_id"') - if schedule is not None: - params['schedule'] = schedule + api_path = api_path.replace('{functionId}', function_id) + + + return self.client.call('get', api_path, { + }, api_params) + + def update(self, function_id: str, name: str, runtime: Runtime = None, execute: List[str] = None, events: List[str] = None, schedule: str = None, timeout: float = None, enabled: bool = None, logging: bool = None, entrypoint: str = None, commands: str = None, scopes: List[str] = None, installation_id: str = None, provider_repository_id: str = None, provider_branch: str = None, provider_silent_mode: bool = None, provider_root_directory: str = None, specification: str = None) -> Dict[str, Any]: + """ + Update function by its unique ID. + + + Parameters + ---------- + function_id : str + Function ID. + name : str + Function name. Max length: 128 chars. + runtime : Runtime + Execution runtime. + execute : List[str] + 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 : List[str] + Events list. Maximum of 100 events are allowed. + schedule : str + Schedule CRON syntax. + timeout : float + Maximum execution time in seconds. + enabled : bool + 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. + logging : bool + When disabled, executions will exclude logs and errors, and will be slightly faster. + entrypoint : str + Entrypoint File. This path is relative to the "providerRootDirectory". + commands : str + Build Commands. + scopes : List[str] + List of scopes allowed for API Key auto-generated for every execution. Maximum of 100 scopes are allowed. + installation_id : str + Appwrite Installation ID for VCS (Version Controle System) deployment. + provider_repository_id : str + Repository ID of the repo linked to the function + provider_branch : str + Production branch for the repo linked to the function + provider_silent_mode : bool + Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. + provider_root_directory : str + Path to function code in the linked repo. + specification : str + Runtime specification for the function and builds. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/functions/{functionId}' + api_params = {} + if function_id is None: + raise AppwriteException('Missing required parameter: "function_id"') - if timeout is not None: - params['timeout'] = timeout + if name is None: + raise AppwriteException('Missing required parameter: "name"') - return self.client.call('post', path, { + api_path = api_path.replace('{functionId}', function_id) + + api_params['name'] = name + api_params['runtime'] = runtime + api_params['execute'] = execute + api_params['events'] = events + api_params['schedule'] = schedule + api_params['timeout'] = timeout + api_params['enabled'] = enabled + api_params['logging'] = logging + api_params['entrypoint'] = entrypoint + api_params['commands'] = commands + api_params['scopes'] = scopes + api_params['installationId'] = installation_id + api_params['providerRepositoryId'] = provider_repository_id + api_params['providerBranch'] = provider_branch + api_params['providerSilentMode'] = provider_silent_mode + api_params['providerRootDirectory'] = provider_root_directory + api_params['specification'] = specification + + return self.client.call('put', api_path, { 'content-type': 'application/json', - }, params) + }, api_params) + + def delete(self, function_id: str) -> Dict[str, Any]: + """ + Delete a function by its unique ID. + + + Parameters + ---------- + function_id : str + Function ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/functions/{functionId}' + api_params = {} + if function_id is None: + raise AppwriteException('Missing required parameter: "function_id"') - def list_runtimes(self): - """List the currently active function runtimes.""" + api_path = api_path.replace('{functionId}', function_id) - params = {} - path = '/functions/runtimes' - return self.client.call('get', path, { + return self.client.call('delete', api_path, { 'content-type': 'application/json', - }, params) - - def get(self, function_id): - """Get Function""" - - if function_id is None: + }, api_params) + + def update_function_deployment(self, function_id: str, deployment_id: str) -> Dict[str, Any]: + """ + Update the function active deployment. Use this endpoint to switch the code deployment that should be used when visitor opens your function. + + + Parameters + ---------- + function_id : str + Function ID. + deployment_id : str + Deployment ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/functions/{functionId}/deployment' + api_params = {} + if function_id is None: raise AppwriteException('Missing required parameter: "function_id"') - params = {} - path = '/functions/{functionId}' - path = path.replace('{functionId}', function_id) + if deployment_id is None: + raise AppwriteException('Missing required parameter: "deployment_id"') - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) + api_path = api_path.replace('{functionId}', function_id) - def update(self, function_id, name, execute, vars = None, events = None, schedule = None, timeout = None): - """Update Function""" + api_params['deploymentId'] = deployment_id - if function_id is None: + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def list_deployments(self, function_id: str, queries: List[str] = None, search: str = None) -> Dict[str, Any]: + """ + Get a list of all the function's code deployments. You can use the query params to filter your results. + + + Parameters + ---------- + function_id : str + Function ID. + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: buildSize, sourceSize, totalSize, buildDuration, status, activate, type + search : str + Search term to filter your list results. Max length: 256 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/functions/{functionId}/deployments' + api_params = {} + if function_id is None: raise AppwriteException('Missing required parameter: "function_id"') - if name is None: - raise AppwriteException('Missing required parameter: "name"') - - if execute is None: - raise AppwriteException('Missing required parameter: "execute"') - - params = {} - path = '/functions/{functionId}' - path = path.replace('{functionId}', function_id) + api_path = api_path.replace('{functionId}', function_id) + + api_params['queries'] = queries + api_params['search'] = search + + return self.client.call('get', api_path, { + }, api_params) + + def create_deployment(self, function_id: str, code: InputFile, activate: bool, entrypoint: str = None, commands: str = None, on_progress = None) -> Dict[str, Any]: + """ + Create a new function code deployment. Use this endpoint to upload a new version of your code function. To execute your newly uploaded code, you'll need to update the function's deployment to use your new deployment UID. + + This endpoint accepts a tar.gz file compressed with your code. Make sure to include any dependencies your code has within the compressed file. You can learn more about code packaging in the [Appwrite Cloud Functions tutorial](https://appwrite.io/docs/functions). + + Use the "command" param to set the entrypoint used to execute your code. + + + Parameters + ---------- + function_id : str + Function ID. + code : InputFile + Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory. + activate : bool + Automatically activate the deployment when it is finished building. + entrypoint : str + Entrypoint File. + commands : str + Build Commands. + on_progress : callable, optional + Optional callback for upload progress + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/functions/{functionId}/deployments' + api_params = {} + if function_id is None: + raise AppwriteException('Missing required parameter: "function_id"') - if name is not None: - params['name'] = name + if code is None: + raise AppwriteException('Missing required parameter: "code"') - if execute is not None: - params['execute'] = execute + if activate is None: + raise AppwriteException('Missing required parameter: "activate"') - if vars is not None: - params['vars'] = vars + api_path = api_path.replace('{functionId}', function_id) - if events is not None: - params['events'] = events + api_params['entrypoint'] = entrypoint + api_params['commands'] = commands + api_params['code'] = str(code).lower() if type(code) is bool else code + api_params['activate'] = str(activate).lower() if type(activate) is bool else activate - if schedule is not None: - params['schedule'] = schedule + param_name = 'code' - if timeout is not None: - params['timeout'] = timeout - return self.client.call('put', path, { - 'content-type': 'application/json', - }, params) + upload_id = '' - def delete(self, function_id): - """Delete Function""" - - if function_id is None: + return self.client.chunked_upload(api_path, { + 'content-type': 'multipart/form-data', + }, api_params, param_name, on_progress, upload_id) + + def create_duplicate_deployment(self, function_id: str, deployment_id: str, build_id: str = None) -> Dict[str, Any]: + """ + Create a new build for an existing function deployment. This endpoint allows you to rebuild a deployment with the updated function configuration, including its entrypoint and build commands if they have been modified. The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build. + + + Parameters + ---------- + function_id : str + Function ID. + deployment_id : str + Deployment ID. + build_id : str + Build unique ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/functions/{functionId}/deployments/duplicate' + api_params = {} + if function_id is None: raise AppwriteException('Missing required parameter: "function_id"') - params = {} - path = '/functions/{functionId}' - path = path.replace('{functionId}', function_id) + if deployment_id is None: + raise AppwriteException('Missing required parameter: "deployment_id"') - return self.client.call('delete', path, { - 'content-type': 'application/json', - }, params) + api_path = api_path.replace('{functionId}', function_id) - def list_executions(self, function_id, limit = None, offset = None, search = None, cursor = None, cursor_direction = None): - """List Executions""" + api_params['deploymentId'] = deployment_id + api_params['buildId'] = build_id - if function_id is None: + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_template_deployment(self, function_id: str, repository: str, owner: str, root_directory: str, version: str, activate: bool = None) -> Dict[str, Any]: + """ + Create a deployment based on a template. + + Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/server/functions#listTemplates) to find the template details. + + + Parameters + ---------- + function_id : str + Function ID. + repository : str + Repository name of the template. + owner : str + The name of the owner of the template. + root_directory : str + Path to function code in the template repo. + version : str + Version (tag) for the repo linked to the function template. + activate : bool + Automatically activate the deployment when it is finished building. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/functions/{functionId}/deployments/template' + api_params = {} + if function_id is None: raise AppwriteException('Missing required parameter: "function_id"') - params = {} - path = '/functions/{functionId}/executions' - path = path.replace('{functionId}', function_id) + if repository is None: + raise AppwriteException('Missing required parameter: "repository"') - if limit is not None: - params['limit'] = limit + if owner is None: + raise AppwriteException('Missing required parameter: "owner"') - if offset is not None: - params['offset'] = offset + if root_directory is None: + raise AppwriteException('Missing required parameter: "root_directory"') - if search is not None: - params['search'] = search + if version is None: + raise AppwriteException('Missing required parameter: "version"') - if cursor is not None: - params['cursor'] = cursor + api_path = api_path.replace('{functionId}', function_id) - if cursor_direction is not None: - params['cursorDirection'] = cursor_direction + api_params['repository'] = repository + api_params['owner'] = owner + api_params['rootDirectory'] = root_directory + api_params['version'] = version + api_params['activate'] = activate - return self.client.call('get', path, { + return self.client.call('post', api_path, { 'content-type': 'application/json', - }, params) + }, api_params) + + def create_vcs_deployment(self, function_id: str, type: VCSDeploymentType, reference: str, activate: bool = None) -> Dict[str, Any]: + """ + Create a deployment when a function is connected to VCS. + + This endpoint lets you create deployment from a branch, commit, or a tag. + + + Parameters + ---------- + function_id : str + Function ID. + type : VCSDeploymentType + Type of reference passed. Allowed values are: branch, commit + reference : str + VCS reference to create deployment from. Depending on type this can be: branch name, commit hash + activate : bool + Automatically activate the deployment when it is finished building. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/functions/{functionId}/deployments/vcs' + api_params = {} + if function_id is None: + raise AppwriteException('Missing required parameter: "function_id"') - def create_execution(self, function_id, data = None): - """Create Execution""" + if type is None: + raise AppwriteException('Missing required parameter: "type"') - if function_id is None: - raise AppwriteException('Missing required parameter: "function_id"') + if reference is None: + raise AppwriteException('Missing required parameter: "reference"') - params = {} - path = '/functions/{functionId}/executions' - path = path.replace('{functionId}', function_id) + api_path = api_path.replace('{functionId}', function_id) - if data is not None: - params['data'] = data + api_params['type'] = type + api_params['reference'] = reference + api_params['activate'] = activate - return self.client.call('post', path, { + return self.client.call('post', api_path, { 'content-type': 'application/json', - }, params) - - def get_execution(self, function_id, execution_id): - """Get Execution""" + }, api_params) + + def get_deployment(self, function_id: str, deployment_id: str) -> Dict[str, Any]: + """ + Get a function deployment by its unique ID. + + + Parameters + ---------- + function_id : str + Function ID. + deployment_id : str + Deployment ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/functions/{functionId}/deployments/{deploymentId}' + api_params = {} + if function_id is None: + raise AppwriteException('Missing required parameter: "function_id"') - if function_id is None: + if deployment_id is None: + raise AppwriteException('Missing required parameter: "deployment_id"') + + api_path = api_path.replace('{functionId}', function_id) + api_path = api_path.replace('{deploymentId}', deployment_id) + + + return self.client.call('get', api_path, { + }, api_params) + + def delete_deployment(self, function_id: str, deployment_id: str) -> Dict[str, Any]: + """ + Delete a code deployment by its unique ID. + + + Parameters + ---------- + function_id : str + Function ID. + deployment_id : str + Deployment ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/functions/{functionId}/deployments/{deploymentId}' + api_params = {} + if function_id is None: raise AppwriteException('Missing required parameter: "function_id"') - if execution_id is None: - raise AppwriteException('Missing required parameter: "execution_id"') + if deployment_id is None: + raise AppwriteException('Missing required parameter: "deployment_id"') - params = {} - path = '/functions/{functionId}/executions/{executionId}' - path = path.replace('{functionId}', function_id) - path = path.replace('{executionId}', execution_id) + api_path = api_path.replace('{functionId}', function_id) + api_path = api_path.replace('{deploymentId}', deployment_id) - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - def update_tag(self, function_id, tag): - """Update Function Tag""" + return self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + def get_deployment_download(self, function_id: str, deployment_id: str, type: DeploymentDownloadType = None) -> bytes: + """ + Get a function deployment content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory. + + + Parameters + ---------- + function_id : str + Function ID. + deployment_id : str + Deployment ID. + type : DeploymentDownloadType + Deployment file to download. Can be: "source", "output". + + Returns + ------- + bytes + Response as bytes + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/functions/{functionId}/deployments/{deploymentId}/download' + api_params = {} + if function_id is None: + raise AppwriteException('Missing required parameter: "function_id"') - if function_id is None: + if deployment_id is None: + raise AppwriteException('Missing required parameter: "deployment_id"') + + api_path = api_path.replace('{functionId}', function_id) + api_path = api_path.replace('{deploymentId}', deployment_id) + + api_params['type'] = type + + return self.client.call('get', api_path, { + }, api_params) + + def update_deployment_status(self, function_id: str, deployment_id: str) -> Dict[str, Any]: + """ + Cancel an ongoing function deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn't started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status 'ready') or failed. The response includes the final build status and details. + + + Parameters + ---------- + function_id : str + Function ID. + deployment_id : str + Deployment ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/functions/{functionId}/deployments/{deploymentId}/status' + api_params = {} + if function_id is None: raise AppwriteException('Missing required parameter: "function_id"') - if tag is None: - raise AppwriteException('Missing required parameter: "tag"') + if deployment_id is None: + raise AppwriteException('Missing required parameter: "deployment_id"') - params = {} - path = '/functions/{functionId}/tag' - path = path.replace('{functionId}', function_id) + api_path = api_path.replace('{functionId}', function_id) + api_path = api_path.replace('{deploymentId}', deployment_id) - if tag is not None: - params['tag'] = tag - return self.client.call('patch', path, { + return self.client.call('patch', api_path, { 'content-type': 'application/json', - }, params) - - def list_tags(self, function_id, search = None, limit = None, offset = None, cursor = None, cursor_direction = None, order_type = None): - """List Tags""" - - if function_id is None: + }, api_params) + + def list_executions(self, function_id: str, queries: List[str] = None) -> Dict[str, Any]: + """ + Get a list of all the current user function execution logs. You can use the query params to filter your results. + + + Parameters + ---------- + function_id : str + Function ID. + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, responseStatusCode, duration, requestMethod, requestPath, deploymentId + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/functions/{functionId}/executions' + api_params = {} + if function_id is None: raise AppwriteException('Missing required parameter: "function_id"') - params = {} - path = '/functions/{functionId}/tags' - path = path.replace('{functionId}', function_id) + api_path = api_path.replace('{functionId}', function_id) + + api_params['queries'] = queries + + return self.client.call('get', api_path, { + }, api_params) + + def create_execution(self, function_id: str, body: str = None, xasync: bool = None, path: str = None, method: ExecutionMethod = None, headers: dict = None, scheduled_at: str = None) -> Dict[str, Any]: + """ + Trigger a function execution. The returned object will return you the current execution status. You can ping the `Get Execution` endpoint to get updates on the current execution status. Once this endpoint is called, your function execution process will start asynchronously. + + + Parameters + ---------- + function_id : str + Function ID. + body : str + HTTP body of execution. Default value is empty string. + xasync : bool + Execute code in the background. Default value is false. + path : str + HTTP path of execution. Path can include query params. Default value is / + method : ExecutionMethod + HTTP method of execution. Default value is GET. + headers : dict + HTTP headers of execution. Defaults to empty. + scheduled_at : str + Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/functions/{functionId}/executions' + api_params = {} + if function_id is None: + raise AppwriteException('Missing required parameter: "function_id"') - if search is not None: - params['search'] = search + api_path = api_path.replace('{functionId}', function_id) - if limit is not None: - params['limit'] = limit + api_params['body'] = body + api_params['async'] = xasync + api_params['path'] = path + api_params['method'] = method + api_params['headers'] = headers + api_params['scheduledAt'] = scheduled_at - if offset is not None: - params['offset'] = offset + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def get_execution(self, function_id: str, execution_id: str) -> Dict[str, Any]: + """ + Get a function execution log by its unique ID. + + + Parameters + ---------- + function_id : str + Function ID. + execution_id : str + Execution ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/functions/{functionId}/executions/{executionId}' + api_params = {} + if function_id is None: + raise AppwriteException('Missing required parameter: "function_id"') - if cursor is not None: - params['cursor'] = cursor + if execution_id is None: + raise AppwriteException('Missing required parameter: "execution_id"') - if cursor_direction is not None: - params['cursorDirection'] = cursor_direction + api_path = api_path.replace('{functionId}', function_id) + api_path = api_path.replace('{executionId}', execution_id) + + + return self.client.call('get', api_path, { + }, api_params) + + def delete_execution(self, function_id: str, execution_id: str) -> Dict[str, Any]: + """ + Delete a function execution by its unique ID. + + + Parameters + ---------- + function_id : str + Function ID. + execution_id : str + Execution ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/functions/{functionId}/executions/{executionId}' + api_params = {} + if function_id is None: + raise AppwriteException('Missing required parameter: "function_id"') - if order_type is not None: - params['orderType'] = order_type + if execution_id is None: + raise AppwriteException('Missing required parameter: "execution_id"') - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) + api_path = api_path.replace('{functionId}', function_id) + api_path = api_path.replace('{executionId}', execution_id) - def create_tag(self, function_id, command, code): - """Create Tag""" - if function_id is None: + return self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + def list_variables(self, function_id: str) -> Dict[str, Any]: + """ + Get a list of all variables of a specific function. + + + Parameters + ---------- + function_id : str + Function unique ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/functions/{functionId}/variables' + api_params = {} + if function_id is None: raise AppwriteException('Missing required parameter: "function_id"') - if command is None: - raise AppwriteException('Missing required parameter: "command"') - - if code is None: - raise AppwriteException('Missing required parameter: "code"') + api_path = api_path.replace('{functionId}', function_id) + + + return self.client.call('get', api_path, { + }, api_params) + + def create_variable(self, function_id: str, key: str, value: str, secret: bool = None) -> Dict[str, Any]: + """ + Create a new function environment variable. These variables can be accessed in the function at runtime as environment variables. + + + Parameters + ---------- + function_id : str + Function unique ID. + key : str + Variable key. Max length: 255 chars. + value : str + Variable value. Max length: 8192 chars. + secret : bool + Secret variables can be updated or deleted, but only functions can read them during build and runtime. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/functions/{functionId}/variables' + api_params = {} + if function_id is None: + raise AppwriteException('Missing required parameter: "function_id"') - params = {} - path = '/functions/{functionId}/tags' - path = path.replace('{functionId}', function_id) + if key is None: + raise AppwriteException('Missing required parameter: "key"') - if command is not None: - params['command'] = command + if value is None: + raise AppwriteException('Missing required parameter: "value"') - if code is not None: - params['code'] = code + api_path = api_path.replace('{functionId}', function_id) - return self.client.call('post', path, { - 'content-type': 'multipart/form-data', - }, params) + api_params['key'] = key + api_params['value'] = value + api_params['secret'] = secret - def get_tag(self, function_id, tag_id): - """Get Tag""" + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def get_variable(self, function_id: str, variable_id: str) -> Dict[str, Any]: + """ + Get a variable by its unique ID. + + + Parameters + ---------- + function_id : str + Function unique ID. + variable_id : str + Variable unique ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/functions/{functionId}/variables/{variableId}' + api_params = {} + if function_id is None: + raise AppwriteException('Missing required parameter: "function_id"') - if function_id is None: + if variable_id is None: + raise AppwriteException('Missing required parameter: "variable_id"') + + api_path = api_path.replace('{functionId}', function_id) + api_path = api_path.replace('{variableId}', variable_id) + + + return self.client.call('get', api_path, { + }, api_params) + + def update_variable(self, function_id: str, variable_id: str, key: str, value: str = None, secret: bool = None) -> Dict[str, Any]: + """ + Update variable by its unique ID. + + + Parameters + ---------- + function_id : str + Function unique ID. + variable_id : str + Variable unique ID. + key : str + Variable key. Max length: 255 chars. + value : str + Variable value. Max length: 8192 chars. + secret : bool + Secret variables can be updated or deleted, but only functions can read them during build and runtime. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/functions/{functionId}/variables/{variableId}' + api_params = {} + if function_id is None: raise AppwriteException('Missing required parameter: "function_id"') - if tag_id is None: - raise AppwriteException('Missing required parameter: "tag_id"') + if variable_id is None: + raise AppwriteException('Missing required parameter: "variable_id"') - params = {} - path = '/functions/{functionId}/tags/{tagId}' - path = path.replace('{functionId}', function_id) - path = path.replace('{tagId}', tag_id) + if key is None: + raise AppwriteException('Missing required parameter: "key"') - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) + api_path = api_path.replace('{functionId}', function_id) + api_path = api_path.replace('{variableId}', variable_id) - def delete_tag(self, function_id, tag_id): - """Delete Tag""" + api_params['key'] = key + api_params['value'] = value + api_params['secret'] = secret - if function_id is None: + return self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + def delete_variable(self, function_id: str, variable_id: str) -> Dict[str, Any]: + """ + Delete a variable by its unique ID. + + + Parameters + ---------- + function_id : str + Function unique ID. + variable_id : str + Variable unique ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/functions/{functionId}/variables/{variableId}' + api_params = {} + if function_id is None: raise AppwriteException('Missing required parameter: "function_id"') - if tag_id is None: - raise AppwriteException('Missing required parameter: "tag_id"') + if variable_id is None: + raise AppwriteException('Missing required parameter: "variable_id"') + + api_path = api_path.replace('{functionId}', function_id) + api_path = api_path.replace('{variableId}', variable_id) - params = {} - path = '/functions/{functionId}/tags/{tagId}' - path = path.replace('{functionId}', function_id) - path = path.replace('{tagId}', tag_id) - return self.client.call('delete', path, { + return self.client.call('delete', api_path, { 'content-type': 'application/json', - }, params) + }, api_params) diff --git a/appwrite/services/graphql.py b/appwrite/services/graphql.py new file mode 100644 index 0000000..69ad4e0 --- /dev/null +++ b/appwrite/services/graphql.py @@ -0,0 +1,76 @@ +from ..service import Service +from typing import List, Dict, Any +from ..exception import AppwriteException + +class Graphql(Service): + + def __init__(self, client) -> None: + super(Graphql, self).__init__(client) + + def query(self, query: dict) -> Dict[str, Any]: + """ + Execute a GraphQL mutation. + + + Parameters + ---------- + query : dict + The query or queries to execute. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/graphql' + api_params = {} + if query is None: + raise AppwriteException('Missing required parameter: "query"') + + + api_params['query'] = query + + return self.client.call('post', api_path, { + 'x-sdk-graphql': 'true', + 'content-type': 'application/json', + }, api_params) + + def mutation(self, query: dict) -> Dict[str, Any]: + """ + Execute a GraphQL mutation. + + + Parameters + ---------- + query : dict + The query or queries to execute. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/graphql/mutation' + api_params = {} + if query is None: + raise AppwriteException('Missing required parameter: "query"') + + + api_params['query'] = query + + return self.client.call('post', api_path, { + 'x-sdk-graphql': 'true', + 'content-type': 'application/json', + }, api_params) diff --git a/appwrite/services/health.py b/appwrite/services/health.py index c8ae4bf..665fd1e 100644 --- a/appwrite/services/health.py +++ b/appwrite/services/health.py @@ -1,117 +1,593 @@ from ..service import Service +from typing import List, Dict, Any from ..exception import AppwriteException +from ..enums.name import Name; class Health(Service): - def __init__(self, client): + def __init__(self, client) -> None: super(Health, self).__init__(client) - def get(self): - """Get HTTP""" - - params = {} - path = '/health' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_antivirus(self): - """Get Antivirus""" - - params = {} - path = '/health/anti-virus' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_cache(self): - """Get Cache""" - - params = {} - path = '/health/cache' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_db(self): - """Get DB""" - - params = {} - path = '/health/db' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_queue_certificates(self): - """Get Certificates Queue""" - - params = {} - path = '/health/queue/certificates' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_queue_functions(self): - """Get Functions Queue""" - - params = {} - path = '/health/queue/functions' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_queue_logs(self): - """Get Logs Queue""" - - params = {} - path = '/health/queue/logs' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_queue_usage(self): - """Get Usage Queue""" - - params = {} - path = '/health/queue/usage' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_queue_webhooks(self): - """Get Webhooks Queue""" - - params = {} - path = '/health/queue/webhooks' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_storage_local(self): - """Get Local Storage""" - - params = {} - path = '/health/storage/local' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_time(self): - """Get Time""" - - params = {} - path = '/health/time' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) + def get(self) -> Dict[str, Any]: + """ + Check the Appwrite HTTP server is up and responsive. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/health' + api_params = {} + + return self.client.call('get', api_path, { + }, api_params) + + def get_antivirus(self) -> Dict[str, Any]: + """ + Check the Appwrite Antivirus server is up and connection is successful. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/health/anti-virus' + api_params = {} + + return self.client.call('get', api_path, { + }, api_params) + + def get_cache(self) -> Dict[str, Any]: + """ + Check the Appwrite in-memory cache servers are up and connection is successful. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/health/cache' + api_params = {} + + return self.client.call('get', api_path, { + }, api_params) + + def get_certificate(self, domain: str = None) -> Dict[str, Any]: + """ + Get the SSL certificate for a domain + + + Parameters + ---------- + domain : str + string + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/health/certificate' + api_params = {} + + api_params['domain'] = domain + + return self.client.call('get', api_path, { + }, api_params) + + def get_db(self) -> Dict[str, Any]: + """ + Check the Appwrite database servers are up and connection is successful. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/health/db' + api_params = {} + + return self.client.call('get', api_path, { + }, api_params) + + def get_pub_sub(self) -> Dict[str, Any]: + """ + Check the Appwrite pub-sub servers are up and connection is successful. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/health/pubsub' + api_params = {} + + return self.client.call('get', api_path, { + }, api_params) + + def get_queue_builds(self, threshold: float = None) -> Dict[str, Any]: + """ + Get the number of builds that are waiting to be processed in the Appwrite internal queue server. + + + Parameters + ---------- + threshold : float + Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/health/queue/builds' + api_params = {} + + api_params['threshold'] = threshold + + return self.client.call('get', api_path, { + }, api_params) + + def get_queue_certificates(self, threshold: float = None) -> Dict[str, Any]: + """ + Get the number of certificates that are waiting to be issued against [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue server. + + + Parameters + ---------- + threshold : float + Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/health/queue/certificates' + api_params = {} + + api_params['threshold'] = threshold + + return self.client.call('get', api_path, { + }, api_params) + + def get_queue_databases(self, name: str = None, threshold: float = None) -> Dict[str, Any]: + """ + Get the number of database changes that are waiting to be processed in the Appwrite internal queue server. + + + Parameters + ---------- + name : str + Queue name for which to check the queue size + threshold : float + Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/health/queue/databases' + api_params = {} + + api_params['name'] = name + api_params['threshold'] = threshold + + return self.client.call('get', api_path, { + }, api_params) + + def get_queue_deletes(self, threshold: float = None) -> Dict[str, Any]: + """ + Get the number of background destructive changes that are waiting to be processed in the Appwrite internal queue server. + + + Parameters + ---------- + threshold : float + Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/health/queue/deletes' + api_params = {} + + api_params['threshold'] = threshold + + return self.client.call('get', api_path, { + }, api_params) + + def get_failed_jobs(self, name: Name, threshold: float = None) -> Dict[str, Any]: + """ + Returns the amount of failed jobs in a given queue. + + + + Parameters + ---------- + name : Name + The name of the queue + threshold : float + Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/health/queue/failed/{name}' + api_params = {} + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + api_path = api_path.replace('{name}', name) + + api_params['threshold'] = threshold + + return self.client.call('get', api_path, { + }, api_params) + + def get_queue_functions(self, threshold: float = None) -> Dict[str, Any]: + """ + Get the number of function executions that are waiting to be processed in the Appwrite internal queue server. + + + Parameters + ---------- + threshold : float + Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/health/queue/functions' + api_params = {} + + api_params['threshold'] = threshold + + return self.client.call('get', api_path, { + }, api_params) + + def get_queue_logs(self, threshold: float = None) -> Dict[str, Any]: + """ + Get the number of logs that are waiting to be processed in the Appwrite internal queue server. + + + Parameters + ---------- + threshold : float + Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/health/queue/logs' + api_params = {} + + api_params['threshold'] = threshold + + return self.client.call('get', api_path, { + }, api_params) + + def get_queue_mails(self, threshold: float = None) -> Dict[str, Any]: + """ + Get the number of mails that are waiting to be processed in the Appwrite internal queue server. + + + Parameters + ---------- + threshold : float + Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/health/queue/mails' + api_params = {} + + api_params['threshold'] = threshold + + return self.client.call('get', api_path, { + }, api_params) + + def get_queue_messaging(self, threshold: float = None) -> Dict[str, Any]: + """ + Get the number of messages that are waiting to be processed in the Appwrite internal queue server. + + + Parameters + ---------- + threshold : float + Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/health/queue/messaging' + api_params = {} + + api_params['threshold'] = threshold + + return self.client.call('get', api_path, { + }, api_params) + + def get_queue_migrations(self, threshold: float = None) -> Dict[str, Any]: + """ + Get the number of migrations that are waiting to be processed in the Appwrite internal queue server. + + + Parameters + ---------- + threshold : float + Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/health/queue/migrations' + api_params = {} + + api_params['threshold'] = threshold + + return self.client.call('get', api_path, { + }, api_params) + + def get_queue_stats_resources(self, threshold: float = None) -> Dict[str, Any]: + """ + Get the number of metrics that are waiting to be processed in the Appwrite stats resources queue. + + + Parameters + ---------- + threshold : float + Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/health/queue/stats-resources' + api_params = {} + + api_params['threshold'] = threshold + + return self.client.call('get', api_path, { + }, api_params) + + def get_queue_usage(self, threshold: float = None) -> Dict[str, Any]: + """ + Get the number of metrics that are waiting to be processed in the Appwrite internal queue server. + + + Parameters + ---------- + threshold : float + Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/health/queue/stats-usage' + api_params = {} + + api_params['threshold'] = threshold + + return self.client.call('get', api_path, { + }, api_params) + + def get_queue_webhooks(self, threshold: float = None) -> Dict[str, Any]: + """ + Get the number of webhooks that are waiting to be processed in the Appwrite internal queue server. + + + Parameters + ---------- + threshold : float + Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/health/queue/webhooks' + api_params = {} + + api_params['threshold'] = threshold + + return self.client.call('get', api_path, { + }, api_params) + + def get_storage(self) -> Dict[str, Any]: + """ + Check the Appwrite storage device is up and connection is successful. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/health/storage' + api_params = {} + + return self.client.call('get', api_path, { + }, api_params) + + def get_storage_local(self) -> Dict[str, Any]: + """ + Check the Appwrite local storage device is up and connection is successful. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/health/storage/local' + api_params = {} + + return self.client.call('get', api_path, { + }, api_params) + + def get_time(self) -> Dict[str, Any]: + """ + Check the Appwrite server time is synced with Google remote NTP server. We use this technology to smoothly handle leap seconds with no disruptive events. The [Network Time Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is used by hundreds of millions of computers and devices to synchronize their clocks over the Internet. If your computer sets its own clock, it likely uses NTP. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/health/time' + api_params = {} + + return self.client.call('get', api_path, { + }, api_params) diff --git a/appwrite/services/locale.py b/appwrite/services/locale.py index c7a929a..c34ddee 100644 --- a/appwrite/services/locale.py +++ b/appwrite/services/locale.py @@ -1,77 +1,178 @@ from ..service import Service +from typing import List, Dict, Any from ..exception import AppwriteException class Locale(Service): - def __init__(self, client): + def __init__(self, client) -> None: super(Locale, self).__init__(client) - def get(self): - """Get User Locale""" - - params = {} - path = '/locale' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_continents(self): - """List Continents""" - - params = {} - path = '/locale/continents' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_countries(self): - """List Countries""" - - params = {} - path = '/locale/countries' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_countries_eu(self): - """List EU Countries""" - - params = {} - path = '/locale/countries/eu' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_countries_phones(self): - """List Countries Phone Codes""" - - params = {} - path = '/locale/countries/phones' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_currencies(self): - """List Currencies""" - - params = {} - path = '/locale/currencies' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_languages(self): - """List Languages""" - - params = {} - path = '/locale/languages' - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) + def get(self) -> Dict[str, Any]: + """ + Get the current user location based on IP. Returns an object with user country code, country name, continent name, continent code, ip address and suggested currency. You can use the locale header to get the data in a supported language. + + ([IP Geolocation by DB-IP](https://db-ip.com)) + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/locale' + api_params = {} + + return self.client.call('get', api_path, { + }, api_params) + + def list_codes(self) -> Dict[str, Any]: + """ + List of all locale codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes). + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/locale/codes' + api_params = {} + + return self.client.call('get', api_path, { + }, api_params) + + def list_continents(self) -> Dict[str, Any]: + """ + List of all continents. You can use the locale header to get the data in a supported language. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/locale/continents' + api_params = {} + + return self.client.call('get', api_path, { + }, api_params) + + def list_countries(self) -> Dict[str, Any]: + """ + List of all countries. You can use the locale header to get the data in a supported language. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/locale/countries' + api_params = {} + + return self.client.call('get', api_path, { + }, api_params) + + def list_countries_eu(self) -> Dict[str, Any]: + """ + List of all countries that are currently members of the EU. You can use the locale header to get the data in a supported language. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/locale/countries/eu' + api_params = {} + + return self.client.call('get', api_path, { + }, api_params) + + def list_countries_phones(self) -> Dict[str, Any]: + """ + List of all countries phone codes. You can use the locale header to get the data in a supported language. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/locale/countries/phones' + api_params = {} + + return self.client.call('get', api_path, { + }, api_params) + + def list_currencies(self) -> Dict[str, Any]: + """ + List of all currencies, including currency symbol, name, plural, and decimal digits for all major and minor currencies. You can use the locale header to get the data in a supported language. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/locale/currencies' + api_params = {} + + return self.client.call('get', api_path, { + }, api_params) + + def list_languages(self) -> Dict[str, Any]: + """ + List of all languages classified by ISO 639-1 including 2-letter code, name in English, and name in the respective language. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/locale/languages' + api_params = {} + + return self.client.call('get', api_path, { + }, api_params) diff --git a/appwrite/services/messaging.py b/appwrite/services/messaging.py new file mode 100644 index 0000000..153a1f7 --- /dev/null +++ b/appwrite/services/messaging.py @@ -0,0 +1,2219 @@ +from ..service import Service +from typing import List, Dict, Any +from ..exception import AppwriteException +from ..enums.message_priority import MessagePriority; +from ..enums.smtp_encryption import SmtpEncryption; + +class Messaging(Service): + + def __init__(self, client) -> None: + super(Messaging, self).__init__(client) + + def list_messages(self, queries: List[str] = None, search: str = None) -> Dict[str, Any]: + """ + Get a list of all messages from the current Appwrite project. + + + Parameters + ---------- + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: scheduledAt, deliveredAt, deliveredTotal, status, description, providerType + search : str + Search term to filter your list results. Max length: 256 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/messages' + api_params = {} + + api_params['queries'] = queries + api_params['search'] = search + + return self.client.call('get', api_path, { + }, api_params) + + def create_email(self, message_id: str, subject: str, content: str, topics: List[str] = None, users: List[str] = None, targets: List[str] = None, cc: List[str] = None, bcc: List[str] = None, attachments: List[str] = None, draft: bool = None, html: bool = None, scheduled_at: str = None) -> Dict[str, Any]: + """ + Create a new email message. + + + Parameters + ---------- + message_id : str + Message ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + subject : str + Email Subject. + content : str + Email Content. + topics : List[str] + List of Topic IDs. + users : List[str] + List of User IDs. + targets : List[str] + List of Targets IDs. + cc : List[str] + Array of target IDs to be added as CC. + bcc : List[str] + Array of target IDs to be added as BCC. + attachments : List[str] + Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as :. + draft : bool + Is message a draft + html : bool + Is content of type HTML + scheduled_at : str + Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/messages/email' + api_params = {} + if message_id is None: + raise AppwriteException('Missing required parameter: "message_id"') + + if subject is None: + raise AppwriteException('Missing required parameter: "subject"') + + if content is None: + raise AppwriteException('Missing required parameter: "content"') + + + api_params['messageId'] = message_id + api_params['subject'] = subject + api_params['content'] = content + api_params['topics'] = topics + api_params['users'] = users + api_params['targets'] = targets + api_params['cc'] = cc + api_params['bcc'] = bcc + api_params['attachments'] = attachments + api_params['draft'] = draft + api_params['html'] = html + api_params['scheduledAt'] = scheduled_at + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_email(self, message_id: str, topics: List[str] = None, users: List[str] = None, targets: List[str] = None, subject: str = None, content: str = None, draft: bool = None, html: bool = None, cc: List[str] = None, bcc: List[str] = None, scheduled_at: str = None, attachments: List[str] = None) -> Dict[str, Any]: + """ + Update an email message by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. + + + + Parameters + ---------- + message_id : str + Message ID. + topics : List[str] + List of Topic IDs. + users : List[str] + List of User IDs. + targets : List[str] + List of Targets IDs. + subject : str + Email Subject. + content : str + Email Content. + draft : bool + Is message a draft + html : bool + Is content of type HTML + cc : List[str] + Array of target IDs to be added as CC. + bcc : List[str] + Array of target IDs to be added as BCC. + scheduled_at : str + Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + attachments : List[str] + Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as :. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/messages/email/{messageId}' + api_params = {} + if message_id is None: + raise AppwriteException('Missing required parameter: "message_id"') + + api_path = api_path.replace('{messageId}', message_id) + + api_params['topics'] = topics + api_params['users'] = users + api_params['targets'] = targets + api_params['subject'] = subject + api_params['content'] = content + api_params['draft'] = draft + api_params['html'] = html + api_params['cc'] = cc + api_params['bcc'] = bcc + api_params['scheduledAt'] = scheduled_at + api_params['attachments'] = attachments + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_push(self, message_id: str, title: str = None, body: str = None, topics: List[str] = None, users: List[str] = None, targets: List[str] = None, data: dict = None, action: str = None, image: str = None, icon: str = None, sound: str = None, color: str = None, tag: str = None, badge: float = None, draft: bool = None, scheduled_at: str = None, content_available: bool = None, critical: bool = None, priority: MessagePriority = None) -> Dict[str, Any]: + """ + Create a new push notification. + + + Parameters + ---------- + message_id : str + Message ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + title : str + Title for push notification. + body : str + Body for push notification. + topics : List[str] + List of Topic IDs. + users : List[str] + List of User IDs. + targets : List[str] + List of Targets IDs. + data : dict + Additional key-value pair data for push notification. + action : str + Action for push notification. + image : str + Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as :. + icon : str + Icon for push notification. Available only for Android and Web Platform. + sound : str + Sound for push notification. Available only for Android and iOS Platform. + color : str + Color for push notification. Available only for Android Platform. + tag : str + Tag for push notification. Available only for Android Platform. + badge : float + Badge for push notification. Available only for iOS Platform. + draft : bool + Is message a draft + scheduled_at : str + Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + content_available : bool + If set to true, the notification will be delivered in the background. Available only for iOS Platform. + critical : bool + If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. + priority : MessagePriority + Set the notification priority. "normal" will consider device state and may not deliver notifications immediately. "high" will always attempt to immediately deliver the notification. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/messages/push' + api_params = {} + if message_id is None: + raise AppwriteException('Missing required parameter: "message_id"') + + + api_params['messageId'] = message_id + api_params['title'] = title + api_params['body'] = body + api_params['topics'] = topics + api_params['users'] = users + api_params['targets'] = targets + api_params['data'] = data + api_params['action'] = action + api_params['image'] = image + api_params['icon'] = icon + api_params['sound'] = sound + api_params['color'] = color + api_params['tag'] = tag + api_params['badge'] = badge + api_params['draft'] = draft + api_params['scheduledAt'] = scheduled_at + api_params['contentAvailable'] = content_available + api_params['critical'] = critical + api_params['priority'] = priority + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_push(self, message_id: str, topics: List[str] = None, users: List[str] = None, targets: List[str] = None, title: str = None, body: str = None, data: dict = None, action: str = None, image: str = None, icon: str = None, sound: str = None, color: str = None, tag: str = None, badge: float = None, draft: bool = None, scheduled_at: str = None, content_available: bool = None, critical: bool = None, priority: MessagePriority = None) -> Dict[str, Any]: + """ + Update a push notification by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. + + + + Parameters + ---------- + message_id : str + Message ID. + topics : List[str] + List of Topic IDs. + users : List[str] + List of User IDs. + targets : List[str] + List of Targets IDs. + title : str + Title for push notification. + body : str + Body for push notification. + data : dict + Additional Data for push notification. + action : str + Action for push notification. + image : str + Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as :. + icon : str + Icon for push notification. Available only for Android and Web platforms. + sound : str + Sound for push notification. Available only for Android and iOS platforms. + color : str + Color for push notification. Available only for Android platforms. + tag : str + Tag for push notification. Available only for Android platforms. + badge : float + Badge for push notification. Available only for iOS platforms. + draft : bool + Is message a draft + scheduled_at : str + Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + content_available : bool + If set to true, the notification will be delivered in the background. Available only for iOS Platform. + critical : bool + If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. + priority : MessagePriority + Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/messages/push/{messageId}' + api_params = {} + if message_id is None: + raise AppwriteException('Missing required parameter: "message_id"') + + api_path = api_path.replace('{messageId}', message_id) + + api_params['topics'] = topics + api_params['users'] = users + api_params['targets'] = targets + api_params['title'] = title + api_params['body'] = body + api_params['data'] = data + api_params['action'] = action + api_params['image'] = image + api_params['icon'] = icon + api_params['sound'] = sound + api_params['color'] = color + api_params['tag'] = tag + api_params['badge'] = badge + api_params['draft'] = draft + api_params['scheduledAt'] = scheduled_at + api_params['contentAvailable'] = content_available + api_params['critical'] = critical + api_params['priority'] = priority + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_sms(self, message_id: str, content: str, topics: List[str] = None, users: List[str] = None, targets: List[str] = None, draft: bool = None, scheduled_at: str = None) -> Dict[str, Any]: + """ + Create a new SMS message. + + + Parameters + ---------- + message_id : str + Message ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + content : str + SMS Content. + topics : List[str] + List of Topic IDs. + users : List[str] + List of User IDs. + targets : List[str] + List of Targets IDs. + draft : bool + Is message a draft + scheduled_at : str + Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/messages/sms' + api_params = {} + if message_id is None: + raise AppwriteException('Missing required parameter: "message_id"') + + if content is None: + raise AppwriteException('Missing required parameter: "content"') + + + api_params['messageId'] = message_id + api_params['content'] = content + api_params['topics'] = topics + api_params['users'] = users + api_params['targets'] = targets + api_params['draft'] = draft + api_params['scheduledAt'] = scheduled_at + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_sms(self, message_id: str, topics: List[str] = None, users: List[str] = None, targets: List[str] = None, content: str = None, draft: bool = None, scheduled_at: str = None) -> Dict[str, Any]: + """ + Update an SMS message by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. + + + + Parameters + ---------- + message_id : str + Message ID. + topics : List[str] + List of Topic IDs. + users : List[str] + List of User IDs. + targets : List[str] + List of Targets IDs. + content : str + Email Content. + draft : bool + Is message a draft + scheduled_at : str + Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/messages/sms/{messageId}' + api_params = {} + if message_id is None: + raise AppwriteException('Missing required parameter: "message_id"') + + api_path = api_path.replace('{messageId}', message_id) + + api_params['topics'] = topics + api_params['users'] = users + api_params['targets'] = targets + api_params['content'] = content + api_params['draft'] = draft + api_params['scheduledAt'] = scheduled_at + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def get_message(self, message_id: str) -> Dict[str, Any]: + """ + Get a message by its unique ID. + + + + Parameters + ---------- + message_id : str + Message ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/messages/{messageId}' + api_params = {} + if message_id is None: + raise AppwriteException('Missing required parameter: "message_id"') + + api_path = api_path.replace('{messageId}', message_id) + + + return self.client.call('get', api_path, { + }, api_params) + + def delete(self, message_id: str) -> Dict[str, Any]: + """ + Delete a message. If the message is not a draft or scheduled, but has been sent, this will not recall the message. + + + Parameters + ---------- + message_id : str + Message ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/messages/{messageId}' + api_params = {} + if message_id is None: + raise AppwriteException('Missing required parameter: "message_id"') + + api_path = api_path.replace('{messageId}', message_id) + + + return self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + def list_message_logs(self, message_id: str, queries: List[str] = None) -> Dict[str, Any]: + """ + Get the message activity logs listed by its unique ID. + + + Parameters + ---------- + message_id : str + Message ID. + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/messages/{messageId}/logs' + api_params = {} + if message_id is None: + raise AppwriteException('Missing required parameter: "message_id"') + + api_path = api_path.replace('{messageId}', message_id) + + api_params['queries'] = queries + + return self.client.call('get', api_path, { + }, api_params) + + def list_targets(self, message_id: str, queries: List[str] = None) -> Dict[str, Any]: + """ + Get a list of the targets associated with a message. + + + Parameters + ---------- + message_id : str + Message ID. + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, providerId, identifier, providerType + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/messages/{messageId}/targets' + api_params = {} + if message_id is None: + raise AppwriteException('Missing required parameter: "message_id"') + + api_path = api_path.replace('{messageId}', message_id) + + api_params['queries'] = queries + + return self.client.call('get', api_path, { + }, api_params) + + def list_providers(self, queries: List[str] = None, search: str = None) -> Dict[str, Any]: + """ + Get a list of all providers from the current Appwrite project. + + + Parameters + ---------- + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, provider, type, enabled + search : str + Search term to filter your list results. Max length: 256 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/providers' + api_params = {} + + api_params['queries'] = queries + api_params['search'] = search + + return self.client.call('get', api_path, { + }, api_params) + + def create_apns_provider(self, provider_id: str, name: str, auth_key: str = None, auth_key_id: str = None, team_id: str = None, bundle_id: str = None, sandbox: bool = None, enabled: bool = None) -> Dict[str, Any]: + """ + Create a new Apple Push Notification service provider. + + + Parameters + ---------- + provider_id : str + Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + name : str + Provider name. + auth_key : str + APNS authentication key. + auth_key_id : str + APNS authentication key ID. + team_id : str + APNS team ID. + bundle_id : str + APNS bundle ID. + sandbox : bool + Use APNS sandbox environment. + enabled : bool + Set as enabled. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/providers/apns' + api_params = {} + if provider_id is None: + raise AppwriteException('Missing required parameter: "provider_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + + api_params['providerId'] = provider_id + api_params['name'] = name + api_params['authKey'] = auth_key + api_params['authKeyId'] = auth_key_id + api_params['teamId'] = team_id + api_params['bundleId'] = bundle_id + api_params['sandbox'] = sandbox + api_params['enabled'] = enabled + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_apns_provider(self, provider_id: str, name: str = None, enabled: bool = None, auth_key: str = None, auth_key_id: str = None, team_id: str = None, bundle_id: str = None, sandbox: bool = None) -> Dict[str, Any]: + """ + Update a Apple Push Notification service provider by its unique ID. + + + Parameters + ---------- + provider_id : str + Provider ID. + name : str + Provider name. + enabled : bool + Set as enabled. + auth_key : str + APNS authentication key. + auth_key_id : str + APNS authentication key ID. + team_id : str + APNS team ID. + bundle_id : str + APNS bundle ID. + sandbox : bool + Use APNS sandbox environment. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/providers/apns/{providerId}' + api_params = {} + if provider_id is None: + raise AppwriteException('Missing required parameter: "provider_id"') + + api_path = api_path.replace('{providerId}', provider_id) + + api_params['name'] = name + api_params['enabled'] = enabled + api_params['authKey'] = auth_key + api_params['authKeyId'] = auth_key_id + api_params['teamId'] = team_id + api_params['bundleId'] = bundle_id + api_params['sandbox'] = sandbox + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_fcm_provider(self, provider_id: str, name: str, service_account_json: dict = None, enabled: bool = None) -> Dict[str, Any]: + """ + Create a new Firebase Cloud Messaging provider. + + + Parameters + ---------- + provider_id : str + Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + name : str + Provider name. + service_account_json : dict + FCM service account JSON. + enabled : bool + Set as enabled. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/providers/fcm' + api_params = {} + if provider_id is None: + raise AppwriteException('Missing required parameter: "provider_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + + api_params['providerId'] = provider_id + api_params['name'] = name + api_params['serviceAccountJSON'] = service_account_json + api_params['enabled'] = enabled + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_fcm_provider(self, provider_id: str, name: str = None, enabled: bool = None, service_account_json: dict = None) -> Dict[str, Any]: + """ + Update a Firebase Cloud Messaging provider by its unique ID. + + + Parameters + ---------- + provider_id : str + Provider ID. + name : str + Provider name. + enabled : bool + Set as enabled. + service_account_json : dict + FCM service account JSON. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/providers/fcm/{providerId}' + api_params = {} + if provider_id is None: + raise AppwriteException('Missing required parameter: "provider_id"') + + api_path = api_path.replace('{providerId}', provider_id) + + api_params['name'] = name + api_params['enabled'] = enabled + api_params['serviceAccountJSON'] = service_account_json + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_mailgun_provider(self, provider_id: str, name: str, api_key: str = None, domain: str = None, is_eu_region: bool = None, from_name: str = None, from_email: str = None, reply_to_name: str = None, reply_to_email: str = None, enabled: bool = None) -> Dict[str, Any]: + """ + Create a new Mailgun provider. + + + Parameters + ---------- + provider_id : str + Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + name : str + Provider name. + api_key : str + Mailgun API Key. + domain : str + Mailgun Domain. + is_eu_region : bool + Set as EU region. + from_name : str + Sender Name. + from_email : str + Sender email address. + reply_to_name : str + Name set in the reply to field for the mail. Default value is sender name. Reply to name must have reply to email as well. + reply_to_email : str + Email set in the reply to field for the mail. Default value is sender email. Reply to email must have reply to name as well. + enabled : bool + Set as enabled. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/providers/mailgun' + api_params = {} + if provider_id is None: + raise AppwriteException('Missing required parameter: "provider_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + + api_params['providerId'] = provider_id + api_params['name'] = name + api_params['apiKey'] = api_key + api_params['domain'] = domain + api_params['isEuRegion'] = is_eu_region + api_params['fromName'] = from_name + api_params['fromEmail'] = from_email + api_params['replyToName'] = reply_to_name + api_params['replyToEmail'] = reply_to_email + api_params['enabled'] = enabled + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_mailgun_provider(self, provider_id: str, name: str = None, api_key: str = None, domain: str = None, is_eu_region: bool = None, enabled: bool = None, from_name: str = None, from_email: str = None, reply_to_name: str = None, reply_to_email: str = None) -> Dict[str, Any]: + """ + Update a Mailgun provider by its unique ID. + + + Parameters + ---------- + provider_id : str + Provider ID. + name : str + Provider name. + api_key : str + Mailgun API Key. + domain : str + Mailgun Domain. + is_eu_region : bool + Set as EU region. + enabled : bool + Set as enabled. + from_name : str + Sender Name. + from_email : str + Sender email address. + reply_to_name : str + Name set in the reply to field for the mail. Default value is sender name. + reply_to_email : str + Email set in the reply to field for the mail. Default value is sender email. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/providers/mailgun/{providerId}' + api_params = {} + if provider_id is None: + raise AppwriteException('Missing required parameter: "provider_id"') + + api_path = api_path.replace('{providerId}', provider_id) + + api_params['name'] = name + api_params['apiKey'] = api_key + api_params['domain'] = domain + api_params['isEuRegion'] = is_eu_region + api_params['enabled'] = enabled + api_params['fromName'] = from_name + api_params['fromEmail'] = from_email + api_params['replyToName'] = reply_to_name + api_params['replyToEmail'] = reply_to_email + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_msg91_provider(self, provider_id: str, name: str, template_id: str = None, sender_id: str = None, auth_key: str = None, enabled: bool = None) -> Dict[str, Any]: + """ + Create a new MSG91 provider. + + + Parameters + ---------- + provider_id : str + Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + name : str + Provider name. + template_id : str + Msg91 template ID + sender_id : str + Msg91 sender ID. + auth_key : str + Msg91 auth key. + enabled : bool + Set as enabled. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/providers/msg91' + api_params = {} + if provider_id is None: + raise AppwriteException('Missing required parameter: "provider_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + + api_params['providerId'] = provider_id + api_params['name'] = name + api_params['templateId'] = template_id + api_params['senderId'] = sender_id + api_params['authKey'] = auth_key + api_params['enabled'] = enabled + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_msg91_provider(self, provider_id: str, name: str = None, enabled: bool = None, template_id: str = None, sender_id: str = None, auth_key: str = None) -> Dict[str, Any]: + """ + Update a MSG91 provider by its unique ID. + + + Parameters + ---------- + provider_id : str + Provider ID. + name : str + Provider name. + enabled : bool + Set as enabled. + template_id : str + Msg91 template ID. + sender_id : str + Msg91 sender ID. + auth_key : str + Msg91 auth key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/providers/msg91/{providerId}' + api_params = {} + if provider_id is None: + raise AppwriteException('Missing required parameter: "provider_id"') + + api_path = api_path.replace('{providerId}', provider_id) + + api_params['name'] = name + api_params['enabled'] = enabled + api_params['templateId'] = template_id + api_params['senderId'] = sender_id + api_params['authKey'] = auth_key + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_sendgrid_provider(self, provider_id: str, name: str, api_key: str = None, from_name: str = None, from_email: str = None, reply_to_name: str = None, reply_to_email: str = None, enabled: bool = None) -> Dict[str, Any]: + """ + Create a new Sendgrid provider. + + + Parameters + ---------- + provider_id : str + Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + name : str + Provider name. + api_key : str + Sendgrid API key. + from_name : str + Sender Name. + from_email : str + Sender email address. + reply_to_name : str + Name set in the reply to field for the mail. Default value is sender name. + reply_to_email : str + Email set in the reply to field for the mail. Default value is sender email. + enabled : bool + Set as enabled. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/providers/sendgrid' + api_params = {} + if provider_id is None: + raise AppwriteException('Missing required parameter: "provider_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + + api_params['providerId'] = provider_id + api_params['name'] = name + api_params['apiKey'] = api_key + api_params['fromName'] = from_name + api_params['fromEmail'] = from_email + api_params['replyToName'] = reply_to_name + api_params['replyToEmail'] = reply_to_email + api_params['enabled'] = enabled + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_sendgrid_provider(self, provider_id: str, name: str = None, enabled: bool = None, api_key: str = None, from_name: str = None, from_email: str = None, reply_to_name: str = None, reply_to_email: str = None) -> Dict[str, Any]: + """ + Update a Sendgrid provider by its unique ID. + + + Parameters + ---------- + provider_id : str + Provider ID. + name : str + Provider name. + enabled : bool + Set as enabled. + api_key : str + Sendgrid API key. + from_name : str + Sender Name. + from_email : str + Sender email address. + reply_to_name : str + Name set in the Reply To field for the mail. Default value is Sender Name. + reply_to_email : str + Email set in the Reply To field for the mail. Default value is Sender Email. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/providers/sendgrid/{providerId}' + api_params = {} + if provider_id is None: + raise AppwriteException('Missing required parameter: "provider_id"') + + api_path = api_path.replace('{providerId}', provider_id) + + api_params['name'] = name + api_params['enabled'] = enabled + api_params['apiKey'] = api_key + api_params['fromName'] = from_name + api_params['fromEmail'] = from_email + api_params['replyToName'] = reply_to_name + api_params['replyToEmail'] = reply_to_email + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_smtp_provider(self, provider_id: str, name: str, host: str, port: float = None, username: str = None, password: str = None, encryption: SmtpEncryption = None, auto_tls: bool = None, mailer: str = None, from_name: str = None, from_email: str = None, reply_to_name: str = None, reply_to_email: str = None, enabled: bool = None) -> Dict[str, Any]: + """ + Create a new SMTP provider. + + + Parameters + ---------- + provider_id : str + Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + name : str + Provider name. + host : str + SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. + port : float + The default SMTP server port. + username : str + Authentication username. + password : str + Authentication password. + encryption : SmtpEncryption + Encryption type. Can be omitted, 'ssl', or 'tls' + auto_tls : bool + Enable SMTP AutoTLS feature. + mailer : str + The value to use for the X-Mailer header. + from_name : str + Sender Name. + from_email : str + Sender email address. + reply_to_name : str + Name set in the reply to field for the mail. Default value is sender name. + reply_to_email : str + Email set in the reply to field for the mail. Default value is sender email. + enabled : bool + Set as enabled. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/providers/smtp' + api_params = {} + if provider_id is None: + raise AppwriteException('Missing required parameter: "provider_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + if host is None: + raise AppwriteException('Missing required parameter: "host"') + + + api_params['providerId'] = provider_id + api_params['name'] = name + api_params['host'] = host + api_params['port'] = port + api_params['username'] = username + api_params['password'] = password + api_params['encryption'] = encryption + api_params['autoTLS'] = auto_tls + api_params['mailer'] = mailer + api_params['fromName'] = from_name + api_params['fromEmail'] = from_email + api_params['replyToName'] = reply_to_name + api_params['replyToEmail'] = reply_to_email + api_params['enabled'] = enabled + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_smtp_provider(self, provider_id: str, name: str = None, host: str = None, port: float = None, username: str = None, password: str = None, encryption: SmtpEncryption = None, auto_tls: bool = None, mailer: str = None, from_name: str = None, from_email: str = None, reply_to_name: str = None, reply_to_email: str = None, enabled: bool = None) -> Dict[str, Any]: + """ + Update a SMTP provider by its unique ID. + + + Parameters + ---------- + provider_id : str + Provider ID. + name : str + Provider name. + host : str + SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. + port : float + SMTP port. + username : str + Authentication username. + password : str + Authentication password. + encryption : SmtpEncryption + Encryption type. Can be 'ssl' or 'tls' + auto_tls : bool + Enable SMTP AutoTLS feature. + mailer : str + The value to use for the X-Mailer header. + from_name : str + Sender Name. + from_email : str + Sender email address. + reply_to_name : str + Name set in the Reply To field for the mail. Default value is Sender Name. + reply_to_email : str + Email set in the Reply To field for the mail. Default value is Sender Email. + enabled : bool + Set as enabled. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/providers/smtp/{providerId}' + api_params = {} + if provider_id is None: + raise AppwriteException('Missing required parameter: "provider_id"') + + api_path = api_path.replace('{providerId}', provider_id) + + api_params['name'] = name + api_params['host'] = host + api_params['port'] = port + api_params['username'] = username + api_params['password'] = password + api_params['encryption'] = encryption + api_params['autoTLS'] = auto_tls + api_params['mailer'] = mailer + api_params['fromName'] = from_name + api_params['fromEmail'] = from_email + api_params['replyToName'] = reply_to_name + api_params['replyToEmail'] = reply_to_email + api_params['enabled'] = enabled + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_telesign_provider(self, provider_id: str, name: str, xfrom: str = None, customer_id: str = None, api_key: str = None, enabled: bool = None) -> Dict[str, Any]: + """ + Create a new Telesign provider. + + + Parameters + ---------- + provider_id : str + Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + name : str + Provider name. + xfrom : str + Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + customer_id : str + Telesign customer ID. + api_key : str + Telesign API key. + enabled : bool + Set as enabled. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/providers/telesign' + api_params = {} + if provider_id is None: + raise AppwriteException('Missing required parameter: "provider_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + + api_params['providerId'] = provider_id + api_params['name'] = name + api_params['from'] = xfrom + api_params['customerId'] = customer_id + api_params['apiKey'] = api_key + api_params['enabled'] = enabled + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_telesign_provider(self, provider_id: str, name: str = None, enabled: bool = None, customer_id: str = None, api_key: str = None, xfrom: str = None) -> Dict[str, Any]: + """ + Update a Telesign provider by its unique ID. + + + Parameters + ---------- + provider_id : str + Provider ID. + name : str + Provider name. + enabled : bool + Set as enabled. + customer_id : str + Telesign customer ID. + api_key : str + Telesign API key. + xfrom : str + Sender number. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/providers/telesign/{providerId}' + api_params = {} + if provider_id is None: + raise AppwriteException('Missing required parameter: "provider_id"') + + api_path = api_path.replace('{providerId}', provider_id) + + api_params['name'] = name + api_params['enabled'] = enabled + api_params['customerId'] = customer_id + api_params['apiKey'] = api_key + api_params['from'] = xfrom + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_textmagic_provider(self, provider_id: str, name: str, xfrom: str = None, username: str = None, api_key: str = None, enabled: bool = None) -> Dict[str, Any]: + """ + Create a new Textmagic provider. + + + Parameters + ---------- + provider_id : str + Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + name : str + Provider name. + xfrom : str + Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + username : str + Textmagic username. + api_key : str + Textmagic apiKey. + enabled : bool + Set as enabled. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/providers/textmagic' + api_params = {} + if provider_id is None: + raise AppwriteException('Missing required parameter: "provider_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + + api_params['providerId'] = provider_id + api_params['name'] = name + api_params['from'] = xfrom + api_params['username'] = username + api_params['apiKey'] = api_key + api_params['enabled'] = enabled + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_textmagic_provider(self, provider_id: str, name: str = None, enabled: bool = None, username: str = None, api_key: str = None, xfrom: str = None) -> Dict[str, Any]: + """ + Update a Textmagic provider by its unique ID. + + + Parameters + ---------- + provider_id : str + Provider ID. + name : str + Provider name. + enabled : bool + Set as enabled. + username : str + Textmagic username. + api_key : str + Textmagic apiKey. + xfrom : str + Sender number. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/providers/textmagic/{providerId}' + api_params = {} + if provider_id is None: + raise AppwriteException('Missing required parameter: "provider_id"') + + api_path = api_path.replace('{providerId}', provider_id) + + api_params['name'] = name + api_params['enabled'] = enabled + api_params['username'] = username + api_params['apiKey'] = api_key + api_params['from'] = xfrom + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_twilio_provider(self, provider_id: str, name: str, xfrom: str = None, account_sid: str = None, auth_token: str = None, enabled: bool = None) -> Dict[str, Any]: + """ + Create a new Twilio provider. + + + Parameters + ---------- + provider_id : str + Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + name : str + Provider name. + xfrom : str + Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + account_sid : str + Twilio account secret ID. + auth_token : str + Twilio authentication token. + enabled : bool + Set as enabled. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/providers/twilio' + api_params = {} + if provider_id is None: + raise AppwriteException('Missing required parameter: "provider_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + + api_params['providerId'] = provider_id + api_params['name'] = name + api_params['from'] = xfrom + api_params['accountSid'] = account_sid + api_params['authToken'] = auth_token + api_params['enabled'] = enabled + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_twilio_provider(self, provider_id: str, name: str = None, enabled: bool = None, account_sid: str = None, auth_token: str = None, xfrom: str = None) -> Dict[str, Any]: + """ + Update a Twilio provider by its unique ID. + + + Parameters + ---------- + provider_id : str + Provider ID. + name : str + Provider name. + enabled : bool + Set as enabled. + account_sid : str + Twilio account secret ID. + auth_token : str + Twilio authentication token. + xfrom : str + Sender number. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/providers/twilio/{providerId}' + api_params = {} + if provider_id is None: + raise AppwriteException('Missing required parameter: "provider_id"') + + api_path = api_path.replace('{providerId}', provider_id) + + api_params['name'] = name + api_params['enabled'] = enabled + api_params['accountSid'] = account_sid + api_params['authToken'] = auth_token + api_params['from'] = xfrom + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_vonage_provider(self, provider_id: str, name: str, xfrom: str = None, api_key: str = None, api_secret: str = None, enabled: bool = None) -> Dict[str, Any]: + """ + Create a new Vonage provider. + + + Parameters + ---------- + provider_id : str + Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + name : str + Provider name. + xfrom : str + Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + api_key : str + Vonage API key. + api_secret : str + Vonage API secret. + enabled : bool + Set as enabled. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/providers/vonage' + api_params = {} + if provider_id is None: + raise AppwriteException('Missing required parameter: "provider_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + + api_params['providerId'] = provider_id + api_params['name'] = name + api_params['from'] = xfrom + api_params['apiKey'] = api_key + api_params['apiSecret'] = api_secret + api_params['enabled'] = enabled + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_vonage_provider(self, provider_id: str, name: str = None, enabled: bool = None, api_key: str = None, api_secret: str = None, xfrom: str = None) -> Dict[str, Any]: + """ + Update a Vonage provider by its unique ID. + + + Parameters + ---------- + provider_id : str + Provider ID. + name : str + Provider name. + enabled : bool + Set as enabled. + api_key : str + Vonage API key. + api_secret : str + Vonage API secret. + xfrom : str + Sender number. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/providers/vonage/{providerId}' + api_params = {} + if provider_id is None: + raise AppwriteException('Missing required parameter: "provider_id"') + + api_path = api_path.replace('{providerId}', provider_id) + + api_params['name'] = name + api_params['enabled'] = enabled + api_params['apiKey'] = api_key + api_params['apiSecret'] = api_secret + api_params['from'] = xfrom + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def get_provider(self, provider_id: str) -> Dict[str, Any]: + """ + Get a provider by its unique ID. + + + + Parameters + ---------- + provider_id : str + Provider ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/providers/{providerId}' + api_params = {} + if provider_id is None: + raise AppwriteException('Missing required parameter: "provider_id"') + + api_path = api_path.replace('{providerId}', provider_id) + + + return self.client.call('get', api_path, { + }, api_params) + + def delete_provider(self, provider_id: str) -> Dict[str, Any]: + """ + Delete a provider by its unique ID. + + + Parameters + ---------- + provider_id : str + Provider ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/providers/{providerId}' + api_params = {} + if provider_id is None: + raise AppwriteException('Missing required parameter: "provider_id"') + + api_path = api_path.replace('{providerId}', provider_id) + + + return self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + def list_provider_logs(self, provider_id: str, queries: List[str] = None) -> Dict[str, Any]: + """ + Get the provider activity logs listed by its unique ID. + + + Parameters + ---------- + provider_id : str + Provider ID. + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/providers/{providerId}/logs' + api_params = {} + if provider_id is None: + raise AppwriteException('Missing required parameter: "provider_id"') + + api_path = api_path.replace('{providerId}', provider_id) + + api_params['queries'] = queries + + return self.client.call('get', api_path, { + }, api_params) + + def list_subscriber_logs(self, subscriber_id: str, queries: List[str] = None) -> Dict[str, Any]: + """ + Get the subscriber activity logs listed by its unique ID. + + + Parameters + ---------- + subscriber_id : str + Subscriber ID. + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/subscribers/{subscriberId}/logs' + api_params = {} + if subscriber_id is None: + raise AppwriteException('Missing required parameter: "subscriber_id"') + + api_path = api_path.replace('{subscriberId}', subscriber_id) + + api_params['queries'] = queries + + return self.client.call('get', api_path, { + }, api_params) + + def list_topics(self, queries: List[str] = None, search: str = None) -> Dict[str, Any]: + """ + Get a list of all topics from the current Appwrite project. + + + Parameters + ---------- + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, description, emailTotal, smsTotal, pushTotal + search : str + Search term to filter your list results. Max length: 256 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/topics' + api_params = {} + + api_params['queries'] = queries + api_params['search'] = search + + return self.client.call('get', api_path, { + }, api_params) + + def create_topic(self, topic_id: str, name: str, subscribe: List[str] = None) -> Dict[str, Any]: + """ + Create a new topic. + + + Parameters + ---------- + topic_id : str + Topic ID. Choose a custom Topic ID or a new Topic ID. + name : str + Topic Name. + subscribe : List[str] + An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/topics' + api_params = {} + if topic_id is None: + raise AppwriteException('Missing required parameter: "topic_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + + api_params['topicId'] = topic_id + api_params['name'] = name + api_params['subscribe'] = subscribe + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def get_topic(self, topic_id: str) -> Dict[str, Any]: + """ + Get a topic by its unique ID. + + + + Parameters + ---------- + topic_id : str + Topic ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/topics/{topicId}' + api_params = {} + if topic_id is None: + raise AppwriteException('Missing required parameter: "topic_id"') + + api_path = api_path.replace('{topicId}', topic_id) + + + return self.client.call('get', api_path, { + }, api_params) + + def update_topic(self, topic_id: str, name: str = None, subscribe: List[str] = None) -> Dict[str, Any]: + """ + Update a topic by its unique ID. + + + + Parameters + ---------- + topic_id : str + Topic ID. + name : str + Topic Name. + subscribe : List[str] + An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/topics/{topicId}' + api_params = {} + if topic_id is None: + raise AppwriteException('Missing required parameter: "topic_id"') + + api_path = api_path.replace('{topicId}', topic_id) + + api_params['name'] = name + api_params['subscribe'] = subscribe + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def delete_topic(self, topic_id: str) -> Dict[str, Any]: + """ + Delete a topic by its unique ID. + + + Parameters + ---------- + topic_id : str + Topic ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/topics/{topicId}' + api_params = {} + if topic_id is None: + raise AppwriteException('Missing required parameter: "topic_id"') + + api_path = api_path.replace('{topicId}', topic_id) + + + return self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + def list_topic_logs(self, topic_id: str, queries: List[str] = None) -> Dict[str, Any]: + """ + Get the topic activity logs listed by its unique ID. + + + Parameters + ---------- + topic_id : str + Topic ID. + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/topics/{topicId}/logs' + api_params = {} + if topic_id is None: + raise AppwriteException('Missing required parameter: "topic_id"') + + api_path = api_path.replace('{topicId}', topic_id) + + api_params['queries'] = queries + + return self.client.call('get', api_path, { + }, api_params) + + def list_subscribers(self, topic_id: str, queries: List[str] = None, search: str = None) -> Dict[str, Any]: + """ + Get a list of all subscribers from the current Appwrite project. + + + Parameters + ---------- + topic_id : str + Topic ID. The topic ID subscribed to. + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, provider, type, enabled + search : str + Search term to filter your list results. Max length: 256 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/topics/{topicId}/subscribers' + api_params = {} + if topic_id is None: + raise AppwriteException('Missing required parameter: "topic_id"') + + api_path = api_path.replace('{topicId}', topic_id) + + api_params['queries'] = queries + api_params['search'] = search + + return self.client.call('get', api_path, { + }, api_params) + + def create_subscriber(self, topic_id: str, subscriber_id: str, target_id: str) -> Dict[str, Any]: + """ + Create a new subscriber. + + + Parameters + ---------- + topic_id : str + Topic ID. The topic ID to subscribe to. + subscriber_id : str + Subscriber ID. Choose a custom Subscriber ID or a new Subscriber ID. + target_id : str + Target ID. The target ID to link to the specified Topic ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/topics/{topicId}/subscribers' + api_params = {} + if topic_id is None: + raise AppwriteException('Missing required parameter: "topic_id"') + + if subscriber_id is None: + raise AppwriteException('Missing required parameter: "subscriber_id"') + + if target_id is None: + raise AppwriteException('Missing required parameter: "target_id"') + + api_path = api_path.replace('{topicId}', topic_id) + + api_params['subscriberId'] = subscriber_id + api_params['targetId'] = target_id + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def get_subscriber(self, topic_id: str, subscriber_id: str) -> Dict[str, Any]: + """ + Get a subscriber by its unique ID. + + + + Parameters + ---------- + topic_id : str + Topic ID. The topic ID subscribed to. + subscriber_id : str + Subscriber ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/topics/{topicId}/subscribers/{subscriberId}' + api_params = {} + if topic_id is None: + raise AppwriteException('Missing required parameter: "topic_id"') + + if subscriber_id is None: + raise AppwriteException('Missing required parameter: "subscriber_id"') + + api_path = api_path.replace('{topicId}', topic_id) + api_path = api_path.replace('{subscriberId}', subscriber_id) + + + return self.client.call('get', api_path, { + }, api_params) + + def delete_subscriber(self, topic_id: str, subscriber_id: str) -> Dict[str, Any]: + """ + Delete a subscriber by its unique ID. + + + Parameters + ---------- + topic_id : str + Topic ID. The topic ID subscribed to. + subscriber_id : str + Subscriber ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/messaging/topics/{topicId}/subscribers/{subscriberId}' + api_params = {} + if topic_id is None: + raise AppwriteException('Missing required parameter: "topic_id"') + + if subscriber_id is None: + raise AppwriteException('Missing required parameter: "subscriber_id"') + + api_path = api_path.replace('{topicId}', topic_id) + api_path = api_path.replace('{subscriberId}', subscriber_id) + + + return self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) diff --git a/appwrite/services/sites.py b/appwrite/services/sites.py new file mode 100644 index 0000000..857cabe --- /dev/null +++ b/appwrite/services/sites.py @@ -0,0 +1,1102 @@ +from ..service import Service +from typing import List, Dict, Any +from ..exception import AppwriteException +from ..enums.framework import Framework; +from ..enums.build_runtime import BuildRuntime; +from ..enums.adapter import Adapter; +from ..input_file import InputFile +from ..enums.vcs_deployment_type import VCSDeploymentType; +from ..enums.deployment_download_type import DeploymentDownloadType; + +class Sites(Service): + + def __init__(self, client) -> None: + super(Sites, self).__init__(client) + + def list(self, queries: List[str] = None, search: str = None) -> Dict[str, Any]: + """ + Get a list of all the project's sites. You can use the query params to filter your results. + + + Parameters + ---------- + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, framework, deploymentId, buildCommand, installCommand, outputDirectory, installationId + search : str + Search term to filter your list results. Max length: 256 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/sites' + api_params = {} + + api_params['queries'] = queries + api_params['search'] = search + + return self.client.call('get', api_path, { + }, api_params) + + def create(self, site_id: str, name: str, framework: Framework, build_runtime: BuildRuntime, enabled: bool = None, logging: bool = None, timeout: float = None, install_command: str = None, build_command: str = None, output_directory: str = None, adapter: Adapter = None, installation_id: str = None, fallback_file: str = None, provider_repository_id: str = None, provider_branch: str = None, provider_silent_mode: bool = None, provider_root_directory: str = None, specification: str = None) -> Dict[str, Any]: + """ + Create a new site. + + + Parameters + ---------- + site_id : str + Site ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + name : str + Site name. Max length: 128 chars. + framework : Framework + Sites framework. + build_runtime : BuildRuntime + Runtime to use during build step. + enabled : bool + 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. + logging : bool + When disabled, request logs will exclude logs and errors, and site responses will be slightly faster. + timeout : float + Maximum request time in seconds. + install_command : str + Install Command. + build_command : str + Build Command. + output_directory : str + Output Directory for site. + adapter : Adapter + Framework adapter defining rendering strategy. Allowed values are: static, ssr + installation_id : str + Appwrite Installation ID for VCS (Version Control System) deployment. + fallback_file : str + Fallback file for single page application sites. + provider_repository_id : str + Repository ID of the repo linked to the site. + provider_branch : str + Production branch for the repo linked to the site. + provider_silent_mode : bool + Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. + provider_root_directory : str + Path to site code in the linked repo. + specification : str + Framework specification for the site and builds. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/sites' + api_params = {} + if site_id is None: + raise AppwriteException('Missing required parameter: "site_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + if framework is None: + raise AppwriteException('Missing required parameter: "framework"') + + if build_runtime is None: + raise AppwriteException('Missing required parameter: "build_runtime"') + + + api_params['siteId'] = site_id + api_params['name'] = name + api_params['framework'] = framework + api_params['enabled'] = enabled + api_params['logging'] = logging + api_params['timeout'] = timeout + api_params['installCommand'] = install_command + api_params['buildCommand'] = build_command + api_params['outputDirectory'] = output_directory + api_params['buildRuntime'] = build_runtime + api_params['adapter'] = adapter + api_params['installationId'] = installation_id + api_params['fallbackFile'] = fallback_file + api_params['providerRepositoryId'] = provider_repository_id + api_params['providerBranch'] = provider_branch + api_params['providerSilentMode'] = provider_silent_mode + api_params['providerRootDirectory'] = provider_root_directory + api_params['specification'] = specification + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def list_frameworks(self) -> Dict[str, Any]: + """ + Get a list of all frameworks that are currently available on the server instance. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/sites/frameworks' + api_params = {} + + return self.client.call('get', api_path, { + }, api_params) + + def list_specifications(self) -> Dict[str, Any]: + """ + List allowed site specifications for this instance. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/sites/specifications' + api_params = {} + + return self.client.call('get', api_path, { + }, api_params) + + def get(self, site_id: str) -> Dict[str, Any]: + """ + Get a site by its unique ID. + + + Parameters + ---------- + site_id : str + Site ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/sites/{siteId}' + api_params = {} + if site_id is None: + raise AppwriteException('Missing required parameter: "site_id"') + + api_path = api_path.replace('{siteId}', site_id) + + + return self.client.call('get', api_path, { + }, api_params) + + def update(self, site_id: str, name: str, framework: Framework, enabled: bool = None, logging: bool = None, timeout: float = None, install_command: str = None, build_command: str = None, output_directory: str = None, build_runtime: BuildRuntime = None, adapter: Adapter = None, fallback_file: str = None, installation_id: str = None, provider_repository_id: str = None, provider_branch: str = None, provider_silent_mode: bool = None, provider_root_directory: str = None, specification: str = None) -> Dict[str, Any]: + """ + Update site by its unique ID. + + + Parameters + ---------- + site_id : str + Site ID. + name : str + Site name. Max length: 128 chars. + framework : Framework + Sites framework. + enabled : bool + 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. + logging : bool + When disabled, request logs will exclude logs and errors, and site responses will be slightly faster. + timeout : float + Maximum request time in seconds. + install_command : str + Install Command. + build_command : str + Build Command. + output_directory : str + Output Directory for site. + build_runtime : BuildRuntime + Runtime to use during build step. + adapter : Adapter + Framework adapter defining rendering strategy. Allowed values are: static, ssr + fallback_file : str + Fallback file for single page application sites. + installation_id : str + Appwrite Installation ID for VCS (Version Control System) deployment. + provider_repository_id : str + Repository ID of the repo linked to the site. + provider_branch : str + Production branch for the repo linked to the site. + provider_silent_mode : bool + Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. + provider_root_directory : str + Path to site code in the linked repo. + specification : str + Framework specification for the site and builds. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/sites/{siteId}' + api_params = {} + if site_id is None: + raise AppwriteException('Missing required parameter: "site_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + if framework is None: + raise AppwriteException('Missing required parameter: "framework"') + + api_path = api_path.replace('{siteId}', site_id) + + api_params['name'] = name + api_params['framework'] = framework + api_params['enabled'] = enabled + api_params['logging'] = logging + api_params['timeout'] = timeout + api_params['installCommand'] = install_command + api_params['buildCommand'] = build_command + api_params['outputDirectory'] = output_directory + api_params['buildRuntime'] = build_runtime + api_params['adapter'] = adapter + api_params['fallbackFile'] = fallback_file + api_params['installationId'] = installation_id + api_params['providerRepositoryId'] = provider_repository_id + api_params['providerBranch'] = provider_branch + api_params['providerSilentMode'] = provider_silent_mode + api_params['providerRootDirectory'] = provider_root_directory + api_params['specification'] = specification + + return self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + def delete(self, site_id: str) -> Dict[str, Any]: + """ + Delete a site by its unique ID. + + + Parameters + ---------- + site_id : str + Site ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/sites/{siteId}' + api_params = {} + if site_id is None: + raise AppwriteException('Missing required parameter: "site_id"') + + api_path = api_path.replace('{siteId}', site_id) + + + return self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_site_deployment(self, site_id: str, deployment_id: str) -> Dict[str, Any]: + """ + Update the site active deployment. Use this endpoint to switch the code deployment that should be used when visitor opens your site. + + + Parameters + ---------- + site_id : str + Site ID. + deployment_id : str + Deployment ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/sites/{siteId}/deployment' + api_params = {} + if site_id is None: + raise AppwriteException('Missing required parameter: "site_id"') + + if deployment_id is None: + raise AppwriteException('Missing required parameter: "deployment_id"') + + api_path = api_path.replace('{siteId}', site_id) + + api_params['deploymentId'] = deployment_id + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def list_deployments(self, site_id: str, queries: List[str] = None, search: str = None) -> Dict[str, Any]: + """ + Get a list of all the site's code deployments. You can use the query params to filter your results. + + + Parameters + ---------- + site_id : str + Site ID. + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: buildSize, sourceSize, totalSize, buildDuration, status, activate, type + search : str + Search term to filter your list results. Max length: 256 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/sites/{siteId}/deployments' + api_params = {} + if site_id is None: + raise AppwriteException('Missing required parameter: "site_id"') + + api_path = api_path.replace('{siteId}', site_id) + + api_params['queries'] = queries + api_params['search'] = search + + return self.client.call('get', api_path, { + }, api_params) + + def create_deployment(self, site_id: str, code: InputFile, activate: bool, install_command: str = None, build_command: str = None, output_directory: str = None, on_progress = None) -> Dict[str, Any]: + """ + Create a new site code deployment. Use this endpoint to upload a new version of your site code. To activate your newly uploaded code, you'll need to update the function's deployment to use your new deployment ID. + + + Parameters + ---------- + site_id : str + Site ID. + code : InputFile + Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory. + activate : bool + Automatically activate the deployment when it is finished building. + install_command : str + Install Commands. + build_command : str + Build Commands. + output_directory : str + Output Directory. + on_progress : callable, optional + Optional callback for upload progress + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/sites/{siteId}/deployments' + api_params = {} + if site_id is None: + raise AppwriteException('Missing required parameter: "site_id"') + + if code is None: + raise AppwriteException('Missing required parameter: "code"') + + if activate is None: + raise AppwriteException('Missing required parameter: "activate"') + + api_path = api_path.replace('{siteId}', site_id) + + api_params['installCommand'] = install_command + api_params['buildCommand'] = build_command + api_params['outputDirectory'] = output_directory + api_params['code'] = str(code).lower() if type(code) is bool else code + api_params['activate'] = str(activate).lower() if type(activate) is bool else activate + + param_name = 'code' + + + upload_id = '' + + return self.client.chunked_upload(api_path, { + 'content-type': 'multipart/form-data', + }, api_params, param_name, on_progress, upload_id) + + def create_duplicate_deployment(self, site_id: str, deployment_id: str) -> Dict[str, Any]: + """ + Create a new build for an existing site deployment. This endpoint allows you to rebuild a deployment with the updated site configuration, including its commands and output directory if they have been modified. The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build. + + + Parameters + ---------- + site_id : str + Site ID. + deployment_id : str + Deployment ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/sites/{siteId}/deployments/duplicate' + api_params = {} + if site_id is None: + raise AppwriteException('Missing required parameter: "site_id"') + + if deployment_id is None: + raise AppwriteException('Missing required parameter: "deployment_id"') + + api_path = api_path.replace('{siteId}', site_id) + + api_params['deploymentId'] = deployment_id + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_template_deployment(self, site_id: str, repository: str, owner: str, root_directory: str, version: str, activate: bool = None) -> Dict[str, Any]: + """ + Create a deployment based on a template. + + Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/server/sites#listTemplates) to find the template details. + + + Parameters + ---------- + site_id : str + Site ID. + repository : str + Repository name of the template. + owner : str + The name of the owner of the template. + root_directory : str + Path to site code in the template repo. + version : str + Version (tag) for the repo linked to the site template. + activate : bool + Automatically activate the deployment when it is finished building. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/sites/{siteId}/deployments/template' + api_params = {} + if site_id is None: + raise AppwriteException('Missing required parameter: "site_id"') + + if repository is None: + raise AppwriteException('Missing required parameter: "repository"') + + if owner is None: + raise AppwriteException('Missing required parameter: "owner"') + + if root_directory is None: + raise AppwriteException('Missing required parameter: "root_directory"') + + if version is None: + raise AppwriteException('Missing required parameter: "version"') + + api_path = api_path.replace('{siteId}', site_id) + + api_params['repository'] = repository + api_params['owner'] = owner + api_params['rootDirectory'] = root_directory + api_params['version'] = version + api_params['activate'] = activate + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_vcs_deployment(self, site_id: str, type: VCSDeploymentType, reference: str, activate: bool = None) -> Dict[str, Any]: + """ + Create a deployment when a site is connected to VCS. + + This endpoint lets you create deployment from a branch, commit, or a tag. + + + Parameters + ---------- + site_id : str + Site ID. + type : VCSDeploymentType + Type of reference passed. Allowed values are: branch, commit + reference : str + VCS reference to create deployment from. Depending on type this can be: branch name, commit hash + activate : bool + Automatically activate the deployment when it is finished building. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/sites/{siteId}/deployments/vcs' + api_params = {} + if site_id is None: + raise AppwriteException('Missing required parameter: "site_id"') + + if type is None: + raise AppwriteException('Missing required parameter: "type"') + + if reference is None: + raise AppwriteException('Missing required parameter: "reference"') + + api_path = api_path.replace('{siteId}', site_id) + + api_params['type'] = type + api_params['reference'] = reference + api_params['activate'] = activate + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def get_deployment(self, site_id: str, deployment_id: str) -> Dict[str, Any]: + """ + Get a site deployment by its unique ID. + + + Parameters + ---------- + site_id : str + Site ID. + deployment_id : str + Deployment ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/sites/{siteId}/deployments/{deploymentId}' + api_params = {} + if site_id is None: + raise AppwriteException('Missing required parameter: "site_id"') + + if deployment_id is None: + raise AppwriteException('Missing required parameter: "deployment_id"') + + api_path = api_path.replace('{siteId}', site_id) + api_path = api_path.replace('{deploymentId}', deployment_id) + + + return self.client.call('get', api_path, { + }, api_params) + + def delete_deployment(self, site_id: str, deployment_id: str) -> Dict[str, Any]: + """ + Delete a site deployment by its unique ID. + + + Parameters + ---------- + site_id : str + Site ID. + deployment_id : str + Deployment ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/sites/{siteId}/deployments/{deploymentId}' + api_params = {} + if site_id is None: + raise AppwriteException('Missing required parameter: "site_id"') + + if deployment_id is None: + raise AppwriteException('Missing required parameter: "deployment_id"') + + api_path = api_path.replace('{siteId}', site_id) + api_path = api_path.replace('{deploymentId}', deployment_id) + + + return self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + def get_deployment_download(self, site_id: str, deployment_id: str, type: DeploymentDownloadType = None) -> bytes: + """ + Get a site deployment content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory. + + + Parameters + ---------- + site_id : str + Site ID. + deployment_id : str + Deployment ID. + type : DeploymentDownloadType + Deployment file to download. Can be: "source", "output". + + Returns + ------- + bytes + Response as bytes + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/sites/{siteId}/deployments/{deploymentId}/download' + api_params = {} + if site_id is None: + raise AppwriteException('Missing required parameter: "site_id"') + + if deployment_id is None: + raise AppwriteException('Missing required parameter: "deployment_id"') + + api_path = api_path.replace('{siteId}', site_id) + api_path = api_path.replace('{deploymentId}', deployment_id) + + api_params['type'] = type + + return self.client.call('get', api_path, { + }, api_params) + + def update_deployment_status(self, site_id: str, deployment_id: str) -> Dict[str, Any]: + """ + Cancel an ongoing site deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn't started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status 'ready') or failed. The response includes the final build status and details. + + + Parameters + ---------- + site_id : str + Site ID. + deployment_id : str + Deployment ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/sites/{siteId}/deployments/{deploymentId}/status' + api_params = {} + if site_id is None: + raise AppwriteException('Missing required parameter: "site_id"') + + if deployment_id is None: + raise AppwriteException('Missing required parameter: "deployment_id"') + + api_path = api_path.replace('{siteId}', site_id) + api_path = api_path.replace('{deploymentId}', deployment_id) + + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def list_logs(self, site_id: str, queries: List[str] = None) -> Dict[str, Any]: + """ + Get a list of all site logs. You can use the query params to filter your results. + + + Parameters + ---------- + site_id : str + Site ID. + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, responseStatusCode, duration, requestMethod, requestPath, deploymentId + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/sites/{siteId}/logs' + api_params = {} + if site_id is None: + raise AppwriteException('Missing required parameter: "site_id"') + + api_path = api_path.replace('{siteId}', site_id) + + api_params['queries'] = queries + + return self.client.call('get', api_path, { + }, api_params) + + def get_log(self, site_id: str, log_id: str) -> Dict[str, Any]: + """ + Get a site request log by its unique ID. + + + Parameters + ---------- + site_id : str + Site ID. + log_id : str + Log ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/sites/{siteId}/logs/{logId}' + api_params = {} + if site_id is None: + raise AppwriteException('Missing required parameter: "site_id"') + + if log_id is None: + raise AppwriteException('Missing required parameter: "log_id"') + + api_path = api_path.replace('{siteId}', site_id) + api_path = api_path.replace('{logId}', log_id) + + + return self.client.call('get', api_path, { + }, api_params) + + def delete_log(self, site_id: str, log_id: str) -> Dict[str, Any]: + """ + Delete a site log by its unique ID. + + + Parameters + ---------- + site_id : str + Site ID. + log_id : str + Log ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/sites/{siteId}/logs/{logId}' + api_params = {} + if site_id is None: + raise AppwriteException('Missing required parameter: "site_id"') + + if log_id is None: + raise AppwriteException('Missing required parameter: "log_id"') + + api_path = api_path.replace('{siteId}', site_id) + api_path = api_path.replace('{logId}', log_id) + + + return self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + def list_variables(self, site_id: str) -> Dict[str, Any]: + """ + Get a list of all variables of a specific site. + + + Parameters + ---------- + site_id : str + Site unique ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/sites/{siteId}/variables' + api_params = {} + if site_id is None: + raise AppwriteException('Missing required parameter: "site_id"') + + api_path = api_path.replace('{siteId}', site_id) + + + return self.client.call('get', api_path, { + }, api_params) + + def create_variable(self, site_id: str, key: str, value: str, secret: bool = None) -> Dict[str, Any]: + """ + Create a new site variable. These variables can be accessed during build and runtime (server-side rendering) as environment variables. + + + Parameters + ---------- + site_id : str + Site unique ID. + key : str + Variable key. Max length: 255 chars. + value : str + Variable value. Max length: 8192 chars. + secret : bool + Secret variables can be updated or deleted, but only sites can read them during build and runtime. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/sites/{siteId}/variables' + api_params = {} + if site_id is None: + raise AppwriteException('Missing required parameter: "site_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if value is None: + raise AppwriteException('Missing required parameter: "value"') + + api_path = api_path.replace('{siteId}', site_id) + + api_params['key'] = key + api_params['value'] = value + api_params['secret'] = secret + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def get_variable(self, site_id: str, variable_id: str) -> Dict[str, Any]: + """ + Get a variable by its unique ID. + + + Parameters + ---------- + site_id : str + Site unique ID. + variable_id : str + Variable unique ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/sites/{siteId}/variables/{variableId}' + api_params = {} + if site_id is None: + raise AppwriteException('Missing required parameter: "site_id"') + + if variable_id is None: + raise AppwriteException('Missing required parameter: "variable_id"') + + api_path = api_path.replace('{siteId}', site_id) + api_path = api_path.replace('{variableId}', variable_id) + + + return self.client.call('get', api_path, { + }, api_params) + + def update_variable(self, site_id: str, variable_id: str, key: str, value: str = None, secret: bool = None) -> Dict[str, Any]: + """ + Update variable by its unique ID. + + + Parameters + ---------- + site_id : str + Site unique ID. + variable_id : str + Variable unique ID. + key : str + Variable key. Max length: 255 chars. + value : str + Variable value. Max length: 8192 chars. + secret : bool + Secret variables can be updated or deleted, but only sites can read them during build and runtime. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/sites/{siteId}/variables/{variableId}' + api_params = {} + if site_id is None: + raise AppwriteException('Missing required parameter: "site_id"') + + if variable_id is None: + raise AppwriteException('Missing required parameter: "variable_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + api_path = api_path.replace('{siteId}', site_id) + api_path = api_path.replace('{variableId}', variable_id) + + api_params['key'] = key + api_params['value'] = value + api_params['secret'] = secret + + return self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + def delete_variable(self, site_id: str, variable_id: str) -> Dict[str, Any]: + """ + Delete a variable by its unique ID. + + + Parameters + ---------- + site_id : str + Site unique ID. + variable_id : str + Variable unique ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/sites/{siteId}/variables/{variableId}' + api_params = {} + if site_id is None: + raise AppwriteException('Missing required parameter: "site_id"') + + if variable_id is None: + raise AppwriteException('Missing required parameter: "variable_id"') + + api_path = api_path.replace('{siteId}', site_id) + api_path = api_path.replace('{variableId}', variable_id) + + + return self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) diff --git a/appwrite/services/storage.py b/appwrite/services/storage.py index 60346e0..e970187 100644 --- a/appwrite/services/storage.py +++ b/appwrite/services/storage.py @@ -1,192 +1,614 @@ from ..service import Service +from typing import List, Dict, Any from ..exception import AppwriteException +from ..enums.compression import Compression; +from ..input_file import InputFile +from ..enums.image_gravity import ImageGravity; +from ..enums.image_format import ImageFormat; class Storage(Service): - def __init__(self, client): + def __init__(self, client) -> None: super(Storage, self).__init__(client) - def list_files(self, search = None, limit = None, offset = None, cursor = None, cursor_direction = None, order_type = None): - """List Files""" - - params = {} - path = '/storage/files' - - if search is not None: - params['search'] = search - - if limit is not None: - params['limit'] = limit - - if offset is not None: - params['offset'] = offset - - if cursor is not None: - params['cursor'] = cursor - - if cursor_direction is not None: - params['cursorDirection'] = cursor_direction - - if order_type is not None: - params['orderType'] = order_type - - return self.client.call('get', path, { + def list_buckets(self, queries: List[str] = None, search: str = None) -> Dict[str, Any]: + """ + Get a list of all the storage buckets. You can use the query params to filter your results. + + + Parameters + ---------- + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: enabled, name, fileSecurity, maximumFileSize, encryption, antivirus + search : str + Search term to filter your list results. Max length: 256 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/storage/buckets' + api_params = {} + + api_params['queries'] = queries + api_params['search'] = search + + return self.client.call('get', api_path, { + }, api_params) + + def create_bucket(self, bucket_id: str, name: str, permissions: List[str] = None, file_security: bool = None, enabled: bool = None, maximum_file_size: float = None, allowed_file_extensions: List[str] = None, compression: Compression = None, encryption: bool = None, antivirus: bool = None) -> Dict[str, Any]: + """ + Create a new storage bucket. + + + Parameters + ---------- + bucket_id : str + Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + name : str + Bucket name + permissions : List[str] + An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + file_security : bool + Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). + enabled : bool + Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. + maximum_file_size : float + Maximum file size allowed in bytes. Maximum allowed value is 30MB. + allowed_file_extensions : List[str] + Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. + compression : Compression + Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled + encryption : bool + Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled + antivirus : bool + Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/storage/buckets' + api_params = {} + if bucket_id is None: + raise AppwriteException('Missing required parameter: "bucket_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + + api_params['bucketId'] = bucket_id + api_params['name'] = name + api_params['permissions'] = permissions + api_params['fileSecurity'] = file_security + api_params['enabled'] = enabled + api_params['maximumFileSize'] = maximum_file_size + api_params['allowedFileExtensions'] = allowed_file_extensions + api_params['compression'] = compression + api_params['encryption'] = encryption + api_params['antivirus'] = antivirus + + return self.client.call('post', api_path, { 'content-type': 'application/json', - }, params) - - def create_file(self, file_id, file, read = None, write = None): - """Create File""" - - if file_id is None: + }, api_params) + + def get_bucket(self, bucket_id: str) -> Dict[str, Any]: + """ + Get a storage bucket by its unique ID. This endpoint response returns a JSON object with the storage bucket metadata. + + + Parameters + ---------- + bucket_id : str + Bucket unique ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/storage/buckets/{bucketId}' + api_params = {} + if bucket_id is None: + raise AppwriteException('Missing required parameter: "bucket_id"') + + api_path = api_path.replace('{bucketId}', bucket_id) + + + return self.client.call('get', api_path, { + }, api_params) + + def update_bucket(self, bucket_id: str, name: str, permissions: List[str] = None, file_security: bool = None, enabled: bool = None, maximum_file_size: float = None, allowed_file_extensions: List[str] = None, compression: Compression = None, encryption: bool = None, antivirus: bool = None) -> Dict[str, Any]: + """ + Update a storage bucket by its unique ID. + + + Parameters + ---------- + bucket_id : str + Bucket unique ID. + name : str + Bucket name + permissions : List[str] + An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + file_security : bool + Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). + enabled : bool + Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. + maximum_file_size : float + Maximum file size allowed in bytes. Maximum allowed value is 30MB. + allowed_file_extensions : List[str] + Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. + compression : Compression + Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled + encryption : bool + Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled + antivirus : bool + Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/storage/buckets/{bucketId}' + api_params = {} + if bucket_id is None: + raise AppwriteException('Missing required parameter: "bucket_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + api_path = api_path.replace('{bucketId}', bucket_id) + + api_params['name'] = name + api_params['permissions'] = permissions + api_params['fileSecurity'] = file_security + api_params['enabled'] = enabled + api_params['maximumFileSize'] = maximum_file_size + api_params['allowedFileExtensions'] = allowed_file_extensions + api_params['compression'] = compression + api_params['encryption'] = encryption + api_params['antivirus'] = antivirus + + return self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + def delete_bucket(self, bucket_id: str) -> Dict[str, Any]: + """ + Delete a storage bucket by its unique ID. + + + Parameters + ---------- + bucket_id : str + Bucket unique ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/storage/buckets/{bucketId}' + api_params = {} + if bucket_id is None: + raise AppwriteException('Missing required parameter: "bucket_id"') + + api_path = api_path.replace('{bucketId}', bucket_id) + + + return self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + def list_files(self, bucket_id: str, queries: List[str] = None, search: str = None) -> Dict[str, Any]: + """ + Get a list of all the user files. You can use the query params to filter your results. + + + Parameters + ---------- + bucket_id : str + Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, signature, mimeType, sizeOriginal, chunksTotal, chunksUploaded + search : str + Search term to filter your list results. Max length: 256 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/storage/buckets/{bucketId}/files' + api_params = {} + if bucket_id is None: + raise AppwriteException('Missing required parameter: "bucket_id"') + + api_path = api_path.replace('{bucketId}', bucket_id) + + api_params['queries'] = queries + api_params['search'] = search + + return self.client.call('get', api_path, { + }, api_params) + + def create_file(self, bucket_id: str, file_id: str, file: InputFile, permissions: List[str] = None, on_progress = None) -> Dict[str, Any]: + """ + Create a new file. Before using this route, you should create a new bucket resource using either a [server integration](https://appwrite.io/docs/server/storage#storageCreateBucket) API or directly from your Appwrite console. + + Larger files should be uploaded using multiple requests with the [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) header to send a partial request with a maximum supported chunk of `5MB`. The `content-range` header values should always be in bytes. + + When the first request is sent, the server will return the **File** object, and the subsequent part request must include the file's **id** in `x-appwrite-id` header to allow the server to know that the partial upload is for the existing file and not for a new one. + + If you're creating a new file using one of the Appwrite SDKs, all the chunking logic will be managed by the SDK internally. + + + + Parameters + ---------- + bucket_id : str + Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + file_id : str + File ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + file : InputFile + Binary file. Appwrite SDKs provide helpers to handle file input. [Learn about file input](https://appwrite.io/docs/products/storage/upload-download#input-file). + permissions : List[str] + An array of permission strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + on_progress : callable, optional + Optional callback for upload progress + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/storage/buckets/{bucketId}/files' + api_params = {} + if bucket_id is None: + raise AppwriteException('Missing required parameter: "bucket_id"') + + if file_id is None: raise AppwriteException('Missing required parameter: "file_id"') - if file is None: + if file is None: raise AppwriteException('Missing required parameter: "file"') - params = {} - path = '/storage/files' + api_path = api_path.replace('{bucketId}', bucket_id) - if file_id is not None: - params['fileId'] = file_id + api_params['fileId'] = file_id + api_params['file'] = str(file).lower() if type(file) is bool else file + api_params['permissions'] = permissions - if file is not None: - params['file'] = file + param_name = 'file' - if read is not None: - params['read'] = read - if write is not None: - params['write'] = write + upload_id = '' + upload_id = file_id - return self.client.call('post', path, { + return self.client.chunked_upload(api_path, { 'content-type': 'multipart/form-data', - }, params) - - def get_file(self, file_id): - """Get File""" - - if file_id is None: + }, api_params, param_name, on_progress, upload_id) + + def get_file(self, bucket_id: str, file_id: str) -> Dict[str, Any]: + """ + Get a file by its unique ID. This endpoint response returns a JSON object with the file metadata. + + + Parameters + ---------- + bucket_id : str + Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + file_id : str + File ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/storage/buckets/{bucketId}/files/{fileId}' + api_params = {} + if bucket_id is None: + raise AppwriteException('Missing required parameter: "bucket_id"') + + if file_id is None: raise AppwriteException('Missing required parameter: "file_id"') - params = {} - path = '/storage/files/{fileId}' - path = path.replace('{fileId}', file_id) - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def update_file(self, file_id, read, write): - """Update File""" - - if file_id is None: + api_path = api_path.replace('{bucketId}', bucket_id) + api_path = api_path.replace('{fileId}', file_id) + + + return self.client.call('get', api_path, { + }, api_params) + + def update_file(self, bucket_id: str, file_id: str, name: str = None, permissions: List[str] = None) -> Dict[str, Any]: + """ + Update a file by its unique ID. Only users with write permissions have access to update this resource. + + + Parameters + ---------- + bucket_id : str + Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + file_id : str + File unique ID. + name : str + Name of the file + permissions : List[str] + An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/storage/buckets/{bucketId}/files/{fileId}' + api_params = {} + if bucket_id is None: + raise AppwriteException('Missing required parameter: "bucket_id"') + + if file_id is None: raise AppwriteException('Missing required parameter: "file_id"') - if read is None: - raise AppwriteException('Missing required parameter: "read"') + api_path = api_path.replace('{bucketId}', bucket_id) + api_path = api_path.replace('{fileId}', file_id) - if write is None: - raise AppwriteException('Missing required parameter: "write"') + api_params['name'] = name + api_params['permissions'] = permissions - params = {} - path = '/storage/files/{fileId}' - path = path.replace('{fileId}', file_id) - - if read is not None: - params['read'] = read - - if write is not None: - params['write'] = write - - return self.client.call('put', path, { + return self.client.call('put', api_path, { 'content-type': 'application/json', - }, params) - - def delete_file(self, file_id): - """Delete File""" - - if file_id is None: + }, api_params) + + def delete_file(self, bucket_id: str, file_id: str) -> Dict[str, Any]: + """ + Delete a file by its unique ID. Only users with write permissions have access to delete this resource. + + + Parameters + ---------- + bucket_id : str + Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + file_id : str + File ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/storage/buckets/{bucketId}/files/{fileId}' + api_params = {} + if bucket_id is None: + raise AppwriteException('Missing required parameter: "bucket_id"') + + if file_id is None: raise AppwriteException('Missing required parameter: "file_id"') - params = {} - path = '/storage/files/{fileId}' - path = path.replace('{fileId}', file_id) + api_path = api_path.replace('{bucketId}', bucket_id) + api_path = api_path.replace('{fileId}', file_id) - return self.client.call('delete', path, { - 'content-type': 'application/json', - }, params) - def get_file_download(self, file_id): - """Get File for Download""" - - if file_id is None: - raise AppwriteException('Missing required parameter: "file_id"') - - params = {} - path = '/storage/files/{fileId}/download' - path = path.replace('{fileId}', file_id) - - return self.client.call('get', path, { + return self.client.call('delete', api_path, { 'content-type': 'application/json', - }, params) - - def get_file_preview(self, file_id, width = None, height = None, gravity = None, quality = None, border_width = None, border_color = None, border_radius = None, opacity = None, rotation = None, background = None, output = None): - """Get File Preview""" - - if file_id is None: + }, api_params) + + def get_file_download(self, bucket_id: str, file_id: str, token: str = None) -> bytes: + """ + Get a file content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory. + + + Parameters + ---------- + bucket_id : str + Storage bucket ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + file_id : str + File ID. + token : str + File token for accessing this file. + + Returns + ------- + bytes + Response as bytes + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/storage/buckets/{bucketId}/files/{fileId}/download' + api_params = {} + if bucket_id is None: + raise AppwriteException('Missing required parameter: "bucket_id"') + + if file_id is None: raise AppwriteException('Missing required parameter: "file_id"') - params = {} - path = '/storage/files/{fileId}/preview' - path = path.replace('{fileId}', file_id) - - if width is not None: - params['width'] = width - - if height is not None: - params['height'] = height - - if gravity is not None: - params['gravity'] = gravity - - if quality is not None: - params['quality'] = quality - - if border_width is not None: - params['borderWidth'] = border_width - - if border_color is not None: - params['borderColor'] = border_color - - if border_radius is not None: - params['borderRadius'] = border_radius - - if opacity is not None: - params['opacity'] = opacity - - if rotation is not None: - params['rotation'] = rotation - - if background is not None: - params['background'] = background - - if output is not None: - params['output'] = output - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def get_file_view(self, file_id): - """Get File for View""" + api_path = api_path.replace('{bucketId}', bucket_id) + api_path = api_path.replace('{fileId}', file_id) + + api_params['token'] = token + + return self.client.call('get', api_path, { + }, api_params) + + def get_file_preview(self, bucket_id: str, file_id: str, width: float = None, height: float = None, gravity: ImageGravity = None, quality: float = None, border_width: float = None, border_color: str = None, border_radius: float = None, opacity: float = None, rotation: float = None, background: str = None, output: ImageFormat = None, token: str = None) -> bytes: + """ + Get a file preview image. Currently, this method supports preview for image files (jpg, png, and gif), other supported formats, like pdf, docs, slides, and spreadsheets, will return the file icon image. You can also pass query string arguments for cutting and resizing your preview image. Preview is supported only for image files smaller than 10MB. + + + Parameters + ---------- + bucket_id : str + Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + file_id : str + File ID + width : float + Resize preview image width, Pass an integer between 0 to 4000. + height : float + Resize preview image height, Pass an integer between 0 to 4000. + gravity : ImageGravity + Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right + quality : float + Preview image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. + border_width : float + Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0. + border_color : str + Preview image border color. Use a valid HEX color, no # is needed for prefix. + border_radius : float + Preview image border radius in pixels. Pass an integer between 0 to 4000. + opacity : float + Preview image opacity. Only works with images having an alpha channel (like png). Pass a number between 0 to 1. + rotation : float + Preview image rotation in degrees. Pass an integer between -360 and 360. + background : str + Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix. + output : ImageFormat + Output format type (jpeg, jpg, png, gif and webp). + token : str + File token for accessing this file. + + Returns + ------- + bytes + Response as bytes + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/storage/buckets/{bucketId}/files/{fileId}/preview' + api_params = {} + if bucket_id is None: + raise AppwriteException('Missing required parameter: "bucket_id"') + + if file_id is None: + raise AppwriteException('Missing required parameter: "file_id"') - if file_id is None: + api_path = api_path.replace('{bucketId}', bucket_id) + api_path = api_path.replace('{fileId}', file_id) + + api_params['width'] = width + api_params['height'] = height + api_params['gravity'] = gravity + api_params['quality'] = quality + api_params['borderWidth'] = border_width + api_params['borderColor'] = border_color + api_params['borderRadius'] = border_radius + api_params['opacity'] = opacity + api_params['rotation'] = rotation + api_params['background'] = background + api_params['output'] = output + api_params['token'] = token + + return self.client.call('get', api_path, { + }, api_params) + + def get_file_view(self, bucket_id: str, file_id: str, token: str = None) -> bytes: + """ + Get a file content by its unique ID. This endpoint is similar to the download method but returns with no 'Content-Disposition: attachment' header. + + + Parameters + ---------- + bucket_id : str + Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + file_id : str + File ID. + token : str + File token for accessing this file. + + Returns + ------- + bytes + Response as bytes + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/storage/buckets/{bucketId}/files/{fileId}/view' + api_params = {} + if bucket_id is None: + raise AppwriteException('Missing required parameter: "bucket_id"') + + if file_id is None: raise AppwriteException('Missing required parameter: "file_id"') - params = {} - path = '/storage/files/{fileId}/view' - path = path.replace('{fileId}', file_id) + api_path = api_path.replace('{bucketId}', bucket_id) + api_path = api_path.replace('{fileId}', file_id) - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) + api_params['token'] = token + + return self.client.call('get', api_path, { + }, api_params) diff --git a/appwrite/services/teams.py b/appwrite/services/teams.py index 813c84a..50e0297 100644 --- a/appwrite/services/teams.py +++ b/appwrite/services/teams.py @@ -1,265 +1,533 @@ from ..service import Service +from typing import List, Dict, Any from ..exception import AppwriteException class Teams(Service): - def __init__(self, client): + def __init__(self, client) -> None: super(Teams, self).__init__(client) - def list(self, search = None, limit = None, offset = None, cursor = None, cursor_direction = None, order_type = None): - """List Teams""" - - params = {} - path = '/teams' - - if search is not None: - params['search'] = search - - if limit is not None: - params['limit'] = limit - - if offset is not None: - params['offset'] = offset - - if cursor is not None: - params['cursor'] = cursor - - if cursor_direction is not None: - params['cursorDirection'] = cursor_direction - - if order_type is not None: - params['orderType'] = order_type - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def create(self, team_id, name, roles = None): - """Create Team""" - - if team_id is None: + def list(self, queries: List[str] = None, search: str = None) -> Dict[str, Any]: + """ + Get a list of all the teams in which the current user is a member. You can use the parameters to filter your results. + + + Parameters + ---------- + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, total, billingPlan + search : str + Search term to filter your list results. Max length: 256 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/teams' + api_params = {} + + api_params['queries'] = queries + api_params['search'] = search + + return self.client.call('get', api_path, { + }, api_params) + + def create(self, team_id: str, name: str, roles: List[str] = None) -> Dict[str, Any]: + """ + Create a new team. The user who creates the team will automatically be assigned as the owner of the team. Only the users with the owner role can invite new members, add new owners and delete or update the team. + + + Parameters + ---------- + team_id : str + Team ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + name : str + Team name. Max length: 128 chars. + roles : List[str] + Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/teams' + api_params = {} + if team_id is None: raise AppwriteException('Missing required parameter: "team_id"') - if name is None: + if name is None: raise AppwriteException('Missing required parameter: "name"') - params = {} - path = '/teams' - - if team_id is not None: - params['teamId'] = team_id - if name is not None: - params['name'] = name + api_params['teamId'] = team_id + api_params['name'] = name + api_params['roles'] = roles - if roles is not None: - params['roles'] = roles - - return self.client.call('post', path, { + return self.client.call('post', api_path, { 'content-type': 'application/json', - }, params) - - def get(self, team_id): - """Get Team""" - - if team_id is None: + }, api_params) + + def get(self, team_id: str) -> Dict[str, Any]: + """ + Get a team by its ID. All team members have read access for this resource. + + + Parameters + ---------- + team_id : str + Team ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/teams/{teamId}' + api_params = {} + if team_id is None: raise AppwriteException('Missing required parameter: "team_id"') - params = {} - path = '/teams/{teamId}' - path = path.replace('{teamId}', team_id) - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def update(self, team_id, name): - """Update Team""" - - if team_id is None: + api_path = api_path.replace('{teamId}', team_id) + + + return self.client.call('get', api_path, { + }, api_params) + + def update_name(self, team_id: str, name: str) -> Dict[str, Any]: + """ + Update the team's name by its unique ID. + + + Parameters + ---------- + team_id : str + Team ID. + name : str + New team name. Max length: 128 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/teams/{teamId}' + api_params = {} + if team_id is None: raise AppwriteException('Missing required parameter: "team_id"') - if name is None: + if name is None: raise AppwriteException('Missing required parameter: "name"') - params = {} - path = '/teams/{teamId}' - path = path.replace('{teamId}', team_id) - - if name is not None: - params['name'] = name - - return self.client.call('put', path, { - 'content-type': 'application/json', - }, params) - - def delete(self, team_id): - """Delete Team""" - - if team_id is None: - raise AppwriteException('Missing required parameter: "team_id"') + api_path = api_path.replace('{teamId}', team_id) - params = {} - path = '/teams/{teamId}' - path = path.replace('{teamId}', team_id) + api_params['name'] = name - return self.client.call('delete', path, { + return self.client.call('put', api_path, { 'content-type': 'application/json', - }, params) - - def get_memberships(self, team_id, search = None, limit = None, offset = None, cursor = None, cursor_direction = None, order_type = None): - """Get Team Memberships""" - - if team_id is None: + }, api_params) + + def delete(self, team_id: str) -> Dict[str, Any]: + """ + Delete a team using its ID. Only team members with the owner role can delete the team. + + + Parameters + ---------- + team_id : str + Team ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/teams/{teamId}' + api_params = {} + if team_id is None: raise AppwriteException('Missing required parameter: "team_id"') - params = {} - path = '/teams/{teamId}/memberships' - path = path.replace('{teamId}', team_id) - - if search is not None: - params['search'] = search - - if limit is not None: - params['limit'] = limit + api_path = api_path.replace('{teamId}', team_id) - if offset is not None: - params['offset'] = offset - if cursor is not None: - params['cursor'] = cursor - - if cursor_direction is not None: - params['cursorDirection'] = cursor_direction - - if order_type is not None: - params['orderType'] = order_type - - return self.client.call('get', path, { + return self.client.call('delete', api_path, { 'content-type': 'application/json', - }, params) - - def create_membership(self, team_id, email, roles, url, name = None): - """Create Team Membership""" - - if team_id is None: + }, api_params) + + def list_memberships(self, team_id: str, queries: List[str] = None, search: str = None) -> Dict[str, Any]: + """ + Use this endpoint to list a team's members using the team's ID. All team members have read access to this endpoint. Hide sensitive attributes from the response by toggling membership privacy in the Console. + + + Parameters + ---------- + team_id : str + Team ID. + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, teamId, invited, joined, confirm, roles + search : str + Search term to filter your list results. Max length: 256 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/teams/{teamId}/memberships' + api_params = {} + if team_id is None: raise AppwriteException('Missing required parameter: "team_id"') - if email is None: - raise AppwriteException('Missing required parameter: "email"') + api_path = api_path.replace('{teamId}', team_id) + + api_params['queries'] = queries + api_params['search'] = search + + return self.client.call('get', api_path, { + }, api_params) + + def create_membership(self, team_id: str, roles: List[str], email: str = None, user_id: str = None, phone: str = None, url: str = None, name: str = None) -> Dict[str, Any]: + """ + Invite a new member to join your team. Provide an ID for existing users, or invite unregistered users using an email or phone number. If initiated from a Client SDK, Appwrite will send an email or sms with a link to join the team to the invited user, and an account will be created for them if one doesn't exist. If initiated from a Server SDK, the new member will be added automatically to the team. + + You only need to provide one of a user ID, email, or phone number. Appwrite will prioritize accepting the user ID > email > phone number if you provide more than one of these parameters. + + Use the `url` parameter to redirect the user from the invitation email to your app. After the user is redirected, use the [Update Team Membership Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus) endpoint to allow the user to accept the invitation to the team. + + Please note that to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) Appwrite will accept the only redirect URLs under the domains you have added as a platform on the Appwrite Console. + + + + Parameters + ---------- + team_id : str + Team ID. + roles : List[str] + Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. + email : str + Email of the new team member. + user_id : str + ID of the user to be added to a team. + phone : str + Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + url : str + URL to redirect the user back to your app from the invitation email. This parameter is not required when an API key is supplied. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. + name : str + Name of the new team member. Max length: 128 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/teams/{teamId}/memberships' + api_params = {} + if team_id is None: + raise AppwriteException('Missing required parameter: "team_id"') - if roles is None: + if roles is None: raise AppwriteException('Missing required parameter: "roles"') - if url is None: - raise AppwriteException('Missing required parameter: "url"') - - params = {} - path = '/teams/{teamId}/memberships' - path = path.replace('{teamId}', team_id) + api_path = api_path.replace('{teamId}', team_id) - if email is not None: - params['email'] = email + api_params['email'] = email + api_params['userId'] = user_id + api_params['phone'] = phone + api_params['roles'] = roles + api_params['url'] = url + api_params['name'] = name - if roles is not None: - params['roles'] = roles - - if url is not None: - params['url'] = url - - if name is not None: - params['name'] = name - - return self.client.call('post', path, { + return self.client.call('post', api_path, { 'content-type': 'application/json', - }, params) - - def get_membership(self, team_id, membership_id): - """Get Team Membership""" - - if team_id is None: + }, api_params) + + def get_membership(self, team_id: str, membership_id: str) -> Dict[str, Any]: + """ + Get a team member by the membership unique id. All team members have read access for this resource. Hide sensitive attributes from the response by toggling membership privacy in the Console. + + + Parameters + ---------- + team_id : str + Team ID. + membership_id : str + Membership ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/teams/{teamId}/memberships/{membershipId}' + api_params = {} + if team_id is None: raise AppwriteException('Missing required parameter: "team_id"') - if membership_id is None: + if membership_id is None: raise AppwriteException('Missing required parameter: "membership_id"') - params = {} - path = '/teams/{teamId}/memberships/{membershipId}' - path = path.replace('{teamId}', team_id) - path = path.replace('{membershipId}', membership_id) - - return self.client.call('get', path, { - 'content-type': 'application/json', - }, params) - - def update_membership_roles(self, team_id, membership_id, roles): - """Update Membership Roles""" - - if team_id is None: + api_path = api_path.replace('{teamId}', team_id) + api_path = api_path.replace('{membershipId}', membership_id) + + + return self.client.call('get', api_path, { + }, api_params) + + def update_membership(self, team_id: str, membership_id: str, roles: List[str]) -> Dict[str, Any]: + """ + Modify the roles of a team member. Only team members with the owner role have access to this endpoint. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). + + + + Parameters + ---------- + team_id : str + Team ID. + membership_id : str + Membership ID. + roles : List[str] + An array of strings. Use this param to set the user's roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/teams/{teamId}/memberships/{membershipId}' + api_params = {} + if team_id is None: raise AppwriteException('Missing required parameter: "team_id"') - if membership_id is None: + if membership_id is None: raise AppwriteException('Missing required parameter: "membership_id"') - if roles is None: + if roles is None: raise AppwriteException('Missing required parameter: "roles"') - params = {} - path = '/teams/{teamId}/memberships/{membershipId}' - path = path.replace('{teamId}', team_id) - path = path.replace('{membershipId}', membership_id) + api_path = api_path.replace('{teamId}', team_id) + api_path = api_path.replace('{membershipId}', membership_id) - if roles is not None: - params['roles'] = roles + api_params['roles'] = roles - return self.client.call('patch', path, { + return self.client.call('patch', api_path, { 'content-type': 'application/json', - }, params) - - def delete_membership(self, team_id, membership_id): - """Delete Team Membership""" - - if team_id is None: + }, api_params) + + def delete_membership(self, team_id: str, membership_id: str) -> Dict[str, Any]: + """ + This endpoint allows a user to leave a team or for a team owner to delete the membership of any other team member. You can also use this endpoint to delete a user membership even if it is not accepted. + + + Parameters + ---------- + team_id : str + Team ID. + membership_id : str + Membership ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/teams/{teamId}/memberships/{membershipId}' + api_params = {} + if team_id is None: raise AppwriteException('Missing required parameter: "team_id"') - if membership_id is None: + if membership_id is None: raise AppwriteException('Missing required parameter: "membership_id"') - params = {} - path = '/teams/{teamId}/memberships/{membershipId}' - path = path.replace('{teamId}', team_id) - path = path.replace('{membershipId}', membership_id) + api_path = api_path.replace('{teamId}', team_id) + api_path = api_path.replace('{membershipId}', membership_id) - return self.client.call('delete', path, { - 'content-type': 'application/json', - }, params) - - def update_membership_status(self, team_id, membership_id, user_id, secret): - """Update Team Membership Status""" - if team_id is None: + return self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_membership_status(self, team_id: str, membership_id: str, user_id: str, secret: str) -> Dict[str, Any]: + """ + Use this endpoint to allow a user to accept an invitation to join a team after being redirected back to your app from the invitation email received by the user. + + If the request is successful, a session for the user is automatically created. + + + + Parameters + ---------- + team_id : str + Team ID. + membership_id : str + Membership ID. + user_id : str + User ID. + secret : str + Secret key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/teams/{teamId}/memberships/{membershipId}/status' + api_params = {} + if team_id is None: raise AppwriteException('Missing required parameter: "team_id"') - if membership_id is None: + if membership_id is None: raise AppwriteException('Missing required parameter: "membership_id"') - if user_id is None: + if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') - if secret is None: + if secret is None: raise AppwriteException('Missing required parameter: "secret"') - params = {} - path = '/teams/{teamId}/memberships/{membershipId}/status' - path = path.replace('{teamId}', team_id) - path = path.replace('{membershipId}', membership_id) + api_path = api_path.replace('{teamId}', team_id) + api_path = api_path.replace('{membershipId}', membership_id) + + api_params['userId'] = user_id + api_params['secret'] = secret + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def get_prefs(self, team_id: str) -> Dict[str, Any]: + """ + Get the team's shared preferences by its unique ID. If a preference doesn't need to be shared by all team members, prefer storing them in [user preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs). + + + Parameters + ---------- + team_id : str + Team ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/teams/{teamId}/prefs' + api_params = {} + if team_id is None: + raise AppwriteException('Missing required parameter: "team_id"') + + api_path = api_path.replace('{teamId}', team_id) + + + return self.client.call('get', api_path, { + }, api_params) + + def update_prefs(self, team_id: str, prefs: dict) -> Dict[str, Any]: + """ + Update the team's preferences by its unique ID. The object you pass is stored as is and replaces any previous value. The maximum allowed prefs size is 64kB and throws an error if exceeded. + + + Parameters + ---------- + team_id : str + Team ID. + prefs : dict + Prefs key-value JSON object. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/teams/{teamId}/prefs' + api_params = {} + if team_id is None: + raise AppwriteException('Missing required parameter: "team_id"') + + if prefs is None: + raise AppwriteException('Missing required parameter: "prefs"') - if user_id is not None: - params['userId'] = user_id + api_path = api_path.replace('{teamId}', team_id) - if secret is not None: - params['secret'] = secret + api_params['prefs'] = prefs - return self.client.call('patch', path, { + return self.client.call('put', api_path, { 'content-type': 'application/json', - }, params) + }, api_params) diff --git a/appwrite/services/tokens.py b/appwrite/services/tokens.py new file mode 100644 index 0000000..93ba739 --- /dev/null +++ b/appwrite/services/tokens.py @@ -0,0 +1,192 @@ +from ..service import Service +from typing import List, Dict, Any +from ..exception import AppwriteException + +class Tokens(Service): + + def __init__(self, client) -> None: + super(Tokens, self).__init__(client) + + def list(self, bucket_id: str, file_id: str, queries: List[str] = None) -> Dict[str, Any]: + """ + List all the tokens created for a specific file or bucket. You can use the query params to filter your results. + + + Parameters + ---------- + bucket_id : str + Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + file_id : str + File unique ID. + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: expire + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/tokens/buckets/{bucketId}/files/{fileId}' + api_params = {} + if bucket_id is None: + raise AppwriteException('Missing required parameter: "bucket_id"') + + if file_id is None: + raise AppwriteException('Missing required parameter: "file_id"') + + api_path = api_path.replace('{bucketId}', bucket_id) + api_path = api_path.replace('{fileId}', file_id) + + api_params['queries'] = queries + + return self.client.call('get', api_path, { + }, api_params) + + def create_file_token(self, bucket_id: str, file_id: str, expire: str = None) -> Dict[str, Any]: + """ + Create a new token. A token is linked to a file. Token can be passed as a request URL search parameter. + + + Parameters + ---------- + bucket_id : str + Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + file_id : str + File unique ID. + expire : str + Token expiry date + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/tokens/buckets/{bucketId}/files/{fileId}' + api_params = {} + if bucket_id is None: + raise AppwriteException('Missing required parameter: "bucket_id"') + + if file_id is None: + raise AppwriteException('Missing required parameter: "file_id"') + + api_path = api_path.replace('{bucketId}', bucket_id) + api_path = api_path.replace('{fileId}', file_id) + + api_params['expire'] = expire + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def get(self, token_id: str) -> Dict[str, Any]: + """ + Get a token by its unique ID. + + + Parameters + ---------- + token_id : str + Token ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/tokens/{tokenId}' + api_params = {} + if token_id is None: + raise AppwriteException('Missing required parameter: "token_id"') + + api_path = api_path.replace('{tokenId}', token_id) + + + return self.client.call('get', api_path, { + }, api_params) + + def update(self, token_id: str, expire: str = None) -> Dict[str, Any]: + """ + Update a token by its unique ID. Use this endpoint to update a token's expiry date. + + + Parameters + ---------- + token_id : str + Token unique ID. + expire : str + File token expiry date + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/tokens/{tokenId}' + api_params = {} + if token_id is None: + raise AppwriteException('Missing required parameter: "token_id"') + + api_path = api_path.replace('{tokenId}', token_id) + + api_params['expire'] = expire + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def delete(self, token_id: str) -> Dict[str, Any]: + """ + Delete a token by its unique ID. + + + Parameters + ---------- + token_id : str + Token ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/tokens/{tokenId}' + api_params = {} + if token_id is None: + raise AppwriteException('Missing required parameter: "token_id"') + + api_path = api_path.replace('{tokenId}', token_id) + + + return self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) diff --git a/appwrite/services/users.py b/appwrite/services/users.py index d1e501c..1af4e41 100644 --- a/appwrite/services/users.py +++ b/appwrite/services/users.py @@ -1,294 +1,1706 @@ from ..service import Service +from typing import List, Dict, Any from ..exception import AppwriteException +from ..enums.password_hash import PasswordHash; +from ..enums.authenticator_type import AuthenticatorType; +from ..enums.messaging_provider_type import MessagingProviderType; class Users(Service): - def __init__(self, client): + def __init__(self, client) -> None: super(Users, self).__init__(client) - def list(self, search = None, limit = None, offset = None, cursor = None, cursor_direction = None, order_type = None): - """List Users""" + def list(self, queries: List[str] = None, search: str = None) -> Dict[str, Any]: + """ + Get a list of all the project's users. You can use the query params to filter your results. + + + Parameters + ---------- + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, labels + search : str + Search term to filter your list results. Max length: 256 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users' + api_params = {} + + api_params['queries'] = queries + api_params['search'] = search + + return self.client.call('get', api_path, { + }, api_params) + + def create(self, user_id: str, email: str = None, phone: str = None, password: str = None, name: str = None) -> Dict[str, Any]: + """ + Create a new user. + + + Parameters + ---------- + user_id : str + User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + email : str + User email. + phone : str + Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + password : str + Plain text user password. Must be at least 8 chars. + name : str + User name. Max length: 128 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') - params = {} - path = '/users' - if search is not None: - params['search'] = search + api_params['userId'] = user_id + api_params['email'] = email + api_params['phone'] = phone + api_params['password'] = password + api_params['name'] = name - if limit is not None: - params['limit'] = limit + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_argon2_user(self, user_id: str, email: str, password: str, name: str = None) -> Dict[str, Any]: + """ + Create a new user. Password provided must be hashed with the [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. + + + Parameters + ---------- + user_id : str + User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + email : str + User email. + password : str + User password hashed using Argon2. + name : str + User name. Max length: 128 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/argon2' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') - if offset is not None: - params['offset'] = offset + if email is None: + raise AppwriteException('Missing required parameter: "email"') - if cursor is not None: - params['cursor'] = cursor + if password is None: + raise AppwriteException('Missing required parameter: "password"') - if cursor_direction is not None: - params['cursorDirection'] = cursor_direction - if order_type is not None: - params['orderType'] = order_type + api_params['userId'] = user_id + api_params['email'] = email + api_params['password'] = password + api_params['name'] = name - return self.client.call('get', path, { + return self.client.call('post', api_path, { 'content-type': 'application/json', - }, params) + }, api_params) + + def create_bcrypt_user(self, user_id: str, email: str, password: str, name: str = None) -> Dict[str, Any]: + """ + Create a new user. Password provided must be hashed with the [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. + + + Parameters + ---------- + user_id : str + User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + email : str + User email. + password : str + User password hashed using Bcrypt. + name : str + User name. Max length: 128 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/bcrypt' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') + + if email is None: + raise AppwriteException('Missing required parameter: "email"') - def create(self, user_id, email, password, name = None): - """Create User""" + if password is None: + raise AppwriteException('Missing required parameter: "password"') - if user_id is None: + + api_params['userId'] = user_id + api_params['email'] = email + api_params['password'] = password + api_params['name'] = name + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def list_identities(self, queries: List[str] = None, search: str = None) -> Dict[str, Any]: + """ + Get identities for all users. + + + Parameters + ---------- + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, provider, providerUid, providerEmail, providerAccessTokenExpiry + search : str + Search term to filter your list results. Max length: 256 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/identities' + api_params = {} + + api_params['queries'] = queries + api_params['search'] = search + + return self.client.call('get', api_path, { + }, api_params) + + def delete_identity(self, identity_id: str) -> Dict[str, Any]: + """ + Delete an identity by its unique ID. + + + Parameters + ---------- + identity_id : str + Identity ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/identities/{identityId}' + api_params = {} + if identity_id is None: + raise AppwriteException('Missing required parameter: "identity_id"') + + api_path = api_path.replace('{identityId}', identity_id) + + + return self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_md5_user(self, user_id: str, email: str, password: str, name: str = None) -> Dict[str, Any]: + """ + Create a new user. Password provided must be hashed with the [MD5](https://en.wikipedia.org/wiki/MD5) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. + + + Parameters + ---------- + user_id : str + User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + email : str + User email. + password : str + User password hashed using MD5. + name : str + User name. Max length: 128 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/md5' + api_params = {} + if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') - if email is None: + if email is None: raise AppwriteException('Missing required parameter: "email"') - if password is None: + if password is None: raise AppwriteException('Missing required parameter: "password"') - params = {} - path = '/users' - if user_id is not None: - params['userId'] = user_id + api_params['userId'] = user_id + api_params['email'] = email + api_params['password'] = password + api_params['name'] = name + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_ph_pass_user(self, user_id: str, email: str, password: str, name: str = None) -> Dict[str, Any]: + """ + Create a new user. Password provided must be hashed with the [PHPass](https://www.openwall.com/phpass/) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. + + + Parameters + ---------- + user_id : str + User ID. Choose a custom ID or pass the string `ID.unique()`to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + email : str + User email. + password : str + User password hashed using PHPass. + name : str + User name. Max length: 128 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/phpass' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') + + if email is None: + raise AppwriteException('Missing required parameter: "email"') - if email is not None: - params['email'] = email + if password is None: + raise AppwriteException('Missing required parameter: "password"') - if password is not None: - params['password'] = password - if name is not None: - params['name'] = name + api_params['userId'] = user_id + api_params['email'] = email + api_params['password'] = password + api_params['name'] = name - return self.client.call('post', path, { + return self.client.call('post', api_path, { 'content-type': 'application/json', - }, params) + }, api_params) + + def create_scrypt_user(self, user_id: str, email: str, password: str, password_salt: str, password_cpu: float, password_memory: float, password_parallel: float, password_length: float, name: str = None) -> Dict[str, Any]: + """ + Create a new user. Password provided must be hashed with the [Scrypt](https://github.com/Tarsnap/scrypt) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. + + + Parameters + ---------- + user_id : str + User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + email : str + User email. + password : str + User password hashed using Scrypt. + password_salt : str + Optional salt used to hash password. + password_cpu : float + Optional CPU cost used to hash password. + password_memory : float + Optional memory cost used to hash password. + password_parallel : float + Optional parallelization cost used to hash password. + password_length : float + Optional hash length used to hash password. + name : str + User name. Max length: 128 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/scrypt' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') - def get(self, user_id): - """Get User""" + if email is None: + raise AppwriteException('Missing required parameter: "email"') - if user_id is None: - raise AppwriteException('Missing required parameter: "user_id"') + if password is None: + raise AppwriteException('Missing required parameter: "password"') + + if password_salt is None: + raise AppwriteException('Missing required parameter: "password_salt"') + + if password_cpu is None: + raise AppwriteException('Missing required parameter: "password_cpu"') + + if password_memory is None: + raise AppwriteException('Missing required parameter: "password_memory"') - params = {} - path = '/users/{userId}' - path = path.replace('{userId}', user_id) + if password_parallel is None: + raise AppwriteException('Missing required parameter: "password_parallel"') - return self.client.call('get', path, { + if password_length is None: + raise AppwriteException('Missing required parameter: "password_length"') + + + api_params['userId'] = user_id + api_params['email'] = email + api_params['password'] = password + api_params['passwordSalt'] = password_salt + api_params['passwordCpu'] = password_cpu + api_params['passwordMemory'] = password_memory + api_params['passwordParallel'] = password_parallel + api_params['passwordLength'] = password_length + api_params['name'] = name + + return self.client.call('post', api_path, { 'content-type': 'application/json', - }, params) + }, api_params) + + def create_scrypt_modified_user(self, user_id: str, email: str, password: str, password_salt: str, password_salt_separator: str, password_signer_key: str, name: str = None) -> Dict[str, Any]: + """ + Create a new user. Password provided must be hashed with the [Scrypt Modified](https://gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. + + + Parameters + ---------- + user_id : str + User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + email : str + User email. + password : str + User password hashed using Scrypt Modified. + password_salt : str + Salt used to hash password. + password_salt_separator : str + Salt separator used to hash password. + password_signer_key : str + Signer key used to hash password. + name : str + User name. Max length: 128 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/scrypt-modified' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') + + if email is None: + raise AppwriteException('Missing required parameter: "email"') + + if password is None: + raise AppwriteException('Missing required parameter: "password"') - def delete(self, user_id): - """Delete User""" + if password_salt is None: + raise AppwriteException('Missing required parameter: "password_salt"') - if user_id is None: + if password_salt_separator is None: + raise AppwriteException('Missing required parameter: "password_salt_separator"') + + if password_signer_key is None: + raise AppwriteException('Missing required parameter: "password_signer_key"') + + + api_params['userId'] = user_id + api_params['email'] = email + api_params['password'] = password + api_params['passwordSalt'] = password_salt + api_params['passwordSaltSeparator'] = password_salt_separator + api_params['passwordSignerKey'] = password_signer_key + api_params['name'] = name + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_sha_user(self, user_id: str, email: str, password: str, password_version: PasswordHash = None, name: str = None) -> Dict[str, Any]: + """ + Create a new user. Password provided must be hashed with the [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. + + + Parameters + ---------- + user_id : str + User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + email : str + User email. + password : str + User password hashed using SHA. + password_version : PasswordHash + Optional SHA version used to hash password. Allowed values are: 'sha1', 'sha224', 'sha256', 'sha384', 'sha512/224', 'sha512/256', 'sha512', 'sha3-224', 'sha3-256', 'sha3-384', 'sha3-512' + name : str + User name. Max length: 128 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/sha' + api_params = {} + if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') - params = {} - path = '/users/{userId}' - path = path.replace('{userId}', user_id) + if email is None: + raise AppwriteException('Missing required parameter: "email"') + + if password is None: + raise AppwriteException('Missing required parameter: "password"') + - return self.client.call('delete', path, { + api_params['userId'] = user_id + api_params['email'] = email + api_params['password'] = password + api_params['passwordVersion'] = password_version + api_params['name'] = name + + return self.client.call('post', api_path, { 'content-type': 'application/json', - }, params) + }, api_params) + + def get(self, user_id: str) -> Dict[str, Any]: + """ + Get a user by its unique ID. + + + Parameters + ---------- + user_id : str + User ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/{userId}' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') + + api_path = api_path.replace('{userId}', user_id) + + + return self.client.call('get', api_path, { + }, api_params) + + def delete(self, user_id: str) -> Dict[str, Any]: + """ + Delete a user by its unique ID, thereby releasing it's ID. Since ID is released and can be reused, all user-related resources like documents or storage files should be deleted before user deletion. If you want to keep ID reserved, use the [updateStatus](https://appwrite.io/docs/server/users#usersUpdateStatus) endpoint instead. + + + Parameters + ---------- + user_id : str + User ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/{userId}' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') + + api_path = api_path.replace('{userId}', user_id) - def update_email(self, user_id, email): - """Update Email""" - if user_id is None: + return self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_email(self, user_id: str, email: str) -> Dict[str, Any]: + """ + Update the user email by its unique ID. + + + Parameters + ---------- + user_id : str + User ID. + email : str + User email. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/{userId}/email' + api_params = {} + if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') - if email is None: + if email is None: raise AppwriteException('Missing required parameter: "email"') - params = {} - path = '/users/{userId}/email' - path = path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', user_id) - if email is not None: - params['email'] = email + api_params['email'] = email - return self.client.call('patch', path, { + return self.client.call('patch', api_path, { 'content-type': 'application/json', - }, params) + }, api_params) + + def create_jwt(self, user_id: str, session_id: str = None, duration: float = None) -> Dict[str, Any]: + """ + Use this endpoint to create a JSON Web Token for user by its unique ID. You can use the resulting JWT to authenticate on behalf of the user. The JWT secret will become invalid if the session it uses gets deleted. + + + Parameters + ---------- + user_id : str + User ID. + session_id : str + Session ID. Use the string 'recent' to use the most recent session. Defaults to the most recent session. + duration : float + Time in seconds before JWT expires. Default duration is 900 seconds, and maximum is 3600 seconds. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/{userId}/jwts' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') - def get_logs(self, user_id, limit = None, offset = None): - """Get User Logs""" + api_path = api_path.replace('{userId}', user_id) - if user_id is None: + api_params['sessionId'] = session_id + api_params['duration'] = duration + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_labels(self, user_id: str, labels: List[str]) -> Dict[str, Any]: + """ + Update the user labels by its unique ID. + + Labels can be used to grant access to resources. While teams are a way for user's to share access to a resource, labels can be defined by the developer to grant access without an invitation. See the [Permissions docs](https://appwrite.io/docs/permissions) for more info. + + + Parameters + ---------- + user_id : str + User ID. + labels : List[str] + Array of user labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/{userId}/labels' + api_params = {} + if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') - params = {} - path = '/users/{userId}/logs' - path = path.replace('{userId}', user_id) + if labels is None: + raise AppwriteException('Missing required parameter: "labels"') - if limit is not None: - params['limit'] = limit + api_path = api_path.replace('{userId}', user_id) - if offset is not None: - params['offset'] = offset + api_params['labels'] = labels - return self.client.call('get', path, { + return self.client.call('put', api_path, { 'content-type': 'application/json', - }, params) + }, api_params) + + def list_logs(self, user_id: str, queries: List[str] = None) -> Dict[str, Any]: + """ + Get the user activity logs list by its unique ID. + + + Parameters + ---------- + user_id : str + User ID. + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/{userId}/logs' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') - def update_name(self, user_id, name): - """Update Name""" + api_path = api_path.replace('{userId}', user_id) + + api_params['queries'] = queries + + return self.client.call('get', api_path, { + }, api_params) + + def list_memberships(self, user_id: str, queries: List[str] = None, search: str = None) -> Dict[str, Any]: + """ + Get the user membership list by its unique ID. + + + Parameters + ---------- + user_id : str + User ID. + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, teamId, invited, joined, confirm, roles + search : str + Search term to filter your list results. Max length: 256 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/{userId}/memberships' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') - if user_id is None: + api_path = api_path.replace('{userId}', user_id) + + api_params['queries'] = queries + api_params['search'] = search + + return self.client.call('get', api_path, { + }, api_params) + + def update_mfa(self, user_id: str, mfa: bool) -> Dict[str, Any]: + """ + Enable or disable MFA on a user account. + + + Parameters + ---------- + user_id : str + User ID. + mfa : bool + Enable or disable MFA. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/{userId}/mfa' + api_params = {} + if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') - if name is None: - raise AppwriteException('Missing required parameter: "name"') + if mfa is None: + raise AppwriteException('Missing required parameter: "mfa"') - params = {} - path = '/users/{userId}/name' - path = path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', user_id) - if name is not None: - params['name'] = name + api_params['mfa'] = mfa - return self.client.call('patch', path, { + return self.client.call('patch', api_path, { 'content-type': 'application/json', - }, params) + }, api_params) + + def delete_mfa_authenticator(self, user_id: str, type: AuthenticatorType) -> Dict[str, Any]: + """ + Delete an authenticator app. + + + Parameters + ---------- + user_id : str + User ID. + type : AuthenticatorType + Type of authenticator. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/{userId}/mfa/authenticators/{type}' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') + + if type is None: + raise AppwriteException('Missing required parameter: "type"') + + api_path = api_path.replace('{userId}', user_id) + api_path = api_path.replace('{type}', type) - def update_password(self, user_id, password): - """Update Password""" - if user_id is None: + return self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + def list_mfa_factors(self, user_id: str) -> Dict[str, Any]: + """ + List the factors available on the account to be used as a MFA challange. + + + Parameters + ---------- + user_id : str + User ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/{userId}/mfa/factors' + api_params = {} + if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') - if password is None: - raise AppwriteException('Missing required parameter: "password"') + api_path = api_path.replace('{userId}', user_id) - params = {} - path = '/users/{userId}/password' - path = path.replace('{userId}', user_id) - if password is not None: - params['password'] = password + return self.client.call('get', api_path, { + }, api_params) + + def get_mfa_recovery_codes(self, user_id: str) -> Dict[str, Any]: + """ + Get recovery codes that can be used as backup for MFA flow by User ID. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. - return self.client.call('patch', path, { - 'content-type': 'application/json', - }, params) - def get_prefs(self, user_id): - """Get User Preferences""" + Parameters + ---------- + user_id : str + User ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ - if user_id is None: + api_path = '/users/{userId}/mfa/recovery-codes' + api_params = {} + if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') - params = {} - path = '/users/{userId}/prefs' - path = path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', user_id) - return self.client.call('get', path, { + + return self.client.call('get', api_path, { + }, api_params) + + def update_mfa_recovery_codes(self, user_id: str) -> Dict[str, Any]: + """ + Regenerate recovery codes that can be used as backup for MFA flow by User ID. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. + + + Parameters + ---------- + user_id : str + User ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/{userId}/mfa/recovery-codes' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') + + api_path = api_path.replace('{userId}', user_id) + + + return self.client.call('put', api_path, { 'content-type': 'application/json', - }, params) + }, api_params) + + def create_mfa_recovery_codes(self, user_id: str) -> Dict[str, Any]: + """ + Generate recovery codes used as backup for MFA flow for User ID. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method by client SDK. + + + Parameters + ---------- + user_id : str + User ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/{userId}/mfa/recovery-codes' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') + + api_path = api_path.replace('{userId}', user_id) - def update_prefs(self, user_id, prefs): - """Update User Preferences""" - if user_id is None: + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_name(self, user_id: str, name: str) -> Dict[str, Any]: + """ + Update the user name by its unique ID. + + + Parameters + ---------- + user_id : str + User ID. + name : str + User name. Max length: 128 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/{userId}/name' + api_params = {} + if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') - if prefs is None: - raise AppwriteException('Missing required parameter: "prefs"') + if name is None: + raise AppwriteException('Missing required parameter: "name"') - params = {} - path = '/users/{userId}/prefs' - path = path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', user_id) - if prefs is not None: - params['prefs'] = prefs + api_params['name'] = name - return self.client.call('patch', path, { + return self.client.call('patch', api_path, { 'content-type': 'application/json', - }, params) + }, api_params) + + def update_password(self, user_id: str, password: str) -> Dict[str, Any]: + """ + Update the user password by its unique ID. + + + Parameters + ---------- + user_id : str + User ID. + password : str + New user password. Must be at least 8 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/{userId}/password' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') + + if password is None: + raise AppwriteException('Missing required parameter: "password"') - def get_sessions(self, user_id): - """Get User Sessions""" + api_path = api_path.replace('{userId}', user_id) - if user_id is None: + api_params['password'] = password + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_phone(self, user_id: str, number: str) -> Dict[str, Any]: + """ + Update the user phone by its unique ID. + + + Parameters + ---------- + user_id : str + User ID. + number : str + User phone number. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/{userId}/phone' + api_params = {} + if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') - params = {} - path = '/users/{userId}/sessions' - path = path.replace('{userId}', user_id) + if number is None: + raise AppwriteException('Missing required parameter: "number"') + + api_path = api_path.replace('{userId}', user_id) - return self.client.call('get', path, { + api_params['number'] = number + + return self.client.call('patch', api_path, { 'content-type': 'application/json', - }, params) + }, api_params) + + def get_prefs(self, user_id: str) -> Dict[str, Any]: + """ + Get the user preferences by its unique ID. + + + Parameters + ---------- + user_id : str + User ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/{userId}/prefs' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') + + api_path = api_path.replace('{userId}', user_id) + + + return self.client.call('get', api_path, { + }, api_params) + + def update_prefs(self, user_id: str, prefs: dict) -> Dict[str, Any]: + """ + Update the user preferences by its unique ID. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded. + + + Parameters + ---------- + user_id : str + User ID. + prefs : dict + Prefs key-value JSON object. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/{userId}/prefs' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') + + if prefs is None: + raise AppwriteException('Missing required parameter: "prefs"') - def delete_sessions(self, user_id): - """Delete User Sessions""" + api_path = api_path.replace('{userId}', user_id) - if user_id is None: + api_params['prefs'] = prefs + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def list_sessions(self, user_id: str) -> Dict[str, Any]: + """ + Get the user sessions list by its unique ID. + + + Parameters + ---------- + user_id : str + User ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/{userId}/sessions' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') + + api_path = api_path.replace('{userId}', user_id) + + + return self.client.call('get', api_path, { + }, api_params) + + def create_session(self, user_id: str) -> Dict[str, Any]: + """ + Creates a session for a user. Returns an immediately usable session object. + + If you want to generate a token for a custom authentication flow, use the [POST /users/{userId}/tokens](https://appwrite.io/docs/server/users#createToken) endpoint. + + + Parameters + ---------- + user_id : str + User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/{userId}/sessions' + api_params = {} + if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') - params = {} - path = '/users/{userId}/sessions' - path = path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', user_id) - return self.client.call('delete', path, { + + return self.client.call('post', api_path, { 'content-type': 'application/json', - }, params) + }, api_params) + + def delete_sessions(self, user_id: str) -> Dict[str, Any]: + """ + Delete all user's sessions by using the user's unique ID. + + + Parameters + ---------- + user_id : str + User ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/{userId}/sessions' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') - def delete_session(self, user_id, session_id): - """Delete User Session""" + api_path = api_path.replace('{userId}', user_id) - if user_id is None: + + return self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + def delete_session(self, user_id: str, session_id: str) -> Dict[str, Any]: + """ + Delete a user sessions by its unique ID. + + + Parameters + ---------- + user_id : str + User ID. + session_id : str + Session ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/{userId}/sessions/{sessionId}' + api_params = {} + if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') - if session_id is None: + if session_id is None: raise AppwriteException('Missing required parameter: "session_id"') - params = {} - path = '/users/{userId}/sessions/{sessionId}' - path = path.replace('{userId}', user_id) - path = path.replace('{sessionId}', session_id) + api_path = api_path.replace('{userId}', user_id) + api_path = api_path.replace('{sessionId}', session_id) - return self.client.call('delete', path, { + + return self.client.call('delete', api_path, { 'content-type': 'application/json', - }, params) + }, api_params) + + def update_status(self, user_id: str, status: bool) -> Dict[str, Any]: + """ + Update the user status by its unique ID. Use this endpoint as an alternative to deleting a user if you want to keep user's ID reserved. + + + Parameters + ---------- + user_id : str + User ID. + status : bool + User Status. To activate the user pass `true` and to block the user pass `false`. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/{userId}/status' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') + + if status is None: + raise AppwriteException('Missing required parameter: "status"') + + api_path = api_path.replace('{userId}', user_id) - def update_status(self, user_id, status): - """Update User Status""" + api_params['status'] = status - if user_id is None: + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def list_targets(self, user_id: str, queries: List[str] = None) -> Dict[str, Any]: + """ + List the messaging targets that are associated with a user. + + + Parameters + ---------- + user_id : str + User ID. + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, providerId, identifier, providerType + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/{userId}/targets' + api_params = {} + if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') - if status is None: - raise AppwriteException('Missing required parameter: "status"') + api_path = api_path.replace('{userId}', user_id) + + api_params['queries'] = queries + + return self.client.call('get', api_path, { + }, api_params) + + def create_target(self, user_id: str, target_id: str, provider_type: MessagingProviderType, identifier: str, provider_id: str = None, name: str = None) -> Dict[str, Any]: + """ + Create a messaging target. + + + Parameters + ---------- + user_id : str + User ID. + target_id : str + Target ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + provider_type : MessagingProviderType + The target provider type. Can be one of the following: `email`, `sms` or `push`. + identifier : str + The target identifier (token, email, phone etc.) + provider_id : str + Provider ID. Message will be sent to this target from the specified provider ID. If no provider ID is set the first setup provider will be used. + name : str + Target name. Max length: 128 chars. For example: My Awesome App Galaxy S23. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/{userId}/targets' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') + + if target_id is None: + raise AppwriteException('Missing required parameter: "target_id"') + + if provider_type is None: + raise AppwriteException('Missing required parameter: "provider_type"') + + if identifier is None: + raise AppwriteException('Missing required parameter: "identifier"') + + api_path = api_path.replace('{userId}', user_id) + + api_params['targetId'] = target_id + api_params['providerType'] = provider_type + api_params['identifier'] = identifier + api_params['providerId'] = provider_id + api_params['name'] = name + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def get_target(self, user_id: str, target_id: str) -> Dict[str, Any]: + """ + Get a user's push notification target by ID. + + + Parameters + ---------- + user_id : str + User ID. + target_id : str + Target ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/{userId}/targets/{targetId}' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') + + if target_id is None: + raise AppwriteException('Missing required parameter: "target_id"') + + api_path = api_path.replace('{userId}', user_id) + api_path = api_path.replace('{targetId}', target_id) + + + return self.client.call('get', api_path, { + }, api_params) + + def update_target(self, user_id: str, target_id: str, identifier: str = None, provider_id: str = None, name: str = None) -> Dict[str, Any]: + """ + Update a messaging target. + + + Parameters + ---------- + user_id : str + User ID. + target_id : str + Target ID. + identifier : str + The target identifier (token, email, phone etc.) + provider_id : str + Provider ID. Message will be sent to this target from the specified provider ID. If no provider ID is set the first setup provider will be used. + name : str + Target name. Max length: 128 chars. For example: My Awesome App Galaxy S23. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/{userId}/targets/{targetId}' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') + + if target_id is None: + raise AppwriteException('Missing required parameter: "target_id"') - params = {} - path = '/users/{userId}/status' - path = path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', user_id) + api_path = api_path.replace('{targetId}', target_id) - if status is not None: - params['status'] = status + api_params['identifier'] = identifier + api_params['providerId'] = provider_id + api_params['name'] = name - return self.client.call('patch', path, { + return self.client.call('patch', api_path, { 'content-type': 'application/json', - }, params) + }, api_params) + + def delete_target(self, user_id: str, target_id: str) -> Dict[str, Any]: + """ + Delete a messaging target. + + + Parameters + ---------- + user_id : str + User ID. + target_id : str + Target ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/{userId}/targets/{targetId}' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') + + if target_id is None: + raise AppwriteException('Missing required parameter: "target_id"') + + api_path = api_path.replace('{userId}', user_id) + api_path = api_path.replace('{targetId}', target_id) - def update_verification(self, user_id, email_verification): - """Update Email Verification""" - if user_id is None: + return self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_token(self, user_id: str, length: float = None, expire: float = None) -> Dict[str, Any]: + """ + Returns a token with a secret key for creating a session. Use the user ID and secret and submit a request to the [PUT /account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. + + + + Parameters + ---------- + user_id : str + User ID. + length : float + Token length in characters. The default length is 6 characters + expire : float + Token expiration period in seconds. The default expiration is 15 minutes. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/{userId}/tokens' + api_params = {} + if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') - if email_verification is None: + api_path = api_path.replace('{userId}', user_id) + + api_params['length'] = length + api_params['expire'] = expire + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_email_verification(self, user_id: str, email_verification: bool) -> Dict[str, Any]: + """ + Update the user email verification status by its unique ID. + + + Parameters + ---------- + user_id : str + User ID. + email_verification : bool + User email verification status. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/{userId}/verification' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') + + if email_verification is None: raise AppwriteException('Missing required parameter: "email_verification"') - params = {} - path = '/users/{userId}/verification' - path = path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', user_id) + + api_params['emailVerification'] = email_verification + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_phone_verification(self, user_id: str, phone_verification: bool) -> Dict[str, Any]: + """ + Update the user phone verification status by its unique ID. + + + Parameters + ---------- + user_id : str + User ID. + phone_verification : bool + User phone verification status. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/{userId}/verification/phone' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') + + if phone_verification is None: + raise AppwriteException('Missing required parameter: "phone_verification"') + + api_path = api_path.replace('{userId}', user_id) - if email_verification is not None: - params['emailVerification'] = email_verification + api_params['phoneVerification'] = phone_verification - return self.client.call('patch', path, { + return self.client.call('patch', api_path, { 'content-type': 'application/json', - }, params) + }, api_params) diff --git a/docs/examples/account/create-anonymous-session.md b/docs/examples/account/create-anonymous-session.md new file mode 100644 index 0000000..c3b7a87 --- /dev/null +++ b/docs/examples/account/create-anonymous-session.md @@ -0,0 +1,10 @@ +from appwrite.client import Client +from appwrite.services.account import Account + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID + +account = Account(client) + +result = account.create_anonymous_session() diff --git a/docs/examples/account/create-email-password-session.md b/docs/examples/account/create-email-password-session.md new file mode 100644 index 0000000..e831821 --- /dev/null +++ b/docs/examples/account/create-email-password-session.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.account import Account + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID + +account = Account(client) + +result = account.create_email_password_session( + email = 'email@example.com', + password = 'password' +) diff --git a/docs/examples/account/create-email-token.md b/docs/examples/account/create-email-token.md new file mode 100644 index 0000000..7ff4f6b --- /dev/null +++ b/docs/examples/account/create-email-token.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.account import Account + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID + +account = Account(client) + +result = account.create_email_token( + user_id = '', + email = 'email@example.com', + phrase = False # optional +) diff --git a/docs/examples/account/create-j-w-t.md b/docs/examples/account/create-j-w-t.md new file mode 100644 index 0000000..172f45f --- /dev/null +++ b/docs/examples/account/create-j-w-t.md @@ -0,0 +1,10 @@ +from appwrite.client import Client +from appwrite.services.account import Account + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID + +account = Account(client) + +result = account.create_jwt() diff --git a/docs/examples/account/create-magic-u-r-l-token.md b/docs/examples/account/create-magic-u-r-l-token.md new file mode 100644 index 0000000..14e76ed --- /dev/null +++ b/docs/examples/account/create-magic-u-r-l-token.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.account import Account + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID + +account = Account(client) + +result = account.create_magic_url_token( + user_id = '', + email = 'email@example.com', + url = 'https://example.com', # optional + phrase = False # optional +) diff --git a/docs/examples/account/create-mfa-authenticator.md b/docs/examples/account/create-mfa-authenticator.md new file mode 100644 index 0000000..70cee1d --- /dev/null +++ b/docs/examples/account/create-mfa-authenticator.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.account import Account +from appwrite.enums import AuthenticatorType + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +account = Account(client) + +result = account.create_mfa_authenticator( + type = AuthenticatorType.TOTP +) diff --git a/docs/examples/account/create-mfa-challenge.md b/docs/examples/account/create-mfa-challenge.md new file mode 100644 index 0000000..abd746c --- /dev/null +++ b/docs/examples/account/create-mfa-challenge.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.account import Account +from appwrite.enums import AuthenticationFactor + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID + +account = Account(client) + +result = account.create_mfa_challenge( + factor = AuthenticationFactor.EMAIL +) diff --git a/docs/examples/account/create-mfa-recovery-codes.md b/docs/examples/account/create-mfa-recovery-codes.md new file mode 100644 index 0000000..69aaa60 --- /dev/null +++ b/docs/examples/account/create-mfa-recovery-codes.md @@ -0,0 +1,11 @@ +from appwrite.client import Client +from appwrite.services.account import Account + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +account = Account(client) + +result = account.create_mfa_recovery_codes() diff --git a/docs/examples/account/create-o-auth2token.md b/docs/examples/account/create-o-auth2token.md new file mode 100644 index 0000000..2dc171b --- /dev/null +++ b/docs/examples/account/create-o-auth2token.md @@ -0,0 +1,16 @@ +from appwrite.client import Client +from appwrite.services.account import Account +from appwrite.enums import OAuthProvider + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID + +account = Account(client) + +result = account.create_o_auth2_token( + provider = OAuthProvider.AMAZON, + success = 'https://example.com', # optional + failure = 'https://example.com', # optional + scopes = [] # optional +) diff --git a/docs/examples/account/create-phone-token.md b/docs/examples/account/create-phone-token.md new file mode 100644 index 0000000..06c2b20 --- /dev/null +++ b/docs/examples/account/create-phone-token.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.account import Account + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID + +account = Account(client) + +result = account.create_phone_token( + user_id = '', + phone = '+12065550100' +) diff --git a/docs/examples/account/create-phone-verification.md b/docs/examples/account/create-phone-verification.md new file mode 100644 index 0000000..c130646 --- /dev/null +++ b/docs/examples/account/create-phone-verification.md @@ -0,0 +1,11 @@ +from appwrite.client import Client +from appwrite.services.account import Account + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +account = Account(client) + +result = account.create_phone_verification() diff --git a/docs/examples/account/create-recovery.md b/docs/examples/account/create-recovery.md index 7102633..51c1777 100644 --- a/docs/examples/account/create-recovery.md +++ b/docs/examples/account/create-recovery.md @@ -2,13 +2,13 @@ from appwrite.client import Client from appwrite.services.account import Account client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_jwt('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with account = Account(client) -result = account.create_recovery('email@example.com', 'https://example.com') +result = account.create_recovery( + email = 'email@example.com', + url = 'https://example.com' +) diff --git a/docs/examples/account/create-session.md b/docs/examples/account/create-session.md new file mode 100644 index 0000000..1048dfe --- /dev/null +++ b/docs/examples/account/create-session.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.account import Account + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID + +account = Account(client) + +result = account.create_session( + user_id = '', + secret = '' +) diff --git a/docs/examples/account/create-verification.md b/docs/examples/account/create-verification.md index 53939ca..d66fc2c 100644 --- a/docs/examples/account/create-verification.md +++ b/docs/examples/account/create-verification.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.account import Account client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_jwt('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with account = Account(client) -result = account.create_verification('https://example.com') +result = account.create_verification( + url = 'https://example.com' +) diff --git a/docs/examples/account/create.md b/docs/examples/account/create.md new file mode 100644 index 0000000..7eda5a3 --- /dev/null +++ b/docs/examples/account/create.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.account import Account + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID + +account = Account(client) + +result = account.create( + user_id = '', + email = 'email@example.com', + password = '', + name = '' # optional +) diff --git a/docs/examples/account/delete-identity.md b/docs/examples/account/delete-identity.md new file mode 100644 index 0000000..0c894fa --- /dev/null +++ b/docs/examples/account/delete-identity.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.account import Account + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +account = Account(client) + +result = account.delete_identity( + identity_id = '' +) diff --git a/docs/examples/account/delete-mfa-authenticator.md b/docs/examples/account/delete-mfa-authenticator.md new file mode 100644 index 0000000..83709c7 --- /dev/null +++ b/docs/examples/account/delete-mfa-authenticator.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.account import Account +from appwrite.enums import AuthenticatorType + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +account = Account(client) + +result = account.delete_mfa_authenticator( + type = AuthenticatorType.TOTP +) diff --git a/docs/examples/account/delete-session.md b/docs/examples/account/delete-session.md index 940367d..5967d70 100644 --- a/docs/examples/account/delete-session.md +++ b/docs/examples/account/delete-session.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.account import Account client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_jwt('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with account = Account(client) -result = account.delete_session('[SESSION_ID]') +result = account.delete_session( + session_id = '' +) diff --git a/docs/examples/account/delete-sessions.md b/docs/examples/account/delete-sessions.md index 317dd04..5061f84 100644 --- a/docs/examples/account/delete-sessions.md +++ b/docs/examples/account/delete-sessions.md @@ -2,12 +2,9 @@ from appwrite.client import Client from appwrite.services.account import Account client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_jwt('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with account = Account(client) diff --git a/docs/examples/account/delete.md b/docs/examples/account/delete.md deleted file mode 100644 index 3ddc987..0000000 --- a/docs/examples/account/delete.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.account import Account - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_jwt('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token -) - -account = Account(client) - -result = account.delete() diff --git a/docs/examples/account/get-logs.md b/docs/examples/account/get-logs.md deleted file mode 100644 index 3ccddc4..0000000 --- a/docs/examples/account/get-logs.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.account import Account - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_jwt('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token -) - -account = Account(client) - -result = account.get_logs() diff --git a/docs/examples/account/get-mfa-recovery-codes.md b/docs/examples/account/get-mfa-recovery-codes.md new file mode 100644 index 0000000..c8fe494 --- /dev/null +++ b/docs/examples/account/get-mfa-recovery-codes.md @@ -0,0 +1,11 @@ +from appwrite.client import Client +from appwrite.services.account import Account + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +account = Account(client) + +result = account.get_mfa_recovery_codes() diff --git a/docs/examples/account/get-prefs.md b/docs/examples/account/get-prefs.md index 616b177..d577b4b 100644 --- a/docs/examples/account/get-prefs.md +++ b/docs/examples/account/get-prefs.md @@ -2,12 +2,9 @@ from appwrite.client import Client from appwrite.services.account import Account client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_jwt('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with account = Account(client) diff --git a/docs/examples/account/get-session.md b/docs/examples/account/get-session.md index 96fef2e..3e2937b 100644 --- a/docs/examples/account/get-session.md +++ b/docs/examples/account/get-session.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.account import Account client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_jwt('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with account = Account(client) -result = account.get_session('[SESSION_ID]') +result = account.get_session( + session_id = '' +) diff --git a/docs/examples/account/get-sessions.md b/docs/examples/account/get-sessions.md deleted file mode 100644 index d35dde2..0000000 --- a/docs/examples/account/get-sessions.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.account import Account - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_jwt('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token -) - -account = Account(client) - -result = account.get_sessions() diff --git a/docs/examples/account/get.md b/docs/examples/account/get.md index f561eb9..5426228 100644 --- a/docs/examples/account/get.md +++ b/docs/examples/account/get.md @@ -2,12 +2,9 @@ from appwrite.client import Client from appwrite.services.account import Account client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_jwt('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with account = Account(client) diff --git a/docs/examples/account/list-identities.md b/docs/examples/account/list-identities.md new file mode 100644 index 0000000..aeb23be --- /dev/null +++ b/docs/examples/account/list-identities.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.account import Account + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +account = Account(client) + +result = account.list_identities( + queries = [] # optional +) diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/list-logs.md new file mode 100644 index 0000000..67d193d --- /dev/null +++ b/docs/examples/account/list-logs.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.account import Account + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +account = Account(client) + +result = account.list_logs( + queries = [] # optional +) diff --git a/docs/examples/account/list-mfa-factors.md b/docs/examples/account/list-mfa-factors.md new file mode 100644 index 0000000..72a3924 --- /dev/null +++ b/docs/examples/account/list-mfa-factors.md @@ -0,0 +1,11 @@ +from appwrite.client import Client +from appwrite.services.account import Account + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +account = Account(client) + +result = account.list_mfa_factors() diff --git a/docs/examples/account/list-sessions.md b/docs/examples/account/list-sessions.md new file mode 100644 index 0000000..c553a7b --- /dev/null +++ b/docs/examples/account/list-sessions.md @@ -0,0 +1,11 @@ +from appwrite.client import Client +from appwrite.services.account import Account + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +account = Account(client) + +result = account.list_sessions() diff --git a/docs/examples/account/update-email.md b/docs/examples/account/update-email.md index d18eed4..14de4fd 100644 --- a/docs/examples/account/update-email.md +++ b/docs/examples/account/update-email.md @@ -2,13 +2,13 @@ from appwrite.client import Client from appwrite.services.account import Account client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_jwt('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with account = Account(client) -result = account.update_email('email@example.com', 'password') +result = account.update_email( + email = 'email@example.com', + password = 'password' +) diff --git a/docs/examples/account/update-m-f-a.md b/docs/examples/account/update-m-f-a.md new file mode 100644 index 0000000..7083d09 --- /dev/null +++ b/docs/examples/account/update-m-f-a.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.account import Account + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +account = Account(client) + +result = account.update_mfa( + mfa = False +) diff --git a/docs/examples/account/update-magic-u-r-l-session.md b/docs/examples/account/update-magic-u-r-l-session.md new file mode 100644 index 0000000..0146083 --- /dev/null +++ b/docs/examples/account/update-magic-u-r-l-session.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.account import Account + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID + +account = Account(client) + +result = account.update_magic_url_session( + user_id = '', + secret = '' +) diff --git a/docs/examples/account/update-mfa-authenticator.md b/docs/examples/account/update-mfa-authenticator.md new file mode 100644 index 0000000..d53607f --- /dev/null +++ b/docs/examples/account/update-mfa-authenticator.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.account import Account +from appwrite.enums import AuthenticatorType + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +account = Account(client) + +result = account.update_mfa_authenticator( + type = AuthenticatorType.TOTP, + otp = '' +) diff --git a/docs/examples/account/update-mfa-challenge.md b/docs/examples/account/update-mfa-challenge.md new file mode 100644 index 0000000..cfc58c5 --- /dev/null +++ b/docs/examples/account/update-mfa-challenge.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.account import Account + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +account = Account(client) + +result = account.update_mfa_challenge( + challenge_id = '', + otp = '' +) diff --git a/docs/examples/account/update-mfa-recovery-codes.md b/docs/examples/account/update-mfa-recovery-codes.md new file mode 100644 index 0000000..51718eb --- /dev/null +++ b/docs/examples/account/update-mfa-recovery-codes.md @@ -0,0 +1,11 @@ +from appwrite.client import Client +from appwrite.services.account import Account + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +account = Account(client) + +result = account.update_mfa_recovery_codes() diff --git a/docs/examples/account/update-name.md b/docs/examples/account/update-name.md index eec1453..534a94e 100644 --- a/docs/examples/account/update-name.md +++ b/docs/examples/account/update-name.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.account import Account client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_jwt('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with account = Account(client) -result = account.update_name('[NAME]') +result = account.update_name( + name = '' +) diff --git a/docs/examples/account/update-password.md b/docs/examples/account/update-password.md index 2e89031..3c072e3 100644 --- a/docs/examples/account/update-password.md +++ b/docs/examples/account/update-password.md @@ -2,13 +2,13 @@ from appwrite.client import Client from appwrite.services.account import Account client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_jwt('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with account = Account(client) -result = account.update_password('password') +result = account.update_password( + password = '', + old_password = 'password' # optional +) diff --git a/docs/examples/account/update-phone-session.md b/docs/examples/account/update-phone-session.md new file mode 100644 index 0000000..52e7723 --- /dev/null +++ b/docs/examples/account/update-phone-session.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.account import Account + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID + +account = Account(client) + +result = account.update_phone_session( + user_id = '', + secret = '' +) diff --git a/docs/examples/account/update-phone-verification.md b/docs/examples/account/update-phone-verification.md new file mode 100644 index 0000000..bcc57de --- /dev/null +++ b/docs/examples/account/update-phone-verification.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.account import Account + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +account = Account(client) + +result = account.update_phone_verification( + user_id = '', + secret = '' +) diff --git a/docs/examples/account/update-phone.md b/docs/examples/account/update-phone.md new file mode 100644 index 0000000..a2cb7d3 --- /dev/null +++ b/docs/examples/account/update-phone.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.account import Account + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +account = Account(client) + +result = account.update_phone( + phone = '+12065550100', + password = 'password' +) diff --git a/docs/examples/account/update-prefs.md b/docs/examples/account/update-prefs.md index 5bf6d74..e2ac7a2 100644 --- a/docs/examples/account/update-prefs.md +++ b/docs/examples/account/update-prefs.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.account import Account client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_jwt('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with account = Account(client) -result = account.update_prefs({}) +result = account.update_prefs( + prefs = {} +) diff --git a/docs/examples/account/update-recovery.md b/docs/examples/account/update-recovery.md index badc07d..ed140ab 100644 --- a/docs/examples/account/update-recovery.md +++ b/docs/examples/account/update-recovery.md @@ -2,13 +2,14 @@ from appwrite.client import Client from appwrite.services.account import Account client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_jwt('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with account = Account(client) -result = account.update_recovery('[USER_ID]', '[SECRET]', 'password', 'password') +result = account.update_recovery( + user_id = '', + secret = '', + password = '' +) diff --git a/docs/examples/account/update-session.md b/docs/examples/account/update-session.md new file mode 100644 index 0000000..abee773 --- /dev/null +++ b/docs/examples/account/update-session.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.account import Account + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +account = Account(client) + +result = account.update_session( + session_id = '' +) diff --git a/docs/examples/account/update-status.md b/docs/examples/account/update-status.md new file mode 100644 index 0000000..a5272f0 --- /dev/null +++ b/docs/examples/account/update-status.md @@ -0,0 +1,11 @@ +from appwrite.client import Client +from appwrite.services.account import Account + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +account = Account(client) + +result = account.update_status() diff --git a/docs/examples/account/update-verification.md b/docs/examples/account/update-verification.md index 02d0125..fbc7af5 100644 --- a/docs/examples/account/update-verification.md +++ b/docs/examples/account/update-verification.md @@ -2,13 +2,13 @@ from appwrite.client import Client from appwrite.services.account import Account client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_jwt('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with account = Account(client) -result = account.update_verification('[USER_ID]', '[SECRET]') +result = account.update_verification( + user_id = '', + secret = '' +) diff --git a/docs/examples/avatars/get-browser.md b/docs/examples/avatars/get-browser.md index 138c0d1..ff11b8b 100644 --- a/docs/examples/avatars/get-browser.md +++ b/docs/examples/avatars/get-browser.md @@ -1,14 +1,17 @@ from appwrite.client import Client from appwrite.services.avatars import Avatars +from appwrite.enums import Browser client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with avatars = Avatars(client) -result = avatars.get_browser('aa') +result = avatars.get_browser( + code = Browser.AVANT_BROWSER, + width = 0, # optional + height = 0, # optional + quality = -1 # optional +) diff --git a/docs/examples/avatars/get-credit-card.md b/docs/examples/avatars/get-credit-card.md index 83f76ac..286f4d3 100644 --- a/docs/examples/avatars/get-credit-card.md +++ b/docs/examples/avatars/get-credit-card.md @@ -1,14 +1,17 @@ from appwrite.client import Client from appwrite.services.avatars import Avatars +from appwrite.enums import CreditCard client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with avatars = Avatars(client) -result = avatars.get_credit_card('amex') +result = avatars.get_credit_card( + code = CreditCard.AMERICAN_EXPRESS, + width = 0, # optional + height = 0, # optional + quality = -1 # optional +) diff --git a/docs/examples/avatars/get-favicon.md b/docs/examples/avatars/get-favicon.md index 6946080..f034ea4 100644 --- a/docs/examples/avatars/get-favicon.md +++ b/docs/examples/avatars/get-favicon.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.avatars import Avatars client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with avatars = Avatars(client) -result = avatars.get_favicon('https://example.com') +result = avatars.get_favicon( + url = 'https://example.com' +) diff --git a/docs/examples/avatars/get-flag.md b/docs/examples/avatars/get-flag.md index 188d6d3..6365a78 100644 --- a/docs/examples/avatars/get-flag.md +++ b/docs/examples/avatars/get-flag.md @@ -1,14 +1,17 @@ from appwrite.client import Client from appwrite.services.avatars import Avatars +from appwrite.enums import Flag client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with avatars = Avatars(client) -result = avatars.get_flag('af') +result = avatars.get_flag( + code = Flag.AFGHANISTAN, + width = 0, # optional + height = 0, # optional + quality = -1 # optional +) diff --git a/docs/examples/avatars/get-image.md b/docs/examples/avatars/get-image.md index 29a6430..9272c4d 100644 --- a/docs/examples/avatars/get-image.md +++ b/docs/examples/avatars/get-image.md @@ -2,13 +2,14 @@ from appwrite.client import Client from appwrite.services.avatars import Avatars client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with avatars = Avatars(client) -result = avatars.get_image('https://example.com') +result = avatars.get_image( + url = 'https://example.com', + width = 0, # optional + height = 0 # optional +) diff --git a/docs/examples/avatars/get-initials.md b/docs/examples/avatars/get-initials.md index 0c300af..2729ff5 100644 --- a/docs/examples/avatars/get-initials.md +++ b/docs/examples/avatars/get-initials.md @@ -2,13 +2,15 @@ from appwrite.client import Client from appwrite.services.avatars import Avatars client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with avatars = Avatars(client) -result = avatars.get_initials() +result = avatars.get_initials( + name = '', # optional + width = 0, # optional + height = 0, # optional + background = '' # optional +) diff --git a/docs/examples/avatars/get-q-r.md b/docs/examples/avatars/get-q-r.md index 38378e9..3fb76a7 100644 --- a/docs/examples/avatars/get-q-r.md +++ b/docs/examples/avatars/get-q-r.md @@ -2,13 +2,15 @@ from appwrite.client import Client from appwrite.services.avatars import Avatars client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with avatars = Avatars(client) -result = avatars.get_qr('[TEXT]') +result = avatars.get_qr( + text = '', + size = 1, # optional + margin = 0, # optional + download = False # optional +) diff --git a/docs/examples/database/create-boolean-attribute.md b/docs/examples/database/create-boolean-attribute.md deleted file mode 100644 index ca3d549..0000000 --- a/docs/examples/database/create-boolean-attribute.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.database import Database - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -database = Database(client) - -result = database.create_boolean_attribute('[COLLECTION_ID]', '', False) diff --git a/docs/examples/database/create-collection.md b/docs/examples/database/create-collection.md deleted file mode 100644 index c1bf0b4..0000000 --- a/docs/examples/database/create-collection.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.database import Database - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -database = Database(client) - -result = database.create_collection('[COLLECTION_ID]', '[NAME]', 'document', ["role:all"], ["role:all"]) diff --git a/docs/examples/database/create-document.md b/docs/examples/database/create-document.md deleted file mode 100644 index 8cef31c..0000000 --- a/docs/examples/database/create-document.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.database import Database - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -database = Database(client) - -result = database.create_document('[COLLECTION_ID]', '[DOCUMENT_ID]', {}) diff --git a/docs/examples/database/create-email-attribute.md b/docs/examples/database/create-email-attribute.md deleted file mode 100644 index 339b4b7..0000000 --- a/docs/examples/database/create-email-attribute.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.database import Database - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -database = Database(client) - -result = database.create_email_attribute('[COLLECTION_ID]', '', False) diff --git a/docs/examples/database/create-enum-attribute.md b/docs/examples/database/create-enum-attribute.md deleted file mode 100644 index e9014ef..0000000 --- a/docs/examples/database/create-enum-attribute.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.database import Database - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -database = Database(client) - -result = database.create_enum_attribute('[COLLECTION_ID]', '', [], False) diff --git a/docs/examples/database/create-float-attribute.md b/docs/examples/database/create-float-attribute.md deleted file mode 100644 index 22d6ed3..0000000 --- a/docs/examples/database/create-float-attribute.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.database import Database - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -database = Database(client) - -result = database.create_float_attribute('[COLLECTION_ID]', '', False) diff --git a/docs/examples/database/create-index.md b/docs/examples/database/create-index.md deleted file mode 100644 index 7553e75..0000000 --- a/docs/examples/database/create-index.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.database import Database - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -database = Database(client) - -result = database.create_index('[COLLECTION_ID]', '', 'key', []) diff --git a/docs/examples/database/create-integer-attribute.md b/docs/examples/database/create-integer-attribute.md deleted file mode 100644 index 5b4ae60..0000000 --- a/docs/examples/database/create-integer-attribute.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.database import Database - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -database = Database(client) - -result = database.create_integer_attribute('[COLLECTION_ID]', '', False) diff --git a/docs/examples/database/create-ip-attribute.md b/docs/examples/database/create-ip-attribute.md deleted file mode 100644 index 6e79f0b..0000000 --- a/docs/examples/database/create-ip-attribute.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.database import Database - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -database = Database(client) - -result = database.create_ip_attribute('[COLLECTION_ID]', '', False) diff --git a/docs/examples/database/create-string-attribute.md b/docs/examples/database/create-string-attribute.md deleted file mode 100644 index 96f3410..0000000 --- a/docs/examples/database/create-string-attribute.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.database import Database - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -database = Database(client) - -result = database.create_string_attribute('[COLLECTION_ID]', '', 1, False) diff --git a/docs/examples/database/create-url-attribute.md b/docs/examples/database/create-url-attribute.md deleted file mode 100644 index dc8efd5..0000000 --- a/docs/examples/database/create-url-attribute.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.database import Database - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -database = Database(client) - -result = database.create_url_attribute('[COLLECTION_ID]', '', False) diff --git a/docs/examples/database/delete-attribute.md b/docs/examples/database/delete-attribute.md deleted file mode 100644 index 9cc8b4c..0000000 --- a/docs/examples/database/delete-attribute.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.database import Database - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -database = Database(client) - -result = database.delete_attribute('[COLLECTION_ID]', '') diff --git a/docs/examples/database/delete-collection.md b/docs/examples/database/delete-collection.md deleted file mode 100644 index 0e188ad..0000000 --- a/docs/examples/database/delete-collection.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.database import Database - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -database = Database(client) - -result = database.delete_collection('[COLLECTION_ID]') diff --git a/docs/examples/database/delete-document.md b/docs/examples/database/delete-document.md deleted file mode 100644 index c085547..0000000 --- a/docs/examples/database/delete-document.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.database import Database - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -database = Database(client) - -result = database.delete_document('[COLLECTION_ID]', '[DOCUMENT_ID]') diff --git a/docs/examples/database/delete-index.md b/docs/examples/database/delete-index.md deleted file mode 100644 index 5289b13..0000000 --- a/docs/examples/database/delete-index.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.database import Database - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -database = Database(client) - -result = database.delete_index('[COLLECTION_ID]', '') diff --git a/docs/examples/database/get-attribute.md b/docs/examples/database/get-attribute.md deleted file mode 100644 index 584a51c..0000000 --- a/docs/examples/database/get-attribute.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.database import Database - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -database = Database(client) - -result = database.get_attribute('[COLLECTION_ID]', '') diff --git a/docs/examples/database/get-collection.md b/docs/examples/database/get-collection.md deleted file mode 100644 index f90f51f..0000000 --- a/docs/examples/database/get-collection.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.database import Database - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -database = Database(client) - -result = database.get_collection('[COLLECTION_ID]') diff --git a/docs/examples/database/get-document.md b/docs/examples/database/get-document.md deleted file mode 100644 index 7989170..0000000 --- a/docs/examples/database/get-document.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.database import Database - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -database = Database(client) - -result = database.get_document('[COLLECTION_ID]', '[DOCUMENT_ID]') diff --git a/docs/examples/database/get-index.md b/docs/examples/database/get-index.md deleted file mode 100644 index 0a492e1..0000000 --- a/docs/examples/database/get-index.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.database import Database - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -database = Database(client) - -result = database.get_index('[COLLECTION_ID]', '') diff --git a/docs/examples/database/list-attributes.md b/docs/examples/database/list-attributes.md deleted file mode 100644 index ba69433..0000000 --- a/docs/examples/database/list-attributes.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.database import Database - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -database = Database(client) - -result = database.list_attributes('[COLLECTION_ID]') diff --git a/docs/examples/database/list-collections.md b/docs/examples/database/list-collections.md deleted file mode 100644 index f60d4b9..0000000 --- a/docs/examples/database/list-collections.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.database import Database - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -database = Database(client) - -result = database.list_collections() diff --git a/docs/examples/database/list-documents.md b/docs/examples/database/list-documents.md deleted file mode 100644 index cecb57d..0000000 --- a/docs/examples/database/list-documents.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.database import Database - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -database = Database(client) - -result = database.list_documents('[COLLECTION_ID]') diff --git a/docs/examples/database/list-indexes.md b/docs/examples/database/list-indexes.md deleted file mode 100644 index 0c7b7db..0000000 --- a/docs/examples/database/list-indexes.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.database import Database - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -database = Database(client) - -result = database.list_indexes('[COLLECTION_ID]') diff --git a/docs/examples/database/update-collection.md b/docs/examples/database/update-collection.md deleted file mode 100644 index adb809c..0000000 --- a/docs/examples/database/update-collection.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.database import Database - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -database = Database(client) - -result = database.update_collection('[COLLECTION_ID]', '[NAME]', 'document') diff --git a/docs/examples/database/update-document.md b/docs/examples/database/update-document.md deleted file mode 100644 index 2f4f89f..0000000 --- a/docs/examples/database/update-document.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.database import Database - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -database = Database(client) - -result = database.update_document('[COLLECTION_ID]', '[DOCUMENT_ID]', {}) diff --git a/docs/examples/databases/create-boolean-attribute.md b/docs/examples/databases/create-boolean-attribute.md new file mode 100644 index 0000000..f12f446 --- /dev/null +++ b/docs/examples/databases/create-boolean-attribute.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.create_boolean_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = False, # optional + array = False # optional +) diff --git a/docs/examples/databases/create-collection.md b/docs/examples/databases/create-collection.md new file mode 100644 index 0000000..596d4a9 --- /dev/null +++ b/docs/examples/databases/create-collection.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.create_collection( + database_id = '', + collection_id = '', + name = '', + permissions = ["read("any")"], # optional + document_security = False, # optional + enabled = False # optional +) diff --git a/docs/examples/databases/create-datetime-attribute.md b/docs/examples/databases/create-datetime-attribute.md new file mode 100644 index 0000000..8fd59e6 --- /dev/null +++ b/docs/examples/databases/create-datetime-attribute.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.create_datetime_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = '', # optional + array = False # optional +) diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md new file mode 100644 index 0000000..1eaf024 --- /dev/null +++ b/docs/examples/databases/create-document.md @@ -0,0 +1,17 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +databases = Databases(client) + +result = databases.create_document( + database_id = '', + collection_id = '', + document_id = '', + data = {}, + permissions = ["read("any")"] # optional +) diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md new file mode 100644 index 0000000..1b94e51 --- /dev/null +++ b/docs/examples/databases/create-documents.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.create_documents( + database_id = '', + collection_id = '', + documents = [] +) diff --git a/docs/examples/databases/create-email-attribute.md b/docs/examples/databases/create-email-attribute.md new file mode 100644 index 0000000..230567a --- /dev/null +++ b/docs/examples/databases/create-email-attribute.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.create_email_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = 'email@example.com', # optional + array = False # optional +) diff --git a/docs/examples/databases/create-enum-attribute.md b/docs/examples/databases/create-enum-attribute.md new file mode 100644 index 0000000..de1ceb9 --- /dev/null +++ b/docs/examples/databases/create-enum-attribute.md @@ -0,0 +1,19 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.create_enum_attribute( + database_id = '', + collection_id = '', + key = '', + elements = [], + required = False, + default = '', # optional + array = False # optional +) diff --git a/docs/examples/databases/create-float-attribute.md b/docs/examples/databases/create-float-attribute.md new file mode 100644 index 0000000..53305c8 --- /dev/null +++ b/docs/examples/databases/create-float-attribute.md @@ -0,0 +1,20 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.create_float_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + min = None, # optional + max = None, # optional + default = None, # optional + array = False # optional +) diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md new file mode 100644 index 0000000..f7bb455 --- /dev/null +++ b/docs/examples/databases/create-index.md @@ -0,0 +1,20 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases +from appwrite.enums import IndexType + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.create_index( + database_id = '', + collection_id = '', + key = '', + type = IndexType.KEY, + attributes = [], + orders = [], # optional + lengths = [] # optional +) diff --git a/docs/examples/databases/create-integer-attribute.md b/docs/examples/databases/create-integer-attribute.md new file mode 100644 index 0000000..92e8b0f --- /dev/null +++ b/docs/examples/databases/create-integer-attribute.md @@ -0,0 +1,20 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.create_integer_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + min = None, # optional + max = None, # optional + default = None, # optional + array = False # optional +) diff --git a/docs/examples/databases/create-ip-attribute.md b/docs/examples/databases/create-ip-attribute.md new file mode 100644 index 0000000..a7f424b --- /dev/null +++ b/docs/examples/databases/create-ip-attribute.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.create_ip_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = '', # optional + array = False # optional +) diff --git a/docs/examples/databases/create-relationship-attribute.md b/docs/examples/databases/create-relationship-attribute.md new file mode 100644 index 0000000..6c8f4dc --- /dev/null +++ b/docs/examples/databases/create-relationship-attribute.md @@ -0,0 +1,21 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases +from appwrite.enums import RelationshipType + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.create_relationship_attribute( + database_id = '', + collection_id = '', + related_collection_id = '', + type = RelationshipType.ONETOONE, + two_way = False, # optional + key = '', # optional + two_way_key = '', # optional + on_delete = RelationMutate.CASCADE # optional +) diff --git a/docs/examples/databases/create-string-attribute.md b/docs/examples/databases/create-string-attribute.md new file mode 100644 index 0000000..dc434cc --- /dev/null +++ b/docs/examples/databases/create-string-attribute.md @@ -0,0 +1,20 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.create_string_attribute( + database_id = '', + collection_id = '', + key = '', + size = 1, + required = False, + default = '', # optional + array = False, # optional + encrypt = False # optional +) diff --git a/docs/examples/databases/create-url-attribute.md b/docs/examples/databases/create-url-attribute.md new file mode 100644 index 0000000..af37573 --- /dev/null +++ b/docs/examples/databases/create-url-attribute.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.create_url_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = 'https://example.com', # optional + array = False # optional +) diff --git a/docs/examples/databases/create.md b/docs/examples/databases/create.md new file mode 100644 index 0000000..0492203 --- /dev/null +++ b/docs/examples/databases/create.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.create( + database_id = '', + name = '', + enabled = False # optional +) diff --git a/docs/examples/databases/decrement-document-attribute.md b/docs/examples/databases/decrement-document-attribute.md new file mode 100644 index 0000000..397bdd4 --- /dev/null +++ b/docs/examples/databases/decrement-document-attribute.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.decrement_document_attribute( + database_id = '', + collection_id = '', + document_id = '', + attribute = '', + value = None, # optional + min = None # optional +) diff --git a/docs/examples/databases/delete-attribute.md b/docs/examples/databases/delete-attribute.md new file mode 100644 index 0000000..e1c4eec --- /dev/null +++ b/docs/examples/databases/delete-attribute.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.delete_attribute( + database_id = '', + collection_id = '', + key = '' +) diff --git a/docs/examples/databases/delete-collection.md b/docs/examples/databases/delete-collection.md new file mode 100644 index 0000000..02f1e1c --- /dev/null +++ b/docs/examples/databases/delete-collection.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.delete_collection( + database_id = '', + collection_id = '' +) diff --git a/docs/examples/databases/delete-document.md b/docs/examples/databases/delete-document.md new file mode 100644 index 0000000..57f8b3b --- /dev/null +++ b/docs/examples/databases/delete-document.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +databases = Databases(client) + +result = databases.delete_document( + database_id = '', + collection_id = '', + document_id = '' +) diff --git a/docs/examples/databases/delete-documents.md b/docs/examples/databases/delete-documents.md new file mode 100644 index 0000000..a315f0c --- /dev/null +++ b/docs/examples/databases/delete-documents.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.delete_documents( + database_id = '', + collection_id = '', + queries = [] # optional +) diff --git a/docs/examples/databases/delete-index.md b/docs/examples/databases/delete-index.md new file mode 100644 index 0000000..0060064 --- /dev/null +++ b/docs/examples/databases/delete-index.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.delete_index( + database_id = '', + collection_id = '', + key = '' +) diff --git a/docs/examples/databases/delete.md b/docs/examples/databases/delete.md new file mode 100644 index 0000000..be64e8c --- /dev/null +++ b/docs/examples/databases/delete.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.delete( + database_id = '' +) diff --git a/docs/examples/databases/get-attribute.md b/docs/examples/databases/get-attribute.md new file mode 100644 index 0000000..dcdb0a6 --- /dev/null +++ b/docs/examples/databases/get-attribute.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.get_attribute( + database_id = '', + collection_id = '', + key = '' +) diff --git a/docs/examples/databases/get-collection.md b/docs/examples/databases/get-collection.md new file mode 100644 index 0000000..0833b4f --- /dev/null +++ b/docs/examples/databases/get-collection.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.get_collection( + database_id = '', + collection_id = '' +) diff --git a/docs/examples/databases/get-document.md b/docs/examples/databases/get-document.md new file mode 100644 index 0000000..aff5008 --- /dev/null +++ b/docs/examples/databases/get-document.md @@ -0,0 +1,16 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +databases = Databases(client) + +result = databases.get_document( + database_id = '', + collection_id = '', + document_id = '', + queries = [] # optional +) diff --git a/docs/examples/databases/get-index.md b/docs/examples/databases/get-index.md new file mode 100644 index 0000000..6971683 --- /dev/null +++ b/docs/examples/databases/get-index.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.get_index( + database_id = '', + collection_id = '', + key = '' +) diff --git a/docs/examples/databases/get.md b/docs/examples/databases/get.md new file mode 100644 index 0000000..c8191a3 --- /dev/null +++ b/docs/examples/databases/get.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.get( + database_id = '' +) diff --git a/docs/examples/databases/increment-document-attribute.md b/docs/examples/databases/increment-document-attribute.md new file mode 100644 index 0000000..d5700e0 --- /dev/null +++ b/docs/examples/databases/increment-document-attribute.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.increment_document_attribute( + database_id = '', + collection_id = '', + document_id = '', + attribute = '', + value = None, # optional + max = None # optional +) diff --git a/docs/examples/databases/list-attributes.md b/docs/examples/databases/list-attributes.md new file mode 100644 index 0000000..c97a5ce --- /dev/null +++ b/docs/examples/databases/list-attributes.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.list_attributes( + database_id = '', + collection_id = '', + queries = [] # optional +) diff --git a/docs/examples/databases/list-collections.md b/docs/examples/databases/list-collections.md new file mode 100644 index 0000000..17d0a3d --- /dev/null +++ b/docs/examples/databases/list-collections.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.list_collections( + database_id = '', + queries = [], # optional + search = '' # optional +) diff --git a/docs/examples/databases/list-documents.md b/docs/examples/databases/list-documents.md new file mode 100644 index 0000000..8b450cd --- /dev/null +++ b/docs/examples/databases/list-documents.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +databases = Databases(client) + +result = databases.list_documents( + database_id = '', + collection_id = '', + queries = [] # optional +) diff --git a/docs/examples/databases/list-indexes.md b/docs/examples/databases/list-indexes.md new file mode 100644 index 0000000..1457151 --- /dev/null +++ b/docs/examples/databases/list-indexes.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.list_indexes( + database_id = '', + collection_id = '', + queries = [] # optional +) diff --git a/docs/examples/databases/list.md b/docs/examples/databases/list.md new file mode 100644 index 0000000..58336c9 --- /dev/null +++ b/docs/examples/databases/list.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.list( + queries = [], # optional + search = '' # optional +) diff --git a/docs/examples/databases/update-boolean-attribute.md b/docs/examples/databases/update-boolean-attribute.md new file mode 100644 index 0000000..a0f72a4 --- /dev/null +++ b/docs/examples/databases/update-boolean-attribute.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.update_boolean_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = False, + new_key = '' # optional +) diff --git a/docs/examples/databases/update-collection.md b/docs/examples/databases/update-collection.md new file mode 100644 index 0000000..2e5be50 --- /dev/null +++ b/docs/examples/databases/update-collection.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.update_collection( + database_id = '', + collection_id = '', + name = '', + permissions = ["read("any")"], # optional + document_security = False, # optional + enabled = False # optional +) diff --git a/docs/examples/databases/update-datetime-attribute.md b/docs/examples/databases/update-datetime-attribute.md new file mode 100644 index 0000000..29bc6be --- /dev/null +++ b/docs/examples/databases/update-datetime-attribute.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.update_datetime_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = '', + new_key = '' # optional +) diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md new file mode 100644 index 0000000..9ef6527 --- /dev/null +++ b/docs/examples/databases/update-document.md @@ -0,0 +1,17 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +databases = Databases(client) + +result = databases.update_document( + database_id = '', + collection_id = '', + document_id = '', + data = {}, # optional + permissions = ["read("any")"] # optional +) diff --git a/docs/examples/databases/update-documents.md b/docs/examples/databases/update-documents.md new file mode 100644 index 0000000..5a50d1a --- /dev/null +++ b/docs/examples/databases/update-documents.md @@ -0,0 +1,16 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.update_documents( + database_id = '', + collection_id = '', + data = {}, # optional + queries = [] # optional +) diff --git a/docs/examples/databases/update-email-attribute.md b/docs/examples/databases/update-email-attribute.md new file mode 100644 index 0000000..c833789 --- /dev/null +++ b/docs/examples/databases/update-email-attribute.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.update_email_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = 'email@example.com', + new_key = '' # optional +) diff --git a/docs/examples/databases/update-enum-attribute.md b/docs/examples/databases/update-enum-attribute.md new file mode 100644 index 0000000..6186a72 --- /dev/null +++ b/docs/examples/databases/update-enum-attribute.md @@ -0,0 +1,19 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.update_enum_attribute( + database_id = '', + collection_id = '', + key = '', + elements = [], + required = False, + default = '', + new_key = '' # optional +) diff --git a/docs/examples/databases/update-float-attribute.md b/docs/examples/databases/update-float-attribute.md new file mode 100644 index 0000000..68cb7d7 --- /dev/null +++ b/docs/examples/databases/update-float-attribute.md @@ -0,0 +1,20 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.update_float_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = None, + min = None, # optional + max = None, # optional + new_key = '' # optional +) diff --git a/docs/examples/databases/update-integer-attribute.md b/docs/examples/databases/update-integer-attribute.md new file mode 100644 index 0000000..05c6bfe --- /dev/null +++ b/docs/examples/databases/update-integer-attribute.md @@ -0,0 +1,20 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.update_integer_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = None, + min = None, # optional + max = None, # optional + new_key = '' # optional +) diff --git a/docs/examples/databases/update-ip-attribute.md b/docs/examples/databases/update-ip-attribute.md new file mode 100644 index 0000000..550d3af --- /dev/null +++ b/docs/examples/databases/update-ip-attribute.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.update_ip_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = '', + new_key = '' # optional +) diff --git a/docs/examples/databases/update-relationship-attribute.md b/docs/examples/databases/update-relationship-attribute.md new file mode 100644 index 0000000..3b6c8e9 --- /dev/null +++ b/docs/examples/databases/update-relationship-attribute.md @@ -0,0 +1,17 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.update_relationship_attribute( + database_id = '', + collection_id = '', + key = '', + on_delete = RelationMutate.CASCADE, # optional + new_key = '' # optional +) diff --git a/docs/examples/databases/update-string-attribute.md b/docs/examples/databases/update-string-attribute.md new file mode 100644 index 0000000..5b66fb0 --- /dev/null +++ b/docs/examples/databases/update-string-attribute.md @@ -0,0 +1,19 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.update_string_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = '', + size = 1, # optional + new_key = '' # optional +) diff --git a/docs/examples/databases/update-url-attribute.md b/docs/examples/databases/update-url-attribute.md new file mode 100644 index 0000000..4a62027 --- /dev/null +++ b/docs/examples/databases/update-url-attribute.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.update_url_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = 'https://example.com', + new_key = '' # optional +) diff --git a/docs/examples/databases/update.md b/docs/examples/databases/update.md new file mode 100644 index 0000000..35d2c0c --- /dev/null +++ b/docs/examples/databases/update.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.update( + database_id = '', + name = '', + enabled = False # optional +) diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md new file mode 100644 index 0000000..c491ea4 --- /dev/null +++ b/docs/examples/databases/upsert-document.md @@ -0,0 +1,17 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +databases = Databases(client) + +result = databases.upsert_document( + database_id = '', + collection_id = '', + document_id = '', + data = {}, + permissions = ["read("any")"] # optional +) diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md new file mode 100644 index 0000000..5136d5f --- /dev/null +++ b/docs/examples/databases/upsert-documents.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.upsert_documents( + database_id = '', + collection_id = '', + documents = [] +) diff --git a/docs/examples/functions/create-deployment.md b/docs/examples/functions/create-deployment.md new file mode 100644 index 0000000..0774005 --- /dev/null +++ b/docs/examples/functions/create-deployment.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.functions import Functions +from appwrite.input_file import InputFile + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +functions = Functions(client) + +result = functions.create_deployment( + function_id = '', + code = InputFile.from_path('file.png'), + activate = False, + entrypoint = '', # optional + commands = '' # optional +) diff --git a/docs/examples/functions/create-duplicate-deployment.md b/docs/examples/functions/create-duplicate-deployment.md new file mode 100644 index 0000000..79315e4 --- /dev/null +++ b/docs/examples/functions/create-duplicate-deployment.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.functions import Functions + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +functions = Functions(client) + +result = functions.create_duplicate_deployment( + function_id = '', + deployment_id = '', + build_id = '' # optional +) diff --git a/docs/examples/functions/create-execution.md b/docs/examples/functions/create-execution.md index dc4442c..b41c7e3 100644 --- a/docs/examples/functions/create-execution.md +++ b/docs/examples/functions/create-execution.md @@ -2,13 +2,18 @@ from appwrite.client import Client from appwrite.services.functions import Functions client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with functions = Functions(client) -result = functions.create_execution('[FUNCTION_ID]') +result = functions.create_execution( + function_id = '', + body = '', # optional + async = False, # optional + path = '', # optional + method = ExecutionMethod.GET, # optional + headers = {}, # optional + scheduled_at = '' # optional +) diff --git a/docs/examples/functions/create-tag.md b/docs/examples/functions/create-tag.md deleted file mode 100644 index 1995a64..0000000 --- a/docs/examples/functions/create-tag.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.functions import Functions - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -functions = Functions(client) - -result = functions.create_tag('[FUNCTION_ID]', '[COMMAND]', open('/path/to/file.png', 'rb')) diff --git a/docs/examples/functions/create-template-deployment.md b/docs/examples/functions/create-template-deployment.md new file mode 100644 index 0000000..6083cc1 --- /dev/null +++ b/docs/examples/functions/create-template-deployment.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.functions import Functions + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +functions = Functions(client) + +result = functions.create_template_deployment( + function_id = '', + repository = '', + owner = '', + root_directory = '', + version = '', + activate = False # optional +) diff --git a/docs/examples/functions/create-variable.md b/docs/examples/functions/create-variable.md new file mode 100644 index 0000000..2089830 --- /dev/null +++ b/docs/examples/functions/create-variable.md @@ -0,0 +1,16 @@ +from appwrite.client import Client +from appwrite.services.functions import Functions + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +functions = Functions(client) + +result = functions.create_variable( + function_id = '', + key = '', + value = '', + secret = False # optional +) diff --git a/docs/examples/functions/create-vcs-deployment.md b/docs/examples/functions/create-vcs-deployment.md new file mode 100644 index 0000000..4004bae --- /dev/null +++ b/docs/examples/functions/create-vcs-deployment.md @@ -0,0 +1,17 @@ +from appwrite.client import Client +from appwrite.services.functions import Functions +from appwrite.enums import VCSDeploymentType + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +functions = Functions(client) + +result = functions.create_vcs_deployment( + function_id = '', + type = VCSDeploymentType.BRANCH, + reference = '', + activate = False # optional +) diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index 53629a5..8758e27 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -1,14 +1,31 @@ from appwrite.client import Client from appwrite.services.functions import Functions +from appwrite.enums import client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key functions = Functions(client) -result = functions.create('[FUNCTION_ID]', '[NAME]', [], 'node-14.5') +result = functions.create( + function_id = '', + name = '', + runtime = .NODE_14_5, + execute = ["any"], # optional + events = [], # optional + schedule = '', # optional + timeout = 1, # optional + enabled = False, # optional + logging = False, # optional + entrypoint = '', # optional + commands = '', # optional + scopes = [], # optional + installation_id = '', # optional + provider_repository_id = '', # optional + provider_branch = '', # optional + provider_silent_mode = False, # optional + provider_root_directory = '', # optional + specification = '' # optional +) diff --git a/docs/examples/functions/delete-deployment.md b/docs/examples/functions/delete-deployment.md new file mode 100644 index 0000000..f874b2d --- /dev/null +++ b/docs/examples/functions/delete-deployment.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.functions import Functions + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +functions = Functions(client) + +result = functions.delete_deployment( + function_id = '', + deployment_id = '' +) diff --git a/docs/examples/functions/delete-execution.md b/docs/examples/functions/delete-execution.md new file mode 100644 index 0000000..df7ce7c --- /dev/null +++ b/docs/examples/functions/delete-execution.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.functions import Functions + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +functions = Functions(client) + +result = functions.delete_execution( + function_id = '', + execution_id = '' +) diff --git a/docs/examples/functions/delete-tag.md b/docs/examples/functions/delete-tag.md deleted file mode 100644 index a4cb1b7..0000000 --- a/docs/examples/functions/delete-tag.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.functions import Functions - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -functions = Functions(client) - -result = functions.delete_tag('[FUNCTION_ID]', '[TAG_ID]') diff --git a/docs/examples/functions/delete-variable.md b/docs/examples/functions/delete-variable.md new file mode 100644 index 0000000..a6e3dc8 --- /dev/null +++ b/docs/examples/functions/delete-variable.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.functions import Functions + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +functions = Functions(client) + +result = functions.delete_variable( + function_id = '', + variable_id = '' +) diff --git a/docs/examples/functions/delete.md b/docs/examples/functions/delete.md index 52658e8..ed2fef7 100644 --- a/docs/examples/functions/delete.md +++ b/docs/examples/functions/delete.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.functions import Functions client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key functions = Functions(client) -result = functions.delete('[FUNCTION_ID]') +result = functions.delete( + function_id = '' +) diff --git a/docs/examples/functions/get-deployment-download.md b/docs/examples/functions/get-deployment-download.md new file mode 100644 index 0000000..1b0673c --- /dev/null +++ b/docs/examples/functions/get-deployment-download.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.functions import Functions + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +functions = Functions(client) + +result = functions.get_deployment_download( + function_id = '', + deployment_id = '', + type = DeploymentDownloadType.SOURCE # optional +) diff --git a/docs/examples/functions/get-deployment.md b/docs/examples/functions/get-deployment.md new file mode 100644 index 0000000..59a1374 --- /dev/null +++ b/docs/examples/functions/get-deployment.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.functions import Functions + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +functions = Functions(client) + +result = functions.get_deployment( + function_id = '', + deployment_id = '' +) diff --git a/docs/examples/functions/get-execution.md b/docs/examples/functions/get-execution.md index 1e10130..a299f35 100644 --- a/docs/examples/functions/get-execution.md +++ b/docs/examples/functions/get-execution.md @@ -2,13 +2,13 @@ from appwrite.client import Client from appwrite.services.functions import Functions client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with functions = Functions(client) -result = functions.get_execution('[FUNCTION_ID]', '[EXECUTION_ID]') +result = functions.get_execution( + function_id = '', + execution_id = '' +) diff --git a/docs/examples/functions/get-tag.md b/docs/examples/functions/get-tag.md deleted file mode 100644 index 4cded46..0000000 --- a/docs/examples/functions/get-tag.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.functions import Functions - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -functions = Functions(client) - -result = functions.get_tag('[FUNCTION_ID]', '[TAG_ID]') diff --git a/docs/examples/functions/get-variable.md b/docs/examples/functions/get-variable.md new file mode 100644 index 0000000..629948e --- /dev/null +++ b/docs/examples/functions/get-variable.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.functions import Functions + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +functions = Functions(client) + +result = functions.get_variable( + function_id = '', + variable_id = '' +) diff --git a/docs/examples/functions/get.md b/docs/examples/functions/get.md index 0007667..eeab5a5 100644 --- a/docs/examples/functions/get.md +++ b/docs/examples/functions/get.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.functions import Functions client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key functions = Functions(client) -result = functions.get('[FUNCTION_ID]') +result = functions.get( + function_id = '' +) diff --git a/docs/examples/functions/list-deployments.md b/docs/examples/functions/list-deployments.md new file mode 100644 index 0000000..4eb92f6 --- /dev/null +++ b/docs/examples/functions/list-deployments.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.functions import Functions + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +functions = Functions(client) + +result = functions.list_deployments( + function_id = '', + queries = [], # optional + search = '' # optional +) diff --git a/docs/examples/functions/list-executions.md b/docs/examples/functions/list-executions.md index 6d75e09..300fc0e 100644 --- a/docs/examples/functions/list-executions.md +++ b/docs/examples/functions/list-executions.md @@ -2,13 +2,13 @@ from appwrite.client import Client from appwrite.services.functions import Functions client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with functions = Functions(client) -result = functions.list_executions('[FUNCTION_ID]') +result = functions.list_executions( + function_id = '', + queries = [] # optional +) diff --git a/docs/examples/functions/list-runtimes.md b/docs/examples/functions/list-runtimes.md index a832a4d..9c89a36 100644 --- a/docs/examples/functions/list-runtimes.md +++ b/docs/examples/functions/list-runtimes.md @@ -2,12 +2,9 @@ from appwrite.client import Client from appwrite.services.functions import Functions client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key functions = Functions(client) diff --git a/docs/examples/functions/list-specifications.md b/docs/examples/functions/list-specifications.md new file mode 100644 index 0000000..d7d0036 --- /dev/null +++ b/docs/examples/functions/list-specifications.md @@ -0,0 +1,11 @@ +from appwrite.client import Client +from appwrite.services.functions import Functions + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +functions = Functions(client) + +result = functions.list_specifications() diff --git a/docs/examples/functions/list-tags.md b/docs/examples/functions/list-tags.md deleted file mode 100644 index 67a81a9..0000000 --- a/docs/examples/functions/list-tags.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.functions import Functions - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -functions = Functions(client) - -result = functions.list_tags('[FUNCTION_ID]') diff --git a/docs/examples/functions/list-variables.md b/docs/examples/functions/list-variables.md new file mode 100644 index 0000000..ebc19c5 --- /dev/null +++ b/docs/examples/functions/list-variables.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.functions import Functions + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +functions = Functions(client) + +result = functions.list_variables( + function_id = '' +) diff --git a/docs/examples/functions/list.md b/docs/examples/functions/list.md index cc1f04d..b1d696d 100644 --- a/docs/examples/functions/list.md +++ b/docs/examples/functions/list.md @@ -2,13 +2,13 @@ from appwrite.client import Client from appwrite.services.functions import Functions client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key functions = Functions(client) -result = functions.list() +result = functions.list( + queries = [], # optional + search = '' # optional +) diff --git a/docs/examples/functions/update-deployment-status.md b/docs/examples/functions/update-deployment-status.md new file mode 100644 index 0000000..6c6a8bf --- /dev/null +++ b/docs/examples/functions/update-deployment-status.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.functions import Functions + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +functions = Functions(client) + +result = functions.update_deployment_status( + function_id = '', + deployment_id = '' +) diff --git a/docs/examples/functions/update-function-deployment.md b/docs/examples/functions/update-function-deployment.md new file mode 100644 index 0000000..da14309 --- /dev/null +++ b/docs/examples/functions/update-function-deployment.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.functions import Functions + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +functions = Functions(client) + +result = functions.update_function_deployment( + function_id = '', + deployment_id = '' +) diff --git a/docs/examples/functions/update-tag.md b/docs/examples/functions/update-tag.md deleted file mode 100644 index 7a9da50..0000000 --- a/docs/examples/functions/update-tag.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.functions import Functions - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -functions = Functions(client) - -result = functions.update_tag('[FUNCTION_ID]', '[TAG]') diff --git a/docs/examples/functions/update-variable.md b/docs/examples/functions/update-variable.md new file mode 100644 index 0000000..f8bcc03 --- /dev/null +++ b/docs/examples/functions/update-variable.md @@ -0,0 +1,17 @@ +from appwrite.client import Client +from appwrite.services.functions import Functions + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +functions = Functions(client) + +result = functions.update_variable( + function_id = '', + variable_id = '', + key = '', + value = '', # optional + secret = False # optional +) diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index 6753381..64ee39b 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -2,13 +2,29 @@ from appwrite.client import Client from appwrite.services.functions import Functions client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key functions = Functions(client) -result = functions.update('[FUNCTION_ID]', '[NAME]', []) +result = functions.update( + function_id = '', + name = '', + runtime = .NODE_14_5, # optional + execute = ["any"], # optional + events = [], # optional + schedule = '', # optional + timeout = 1, # optional + enabled = False, # optional + logging = False, # optional + entrypoint = '', # optional + commands = '', # optional + scopes = [], # optional + installation_id = '', # optional + provider_repository_id = '', # optional + provider_branch = '', # optional + provider_silent_mode = False, # optional + provider_root_directory = '', # optional + specification = '' # optional +) diff --git a/docs/examples/graphql/mutation.md b/docs/examples/graphql/mutation.md new file mode 100644 index 0000000..189892a --- /dev/null +++ b/docs/examples/graphql/mutation.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.graphql import Graphql + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +graphql = Graphql(client) + +result = graphql.mutation( + query = {} +) diff --git a/docs/examples/graphql/query.md b/docs/examples/graphql/query.md new file mode 100644 index 0000000..585a502 --- /dev/null +++ b/docs/examples/graphql/query.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.graphql import Graphql + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +graphql = Graphql(client) + +result = graphql.query( + query = {} +) diff --git a/docs/examples/health/get-antivirus.md b/docs/examples/health/get-antivirus.md index 97ee120..2b62147 100644 --- a/docs/examples/health/get-antivirus.md +++ b/docs/examples/health/get-antivirus.md @@ -2,12 +2,9 @@ from appwrite.client import Client from appwrite.services.health import Health client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key health = Health(client) diff --git a/docs/examples/health/get-cache.md b/docs/examples/health/get-cache.md index 57c7939..595c4bf 100644 --- a/docs/examples/health/get-cache.md +++ b/docs/examples/health/get-cache.md @@ -2,12 +2,9 @@ from appwrite.client import Client from appwrite.services.health import Health client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key health = Health(client) diff --git a/docs/examples/health/get-certificate.md b/docs/examples/health/get-certificate.md new file mode 100644 index 0000000..5b3e2c0 --- /dev/null +++ b/docs/examples/health/get-certificate.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.health import Health + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +health = Health(client) + +result = health.get_certificate( + domain = '' # optional +) diff --git a/docs/examples/health/get-d-b.md b/docs/examples/health/get-d-b.md index 4c2bafe..47c7bd8 100644 --- a/docs/examples/health/get-d-b.md +++ b/docs/examples/health/get-d-b.md @@ -2,12 +2,9 @@ from appwrite.client import Client from appwrite.services.health import Health client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key health = Health(client) diff --git a/docs/examples/health/get-failed-jobs.md b/docs/examples/health/get-failed-jobs.md new file mode 100644 index 0000000..5362a2d --- /dev/null +++ b/docs/examples/health/get-failed-jobs.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.health import Health +from appwrite.enums import + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +health = Health(client) + +result = health.get_failed_jobs( + name = .V1_DATABASE, + threshold = None # optional +) diff --git a/docs/examples/health/get-pub-sub.md b/docs/examples/health/get-pub-sub.md new file mode 100644 index 0000000..e5115d0 --- /dev/null +++ b/docs/examples/health/get-pub-sub.md @@ -0,0 +1,11 @@ +from appwrite.client import Client +from appwrite.services.health import Health + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +health = Health(client) + +result = health.get_pub_sub() diff --git a/docs/examples/health/get-queue-builds.md b/docs/examples/health/get-queue-builds.md new file mode 100644 index 0000000..18ed8e3 --- /dev/null +++ b/docs/examples/health/get-queue-builds.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.health import Health + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +health = Health(client) + +result = health.get_queue_builds( + threshold = None # optional +) diff --git a/docs/examples/health/get-queue-certificates.md b/docs/examples/health/get-queue-certificates.md index 1f87c27..b0a29e2 100644 --- a/docs/examples/health/get-queue-certificates.md +++ b/docs/examples/health/get-queue-certificates.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.health import Health client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key health = Health(client) -result = health.get_queue_certificates() +result = health.get_queue_certificates( + threshold = None # optional +) diff --git a/docs/examples/health/get-queue-databases.md b/docs/examples/health/get-queue-databases.md new file mode 100644 index 0000000..491d1f7 --- /dev/null +++ b/docs/examples/health/get-queue-databases.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.health import Health + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +health = Health(client) + +result = health.get_queue_databases( + name = '', # optional + threshold = None # optional +) diff --git a/docs/examples/health/get-queue-deletes.md b/docs/examples/health/get-queue-deletes.md new file mode 100644 index 0000000..fa860c6 --- /dev/null +++ b/docs/examples/health/get-queue-deletes.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.health import Health + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +health = Health(client) + +result = health.get_queue_deletes( + threshold = None # optional +) diff --git a/docs/examples/health/get-queue-functions.md b/docs/examples/health/get-queue-functions.md index 3e0b0c0..d4ca938 100644 --- a/docs/examples/health/get-queue-functions.md +++ b/docs/examples/health/get-queue-functions.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.health import Health client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key health = Health(client) -result = health.get_queue_functions() +result = health.get_queue_functions( + threshold = None # optional +) diff --git a/docs/examples/health/get-queue-logs.md b/docs/examples/health/get-queue-logs.md index fdf80c6..1479f03 100644 --- a/docs/examples/health/get-queue-logs.md +++ b/docs/examples/health/get-queue-logs.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.health import Health client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key health = Health(client) -result = health.get_queue_logs() +result = health.get_queue_logs( + threshold = None # optional +) diff --git a/docs/examples/health/get-queue-mails.md b/docs/examples/health/get-queue-mails.md new file mode 100644 index 0000000..6835efe --- /dev/null +++ b/docs/examples/health/get-queue-mails.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.health import Health + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +health = Health(client) + +result = health.get_queue_mails( + threshold = None # optional +) diff --git a/docs/examples/health/get-queue-messaging.md b/docs/examples/health/get-queue-messaging.md new file mode 100644 index 0000000..34cbad2 --- /dev/null +++ b/docs/examples/health/get-queue-messaging.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.health import Health + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +health = Health(client) + +result = health.get_queue_messaging( + threshold = None # optional +) diff --git a/docs/examples/health/get-queue-migrations.md b/docs/examples/health/get-queue-migrations.md new file mode 100644 index 0000000..019db4e --- /dev/null +++ b/docs/examples/health/get-queue-migrations.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.health import Health + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +health = Health(client) + +result = health.get_queue_migrations( + threshold = None # optional +) diff --git a/docs/examples/health/get-queue-stats-resources.md b/docs/examples/health/get-queue-stats-resources.md new file mode 100644 index 0000000..92aebc3 --- /dev/null +++ b/docs/examples/health/get-queue-stats-resources.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.health import Health + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +health = Health(client) + +result = health.get_queue_stats_resources( + threshold = None # optional +) diff --git a/docs/examples/health/get-queue-usage.md b/docs/examples/health/get-queue-usage.md index aeb8e83..266ca82 100644 --- a/docs/examples/health/get-queue-usage.md +++ b/docs/examples/health/get-queue-usage.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.health import Health client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key health = Health(client) -result = health.get_queue_usage() +result = health.get_queue_usage( + threshold = None # optional +) diff --git a/docs/examples/health/get-queue-webhooks.md b/docs/examples/health/get-queue-webhooks.md index 90c4238..df5e2d5 100644 --- a/docs/examples/health/get-queue-webhooks.md +++ b/docs/examples/health/get-queue-webhooks.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.health import Health client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key health = Health(client) -result = health.get_queue_webhooks() +result = health.get_queue_webhooks( + threshold = None # optional +) diff --git a/docs/examples/health/get-storage-local.md b/docs/examples/health/get-storage-local.md index b06dcef..7d2ea44 100644 --- a/docs/examples/health/get-storage-local.md +++ b/docs/examples/health/get-storage-local.md @@ -2,12 +2,9 @@ from appwrite.client import Client from appwrite.services.health import Health client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key health = Health(client) diff --git a/docs/examples/health/get-storage.md b/docs/examples/health/get-storage.md new file mode 100644 index 0000000..821d9f3 --- /dev/null +++ b/docs/examples/health/get-storage.md @@ -0,0 +1,11 @@ +from appwrite.client import Client +from appwrite.services.health import Health + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +health = Health(client) + +result = health.get_storage() diff --git a/docs/examples/health/get-time.md b/docs/examples/health/get-time.md index df68c1a..907e964 100644 --- a/docs/examples/health/get-time.md +++ b/docs/examples/health/get-time.md @@ -2,12 +2,9 @@ from appwrite.client import Client from appwrite.services.health import Health client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key health = Health(client) diff --git a/docs/examples/health/get.md b/docs/examples/health/get.md index f3416ae..c544fcc 100644 --- a/docs/examples/health/get.md +++ b/docs/examples/health/get.md @@ -2,12 +2,9 @@ from appwrite.client import Client from appwrite.services.health import Health client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key health = Health(client) diff --git a/docs/examples/locale/get-continents.md b/docs/examples/locale/get-continents.md deleted file mode 100644 index 393326d..0000000 --- a/docs/examples/locale/get-continents.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.locale import Locale - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -locale = Locale(client) - -result = locale.get_continents() diff --git a/docs/examples/locale/get-countries-e-u.md b/docs/examples/locale/get-countries-e-u.md deleted file mode 100644 index 51178dd..0000000 --- a/docs/examples/locale/get-countries-e-u.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.locale import Locale - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -locale = Locale(client) - -result = locale.get_countries_eu() diff --git a/docs/examples/locale/get-countries-phones.md b/docs/examples/locale/get-countries-phones.md deleted file mode 100644 index 8c7693a..0000000 --- a/docs/examples/locale/get-countries-phones.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.locale import Locale - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -locale = Locale(client) - -result = locale.get_countries_phones() diff --git a/docs/examples/locale/get-countries.md b/docs/examples/locale/get-countries.md deleted file mode 100644 index 8a6c7cb..0000000 --- a/docs/examples/locale/get-countries.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.locale import Locale - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -locale = Locale(client) - -result = locale.get_countries() diff --git a/docs/examples/locale/get-currencies.md b/docs/examples/locale/get-currencies.md deleted file mode 100644 index 17586de..0000000 --- a/docs/examples/locale/get-currencies.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.locale import Locale - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -locale = Locale(client) - -result = locale.get_currencies() diff --git a/docs/examples/locale/get-languages.md b/docs/examples/locale/get-languages.md deleted file mode 100644 index 292a401..0000000 --- a/docs/examples/locale/get-languages.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.locale import Locale - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -locale = Locale(client) - -result = locale.get_languages() diff --git a/docs/examples/locale/get.md b/docs/examples/locale/get.md index 752df01..6f2a877 100644 --- a/docs/examples/locale/get.md +++ b/docs/examples/locale/get.md @@ -2,12 +2,9 @@ from appwrite.client import Client from appwrite.services.locale import Locale client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with locale = Locale(client) diff --git a/docs/examples/locale/list-codes.md b/docs/examples/locale/list-codes.md new file mode 100644 index 0000000..5f3e501 --- /dev/null +++ b/docs/examples/locale/list-codes.md @@ -0,0 +1,11 @@ +from appwrite.client import Client +from appwrite.services.locale import Locale + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +locale = Locale(client) + +result = locale.list_codes() diff --git a/docs/examples/locale/list-continents.md b/docs/examples/locale/list-continents.md new file mode 100644 index 0000000..0aead81 --- /dev/null +++ b/docs/examples/locale/list-continents.md @@ -0,0 +1,11 @@ +from appwrite.client import Client +from appwrite.services.locale import Locale + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +locale = Locale(client) + +result = locale.list_continents() diff --git a/docs/examples/locale/list-countries-e-u.md b/docs/examples/locale/list-countries-e-u.md new file mode 100644 index 0000000..f88e331 --- /dev/null +++ b/docs/examples/locale/list-countries-e-u.md @@ -0,0 +1,11 @@ +from appwrite.client import Client +from appwrite.services.locale import Locale + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +locale = Locale(client) + +result = locale.list_countries_eu() diff --git a/docs/examples/locale/list-countries-phones.md b/docs/examples/locale/list-countries-phones.md new file mode 100644 index 0000000..b1fdc1a --- /dev/null +++ b/docs/examples/locale/list-countries-phones.md @@ -0,0 +1,11 @@ +from appwrite.client import Client +from appwrite.services.locale import Locale + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +locale = Locale(client) + +result = locale.list_countries_phones() diff --git a/docs/examples/locale/list-countries.md b/docs/examples/locale/list-countries.md new file mode 100644 index 0000000..0c5b23c --- /dev/null +++ b/docs/examples/locale/list-countries.md @@ -0,0 +1,11 @@ +from appwrite.client import Client +from appwrite.services.locale import Locale + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +locale = Locale(client) + +result = locale.list_countries() diff --git a/docs/examples/locale/list-currencies.md b/docs/examples/locale/list-currencies.md new file mode 100644 index 0000000..20009d6 --- /dev/null +++ b/docs/examples/locale/list-currencies.md @@ -0,0 +1,11 @@ +from appwrite.client import Client +from appwrite.services.locale import Locale + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +locale = Locale(client) + +result = locale.list_currencies() diff --git a/docs/examples/locale/list-languages.md b/docs/examples/locale/list-languages.md new file mode 100644 index 0000000..1962a83 --- /dev/null +++ b/docs/examples/locale/list-languages.md @@ -0,0 +1,11 @@ +from appwrite.client import Client +from appwrite.services.locale import Locale + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +locale = Locale(client) + +result = locale.list_languages() diff --git a/docs/examples/messaging/create-apns-provider.md b/docs/examples/messaging/create-apns-provider.md new file mode 100644 index 0000000..b57fa00 --- /dev/null +++ b/docs/examples/messaging/create-apns-provider.md @@ -0,0 +1,20 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +messaging = Messaging(client) + +result = messaging.create_apns_provider( + provider_id = '', + name = '', + auth_key = '', # optional + auth_key_id = '', # optional + team_id = '', # optional + bundle_id = '', # optional + sandbox = False, # optional + enabled = False # optional +) diff --git a/docs/examples/messaging/create-email.md b/docs/examples/messaging/create-email.md new file mode 100644 index 0000000..8b4c9d2 --- /dev/null +++ b/docs/examples/messaging/create-email.md @@ -0,0 +1,24 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +messaging = Messaging(client) + +result = messaging.create_email( + message_id = '', + subject = '', + content = '', + topics = [], # optional + users = [], # optional + targets = [], # optional + cc = [], # optional + bcc = [], # optional + attachments = [], # optional + draft = False, # optional + html = False, # optional + scheduled_at = '' # optional +) diff --git a/docs/examples/messaging/create-fcm-provider.md b/docs/examples/messaging/create-fcm-provider.md new file mode 100644 index 0000000..9c40eb7 --- /dev/null +++ b/docs/examples/messaging/create-fcm-provider.md @@ -0,0 +1,16 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +messaging = Messaging(client) + +result = messaging.create_fcm_provider( + provider_id = '', + name = '', + service_account_json = {}, # optional + enabled = False # optional +) diff --git a/docs/examples/messaging/create-mailgun-provider.md b/docs/examples/messaging/create-mailgun-provider.md new file mode 100644 index 0000000..6703f6f --- /dev/null +++ b/docs/examples/messaging/create-mailgun-provider.md @@ -0,0 +1,22 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +messaging = Messaging(client) + +result = messaging.create_mailgun_provider( + provider_id = '', + name = '', + api_key = '', # optional + domain = '', # optional + is_eu_region = False, # optional + from_name = '', # optional + from_email = 'email@example.com', # optional + reply_to_name = '', # optional + reply_to_email = 'email@example.com', # optional + enabled = False # optional +) diff --git a/docs/examples/messaging/create-msg91provider.md b/docs/examples/messaging/create-msg91provider.md new file mode 100644 index 0000000..9315dcd --- /dev/null +++ b/docs/examples/messaging/create-msg91provider.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +messaging = Messaging(client) + +result = messaging.create_msg91_provider( + provider_id = '', + name = '', + template_id = '', # optional + sender_id = '', # optional + auth_key = '', # optional + enabled = False # optional +) diff --git a/docs/examples/messaging/create-push.md b/docs/examples/messaging/create-push.md new file mode 100644 index 0000000..8671b56 --- /dev/null +++ b/docs/examples/messaging/create-push.md @@ -0,0 +1,31 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +messaging = Messaging(client) + +result = messaging.create_push( + message_id = '', + title = '', # optional + body = '<BODY>', # optional + topics = [], # optional + users = [], # optional + targets = [], # optional + data = {}, # optional + action = '<ACTION>', # optional + image = '[ID1:ID2]', # optional + icon = '<ICON>', # optional + sound = '<SOUND>', # optional + color = '<COLOR>', # optional + tag = '<TAG>', # optional + badge = None, # optional + draft = False, # optional + scheduled_at = '', # optional + content_available = False, # optional + critical = False, # optional + priority = MessagePriority.NORMAL # optional +) diff --git a/docs/examples/messaging/create-sendgrid-provider.md b/docs/examples/messaging/create-sendgrid-provider.md new file mode 100644 index 0000000..46ff54f --- /dev/null +++ b/docs/examples/messaging/create-sendgrid-provider.md @@ -0,0 +1,20 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.create_sendgrid_provider( + provider_id = '<PROVIDER_ID>', + name = '<NAME>', + api_key = '<API_KEY>', # optional + from_name = '<FROM_NAME>', # optional + from_email = 'email@example.com', # optional + reply_to_name = '<REPLY_TO_NAME>', # optional + reply_to_email = 'email@example.com', # optional + enabled = False # optional +) diff --git a/docs/examples/messaging/create-sms.md b/docs/examples/messaging/create-sms.md new file mode 100644 index 0000000..d1c7b49 --- /dev/null +++ b/docs/examples/messaging/create-sms.md @@ -0,0 +1,19 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.create_sms( + message_id = '<MESSAGE_ID>', + content = '<CONTENT>', + topics = [], # optional + users = [], # optional + targets = [], # optional + draft = False, # optional + scheduled_at = '' # optional +) diff --git a/docs/examples/messaging/create-smtp-provider.md b/docs/examples/messaging/create-smtp-provider.md new file mode 100644 index 0000000..99914f0 --- /dev/null +++ b/docs/examples/messaging/create-smtp-provider.md @@ -0,0 +1,26 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.create_smtp_provider( + provider_id = '<PROVIDER_ID>', + name = '<NAME>', + host = '<HOST>', + port = 1, # optional + username = '<USERNAME>', # optional + password = '<PASSWORD>', # optional + encryption = SmtpEncryption.NONE, # optional + auto_tls = False, # optional + mailer = '<MAILER>', # optional + from_name = '<FROM_NAME>', # optional + from_email = 'email@example.com', # optional + reply_to_name = '<REPLY_TO_NAME>', # optional + reply_to_email = 'email@example.com', # optional + enabled = False # optional +) diff --git a/docs/examples/messaging/create-subscriber.md b/docs/examples/messaging/create-subscriber.md new file mode 100644 index 0000000..bc0c892 --- /dev/null +++ b/docs/examples/messaging/create-subscriber.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_jwt('<YOUR_JWT>') # Your secret JSON Web Token + +messaging = Messaging(client) + +result = messaging.create_subscriber( + topic_id = '<TOPIC_ID>', + subscriber_id = '<SUBSCRIBER_ID>', + target_id = '<TARGET_ID>' +) diff --git a/docs/examples/messaging/create-telesign-provider.md b/docs/examples/messaging/create-telesign-provider.md new file mode 100644 index 0000000..aff09fe --- /dev/null +++ b/docs/examples/messaging/create-telesign-provider.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.create_telesign_provider( + provider_id = '<PROVIDER_ID>', + name = '<NAME>', + from = '+12065550100', # optional + customer_id = '<CUSTOMER_ID>', # optional + api_key = '<API_KEY>', # optional + enabled = False # optional +) diff --git a/docs/examples/messaging/create-textmagic-provider.md b/docs/examples/messaging/create-textmagic-provider.md new file mode 100644 index 0000000..46ded71 --- /dev/null +++ b/docs/examples/messaging/create-textmagic-provider.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.create_textmagic_provider( + provider_id = '<PROVIDER_ID>', + name = '<NAME>', + from = '+12065550100', # optional + username = '<USERNAME>', # optional + api_key = '<API_KEY>', # optional + enabled = False # optional +) diff --git a/docs/examples/messaging/create-topic.md b/docs/examples/messaging/create-topic.md new file mode 100644 index 0000000..c1cb465 --- /dev/null +++ b/docs/examples/messaging/create-topic.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.create_topic( + topic_id = '<TOPIC_ID>', + name = '<NAME>', + subscribe = ["any"] # optional +) diff --git a/docs/examples/messaging/create-twilio-provider.md b/docs/examples/messaging/create-twilio-provider.md new file mode 100644 index 0000000..4438563 --- /dev/null +++ b/docs/examples/messaging/create-twilio-provider.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.create_twilio_provider( + provider_id = '<PROVIDER_ID>', + name = '<NAME>', + from = '+12065550100', # optional + account_sid = '<ACCOUNT_SID>', # optional + auth_token = '<AUTH_TOKEN>', # optional + enabled = False # optional +) diff --git a/docs/examples/messaging/create-vonage-provider.md b/docs/examples/messaging/create-vonage-provider.md new file mode 100644 index 0000000..6ffded5 --- /dev/null +++ b/docs/examples/messaging/create-vonage-provider.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.create_vonage_provider( + provider_id = '<PROVIDER_ID>', + name = '<NAME>', + from = '+12065550100', # optional + api_key = '<API_KEY>', # optional + api_secret = '<API_SECRET>', # optional + enabled = False # optional +) diff --git a/docs/examples/messaging/delete-provider.md b/docs/examples/messaging/delete-provider.md new file mode 100644 index 0000000..649e504 --- /dev/null +++ b/docs/examples/messaging/delete-provider.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.delete_provider( + provider_id = '<PROVIDER_ID>' +) diff --git a/docs/examples/messaging/delete-subscriber.md b/docs/examples/messaging/delete-subscriber.md new file mode 100644 index 0000000..c012a9a --- /dev/null +++ b/docs/examples/messaging/delete-subscriber.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_jwt('<YOUR_JWT>') # Your secret JSON Web Token + +messaging = Messaging(client) + +result = messaging.delete_subscriber( + topic_id = '<TOPIC_ID>', + subscriber_id = '<SUBSCRIBER_ID>' +) diff --git a/docs/examples/messaging/delete-topic.md b/docs/examples/messaging/delete-topic.md new file mode 100644 index 0000000..76f9093 --- /dev/null +++ b/docs/examples/messaging/delete-topic.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.delete_topic( + topic_id = '<TOPIC_ID>' +) diff --git a/docs/examples/messaging/delete.md b/docs/examples/messaging/delete.md new file mode 100644 index 0000000..0153ac9 --- /dev/null +++ b/docs/examples/messaging/delete.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.delete( + message_id = '<MESSAGE_ID>' +) diff --git a/docs/examples/messaging/get-message.md b/docs/examples/messaging/get-message.md new file mode 100644 index 0000000..3fadcff --- /dev/null +++ b/docs/examples/messaging/get-message.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.get_message( + message_id = '<MESSAGE_ID>' +) diff --git a/docs/examples/messaging/get-provider.md b/docs/examples/messaging/get-provider.md new file mode 100644 index 0000000..58e6228 --- /dev/null +++ b/docs/examples/messaging/get-provider.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.get_provider( + provider_id = '<PROVIDER_ID>' +) diff --git a/docs/examples/messaging/get-subscriber.md b/docs/examples/messaging/get-subscriber.md new file mode 100644 index 0000000..ca997f2 --- /dev/null +++ b/docs/examples/messaging/get-subscriber.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.get_subscriber( + topic_id = '<TOPIC_ID>', + subscriber_id = '<SUBSCRIBER_ID>' +) diff --git a/docs/examples/messaging/get-topic.md b/docs/examples/messaging/get-topic.md new file mode 100644 index 0000000..c238a98 --- /dev/null +++ b/docs/examples/messaging/get-topic.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.get_topic( + topic_id = '<TOPIC_ID>' +) diff --git a/docs/examples/messaging/list-message-logs.md b/docs/examples/messaging/list-message-logs.md new file mode 100644 index 0000000..f28c3e5 --- /dev/null +++ b/docs/examples/messaging/list-message-logs.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.list_message_logs( + message_id = '<MESSAGE_ID>', + queries = [] # optional +) diff --git a/docs/examples/messaging/list-messages.md b/docs/examples/messaging/list-messages.md new file mode 100644 index 0000000..211649d --- /dev/null +++ b/docs/examples/messaging/list-messages.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.list_messages( + queries = [], # optional + search = '<SEARCH>' # optional +) diff --git a/docs/examples/messaging/list-provider-logs.md b/docs/examples/messaging/list-provider-logs.md new file mode 100644 index 0000000..da87e59 --- /dev/null +++ b/docs/examples/messaging/list-provider-logs.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.list_provider_logs( + provider_id = '<PROVIDER_ID>', + queries = [] # optional +) diff --git a/docs/examples/messaging/list-providers.md b/docs/examples/messaging/list-providers.md new file mode 100644 index 0000000..03e5c4e --- /dev/null +++ b/docs/examples/messaging/list-providers.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.list_providers( + queries = [], # optional + search = '<SEARCH>' # optional +) diff --git a/docs/examples/messaging/list-subscriber-logs.md b/docs/examples/messaging/list-subscriber-logs.md new file mode 100644 index 0000000..df8ec72 --- /dev/null +++ b/docs/examples/messaging/list-subscriber-logs.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.list_subscriber_logs( + subscriber_id = '<SUBSCRIBER_ID>', + queries = [] # optional +) diff --git a/docs/examples/messaging/list-subscribers.md b/docs/examples/messaging/list-subscribers.md new file mode 100644 index 0000000..f949b40 --- /dev/null +++ b/docs/examples/messaging/list-subscribers.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.list_subscribers( + topic_id = '<TOPIC_ID>', + queries = [], # optional + search = '<SEARCH>' # optional +) diff --git a/docs/examples/messaging/list-targets.md b/docs/examples/messaging/list-targets.md new file mode 100644 index 0000000..786ee42 --- /dev/null +++ b/docs/examples/messaging/list-targets.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.list_targets( + message_id = '<MESSAGE_ID>', + queries = [] # optional +) diff --git a/docs/examples/messaging/list-topic-logs.md b/docs/examples/messaging/list-topic-logs.md new file mode 100644 index 0000000..f8a3995 --- /dev/null +++ b/docs/examples/messaging/list-topic-logs.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.list_topic_logs( + topic_id = '<TOPIC_ID>', + queries = [] # optional +) diff --git a/docs/examples/messaging/list-topics.md b/docs/examples/messaging/list-topics.md new file mode 100644 index 0000000..1c2cefc --- /dev/null +++ b/docs/examples/messaging/list-topics.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.list_topics( + queries = [], # optional + search = '<SEARCH>' # optional +) diff --git a/docs/examples/messaging/update-apns-provider.md b/docs/examples/messaging/update-apns-provider.md new file mode 100644 index 0000000..f695b61 --- /dev/null +++ b/docs/examples/messaging/update-apns-provider.md @@ -0,0 +1,20 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.update_apns_provider( + provider_id = '<PROVIDER_ID>', + name = '<NAME>', # optional + enabled = False, # optional + auth_key = '<AUTH_KEY>', # optional + auth_key_id = '<AUTH_KEY_ID>', # optional + team_id = '<TEAM_ID>', # optional + bundle_id = '<BUNDLE_ID>', # optional + sandbox = False # optional +) diff --git a/docs/examples/messaging/update-email.md b/docs/examples/messaging/update-email.md new file mode 100644 index 0000000..5731d5f --- /dev/null +++ b/docs/examples/messaging/update-email.md @@ -0,0 +1,24 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.update_email( + message_id = '<MESSAGE_ID>', + topics = [], # optional + users = [], # optional + targets = [], # optional + subject = '<SUBJECT>', # optional + content = '<CONTENT>', # optional + draft = False, # optional + html = False, # optional + cc = [], # optional + bcc = [], # optional + scheduled_at = '', # optional + attachments = [] # optional +) diff --git a/docs/examples/messaging/update-fcm-provider.md b/docs/examples/messaging/update-fcm-provider.md new file mode 100644 index 0000000..0119d71 --- /dev/null +++ b/docs/examples/messaging/update-fcm-provider.md @@ -0,0 +1,16 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.update_fcm_provider( + provider_id = '<PROVIDER_ID>', + name = '<NAME>', # optional + enabled = False, # optional + service_account_json = {} # optional +) diff --git a/docs/examples/messaging/update-mailgun-provider.md b/docs/examples/messaging/update-mailgun-provider.md new file mode 100644 index 0000000..039475f --- /dev/null +++ b/docs/examples/messaging/update-mailgun-provider.md @@ -0,0 +1,22 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.update_mailgun_provider( + provider_id = '<PROVIDER_ID>', + name = '<NAME>', # optional + api_key = '<API_KEY>', # optional + domain = '<DOMAIN>', # optional + is_eu_region = False, # optional + enabled = False, # optional + from_name = '<FROM_NAME>', # optional + from_email = 'email@example.com', # optional + reply_to_name = '<REPLY_TO_NAME>', # optional + reply_to_email = '<REPLY_TO_EMAIL>' # optional +) diff --git a/docs/examples/messaging/update-msg91provider.md b/docs/examples/messaging/update-msg91provider.md new file mode 100644 index 0000000..c5bd057 --- /dev/null +++ b/docs/examples/messaging/update-msg91provider.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.update_msg91_provider( + provider_id = '<PROVIDER_ID>', + name = '<NAME>', # optional + enabled = False, # optional + template_id = '<TEMPLATE_ID>', # optional + sender_id = '<SENDER_ID>', # optional + auth_key = '<AUTH_KEY>' # optional +) diff --git a/docs/examples/messaging/update-push.md b/docs/examples/messaging/update-push.md new file mode 100644 index 0000000..e3bb02e --- /dev/null +++ b/docs/examples/messaging/update-push.md @@ -0,0 +1,31 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.update_push( + message_id = '<MESSAGE_ID>', + topics = [], # optional + users = [], # optional + targets = [], # optional + title = '<TITLE>', # optional + body = '<BODY>', # optional + data = {}, # optional + action = '<ACTION>', # optional + image = '[ID1:ID2]', # optional + icon = '<ICON>', # optional + sound = '<SOUND>', # optional + color = '<COLOR>', # optional + tag = '<TAG>', # optional + badge = None, # optional + draft = False, # optional + scheduled_at = '', # optional + content_available = False, # optional + critical = False, # optional + priority = MessagePriority.NORMAL # optional +) diff --git a/docs/examples/messaging/update-sendgrid-provider.md b/docs/examples/messaging/update-sendgrid-provider.md new file mode 100644 index 0000000..fc0a44d --- /dev/null +++ b/docs/examples/messaging/update-sendgrid-provider.md @@ -0,0 +1,20 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.update_sendgrid_provider( + provider_id = '<PROVIDER_ID>', + name = '<NAME>', # optional + enabled = False, # optional + api_key = '<API_KEY>', # optional + from_name = '<FROM_NAME>', # optional + from_email = 'email@example.com', # optional + reply_to_name = '<REPLY_TO_NAME>', # optional + reply_to_email = '<REPLY_TO_EMAIL>' # optional +) diff --git a/docs/examples/messaging/update-sms.md b/docs/examples/messaging/update-sms.md new file mode 100644 index 0000000..2eec4e2 --- /dev/null +++ b/docs/examples/messaging/update-sms.md @@ -0,0 +1,19 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.update_sms( + message_id = '<MESSAGE_ID>', + topics = [], # optional + users = [], # optional + targets = [], # optional + content = '<CONTENT>', # optional + draft = False, # optional + scheduled_at = '' # optional +) diff --git a/docs/examples/messaging/update-smtp-provider.md b/docs/examples/messaging/update-smtp-provider.md new file mode 100644 index 0000000..80019aa --- /dev/null +++ b/docs/examples/messaging/update-smtp-provider.md @@ -0,0 +1,26 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.update_smtp_provider( + provider_id = '<PROVIDER_ID>', + name = '<NAME>', # optional + host = '<HOST>', # optional + port = 1, # optional + username = '<USERNAME>', # optional + password = '<PASSWORD>', # optional + encryption = SmtpEncryption.NONE, # optional + auto_tls = False, # optional + mailer = '<MAILER>', # optional + from_name = '<FROM_NAME>', # optional + from_email = 'email@example.com', # optional + reply_to_name = '<REPLY_TO_NAME>', # optional + reply_to_email = '<REPLY_TO_EMAIL>', # optional + enabled = False # optional +) diff --git a/docs/examples/messaging/update-telesign-provider.md b/docs/examples/messaging/update-telesign-provider.md new file mode 100644 index 0000000..193a26f --- /dev/null +++ b/docs/examples/messaging/update-telesign-provider.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.update_telesign_provider( + provider_id = '<PROVIDER_ID>', + name = '<NAME>', # optional + enabled = False, # optional + customer_id = '<CUSTOMER_ID>', # optional + api_key = '<API_KEY>', # optional + from = '<FROM>' # optional +) diff --git a/docs/examples/messaging/update-textmagic-provider.md b/docs/examples/messaging/update-textmagic-provider.md new file mode 100644 index 0000000..159f954 --- /dev/null +++ b/docs/examples/messaging/update-textmagic-provider.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.update_textmagic_provider( + provider_id = '<PROVIDER_ID>', + name = '<NAME>', # optional + enabled = False, # optional + username = '<USERNAME>', # optional + api_key = '<API_KEY>', # optional + from = '<FROM>' # optional +) diff --git a/docs/examples/messaging/update-topic.md b/docs/examples/messaging/update-topic.md new file mode 100644 index 0000000..721f160 --- /dev/null +++ b/docs/examples/messaging/update-topic.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.update_topic( + topic_id = '<TOPIC_ID>', + name = '<NAME>', # optional + subscribe = ["any"] # optional +) diff --git a/docs/examples/messaging/update-twilio-provider.md b/docs/examples/messaging/update-twilio-provider.md new file mode 100644 index 0000000..b80c55b --- /dev/null +++ b/docs/examples/messaging/update-twilio-provider.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.update_twilio_provider( + provider_id = '<PROVIDER_ID>', + name = '<NAME>', # optional + enabled = False, # optional + account_sid = '<ACCOUNT_SID>', # optional + auth_token = '<AUTH_TOKEN>', # optional + from = '<FROM>' # optional +) diff --git a/docs/examples/messaging/update-vonage-provider.md b/docs/examples/messaging/update-vonage-provider.md new file mode 100644 index 0000000..b25f416 --- /dev/null +++ b/docs/examples/messaging/update-vonage-provider.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.messaging import Messaging + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +messaging = Messaging(client) + +result = messaging.update_vonage_provider( + provider_id = '<PROVIDER_ID>', + name = '<NAME>', # optional + enabled = False, # optional + api_key = '<API_KEY>', # optional + api_secret = '<API_SECRET>', # optional + from = '<FROM>' # optional +) diff --git a/docs/examples/sites/create-deployment.md b/docs/examples/sites/create-deployment.md new file mode 100644 index 0000000..de6472c --- /dev/null +++ b/docs/examples/sites/create-deployment.md @@ -0,0 +1,19 @@ +from appwrite.client import Client +from appwrite.services.sites import Sites +from appwrite.input_file import InputFile + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +sites = Sites(client) + +result = sites.create_deployment( + site_id = '<SITE_ID>', + code = InputFile.from_path('file.png'), + activate = False, + install_command = '<INSTALL_COMMAND>', # optional + build_command = '<BUILD_COMMAND>', # optional + output_directory = '<OUTPUT_DIRECTORY>' # optional +) diff --git a/docs/examples/sites/create-duplicate-deployment.md b/docs/examples/sites/create-duplicate-deployment.md new file mode 100644 index 0000000..d79ab9d --- /dev/null +++ b/docs/examples/sites/create-duplicate-deployment.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.sites import Sites + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +sites = Sites(client) + +result = sites.create_duplicate_deployment( + site_id = '<SITE_ID>', + deployment_id = '<DEPLOYMENT_ID>' +) diff --git a/docs/examples/sites/create-template-deployment.md b/docs/examples/sites/create-template-deployment.md new file mode 100644 index 0000000..ac05f9e --- /dev/null +++ b/docs/examples/sites/create-template-deployment.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.sites import Sites + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +sites = Sites(client) + +result = sites.create_template_deployment( + site_id = '<SITE_ID>', + repository = '<REPOSITORY>', + owner = '<OWNER>', + root_directory = '<ROOT_DIRECTORY>', + version = '<VERSION>', + activate = False # optional +) diff --git a/docs/examples/sites/create-variable.md b/docs/examples/sites/create-variable.md new file mode 100644 index 0000000..739beff --- /dev/null +++ b/docs/examples/sites/create-variable.md @@ -0,0 +1,16 @@ +from appwrite.client import Client +from appwrite.services.sites import Sites + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +sites = Sites(client) + +result = sites.create_variable( + site_id = '<SITE_ID>', + key = '<KEY>', + value = '<VALUE>', + secret = False # optional +) diff --git a/docs/examples/sites/create-vcs-deployment.md b/docs/examples/sites/create-vcs-deployment.md new file mode 100644 index 0000000..089e6c8 --- /dev/null +++ b/docs/examples/sites/create-vcs-deployment.md @@ -0,0 +1,17 @@ +from appwrite.client import Client +from appwrite.services.sites import Sites +from appwrite.enums import VCSDeploymentType + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +sites = Sites(client) + +result = sites.create_vcs_deployment( + site_id = '<SITE_ID>', + type = VCSDeploymentType.BRANCH, + reference = '<REFERENCE>', + activate = False # optional +) diff --git a/docs/examples/sites/create.md b/docs/examples/sites/create.md new file mode 100644 index 0000000..4950cd2 --- /dev/null +++ b/docs/examples/sites/create.md @@ -0,0 +1,32 @@ +from appwrite.client import Client +from appwrite.services.sites import Sites +from appwrite.enums import +from appwrite.enums import + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +sites = Sites(client) + +result = sites.create( + site_id = '<SITE_ID>', + name = '<NAME>', + framework = .ANALOG, + build_runtime = .NODE_14_5, + enabled = False, # optional + logging = False, # optional + timeout = 1, # optional + install_command = '<INSTALL_COMMAND>', # optional + build_command = '<BUILD_COMMAND>', # optional + output_directory = '<OUTPUT_DIRECTORY>', # optional + adapter = .STATIC, # optional + installation_id = '<INSTALLATION_ID>', # optional + fallback_file = '<FALLBACK_FILE>', # optional + provider_repository_id = '<PROVIDER_REPOSITORY_ID>', # optional + provider_branch = '<PROVIDER_BRANCH>', # optional + provider_silent_mode = False, # optional + provider_root_directory = '<PROVIDER_ROOT_DIRECTORY>', # optional + specification = '' # optional +) diff --git a/docs/examples/sites/delete-deployment.md b/docs/examples/sites/delete-deployment.md new file mode 100644 index 0000000..029730a --- /dev/null +++ b/docs/examples/sites/delete-deployment.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.sites import Sites + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +sites = Sites(client) + +result = sites.delete_deployment( + site_id = '<SITE_ID>', + deployment_id = '<DEPLOYMENT_ID>' +) diff --git a/docs/examples/sites/delete-log.md b/docs/examples/sites/delete-log.md new file mode 100644 index 0000000..0b516e6 --- /dev/null +++ b/docs/examples/sites/delete-log.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.sites import Sites + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +sites = Sites(client) + +result = sites.delete_log( + site_id = '<SITE_ID>', + log_id = '<LOG_ID>' +) diff --git a/docs/examples/sites/delete-variable.md b/docs/examples/sites/delete-variable.md new file mode 100644 index 0000000..c078813 --- /dev/null +++ b/docs/examples/sites/delete-variable.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.sites import Sites + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +sites = Sites(client) + +result = sites.delete_variable( + site_id = '<SITE_ID>', + variable_id = '<VARIABLE_ID>' +) diff --git a/docs/examples/sites/delete.md b/docs/examples/sites/delete.md new file mode 100644 index 0000000..60670e6 --- /dev/null +++ b/docs/examples/sites/delete.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.sites import Sites + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +sites = Sites(client) + +result = sites.delete( + site_id = '<SITE_ID>' +) diff --git a/docs/examples/sites/get-deployment-download.md b/docs/examples/sites/get-deployment-download.md new file mode 100644 index 0000000..d6af564 --- /dev/null +++ b/docs/examples/sites/get-deployment-download.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.sites import Sites + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +sites = Sites(client) + +result = sites.get_deployment_download( + site_id = '<SITE_ID>', + deployment_id = '<DEPLOYMENT_ID>', + type = DeploymentDownloadType.SOURCE # optional +) diff --git a/docs/examples/sites/get-deployment.md b/docs/examples/sites/get-deployment.md new file mode 100644 index 0000000..c4ee1de --- /dev/null +++ b/docs/examples/sites/get-deployment.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.sites import Sites + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +sites = Sites(client) + +result = sites.get_deployment( + site_id = '<SITE_ID>', + deployment_id = '<DEPLOYMENT_ID>' +) diff --git a/docs/examples/sites/get-log.md b/docs/examples/sites/get-log.md new file mode 100644 index 0000000..ae5d8ac --- /dev/null +++ b/docs/examples/sites/get-log.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.sites import Sites + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +sites = Sites(client) + +result = sites.get_log( + site_id = '<SITE_ID>', + log_id = '<LOG_ID>' +) diff --git a/docs/examples/sites/get-variable.md b/docs/examples/sites/get-variable.md new file mode 100644 index 0000000..7f5f0f6 --- /dev/null +++ b/docs/examples/sites/get-variable.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.sites import Sites + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +sites = Sites(client) + +result = sites.get_variable( + site_id = '<SITE_ID>', + variable_id = '<VARIABLE_ID>' +) diff --git a/docs/examples/sites/get.md b/docs/examples/sites/get.md new file mode 100644 index 0000000..f9532a0 --- /dev/null +++ b/docs/examples/sites/get.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.sites import Sites + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +sites = Sites(client) + +result = sites.get( + site_id = '<SITE_ID>' +) diff --git a/docs/examples/sites/list-deployments.md b/docs/examples/sites/list-deployments.md new file mode 100644 index 0000000..15ec24d --- /dev/null +++ b/docs/examples/sites/list-deployments.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.sites import Sites + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +sites = Sites(client) + +result = sites.list_deployments( + site_id = '<SITE_ID>', + queries = [], # optional + search = '<SEARCH>' # optional +) diff --git a/docs/examples/sites/list-frameworks.md b/docs/examples/sites/list-frameworks.md new file mode 100644 index 0000000..6e37646 --- /dev/null +++ b/docs/examples/sites/list-frameworks.md @@ -0,0 +1,11 @@ +from appwrite.client import Client +from appwrite.services.sites import Sites + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +sites = Sites(client) + +result = sites.list_frameworks() diff --git a/docs/examples/sites/list-logs.md b/docs/examples/sites/list-logs.md new file mode 100644 index 0000000..d3a9a19 --- /dev/null +++ b/docs/examples/sites/list-logs.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.sites import Sites + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +sites = Sites(client) + +result = sites.list_logs( + site_id = '<SITE_ID>', + queries = [] # optional +) diff --git a/docs/examples/sites/list-specifications.md b/docs/examples/sites/list-specifications.md new file mode 100644 index 0000000..93b713c --- /dev/null +++ b/docs/examples/sites/list-specifications.md @@ -0,0 +1,11 @@ +from appwrite.client import Client +from appwrite.services.sites import Sites + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +sites = Sites(client) + +result = sites.list_specifications() diff --git a/docs/examples/sites/list-variables.md b/docs/examples/sites/list-variables.md new file mode 100644 index 0000000..5ff78e6 --- /dev/null +++ b/docs/examples/sites/list-variables.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.sites import Sites + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +sites = Sites(client) + +result = sites.list_variables( + site_id = '<SITE_ID>' +) diff --git a/docs/examples/sites/list.md b/docs/examples/sites/list.md new file mode 100644 index 0000000..1b344e1 --- /dev/null +++ b/docs/examples/sites/list.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.sites import Sites + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +sites = Sites(client) + +result = sites.list( + queries = [], # optional + search = '<SEARCH>' # optional +) diff --git a/docs/examples/sites/update-deployment-status.md b/docs/examples/sites/update-deployment-status.md new file mode 100644 index 0000000..492ee4f --- /dev/null +++ b/docs/examples/sites/update-deployment-status.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.sites import Sites + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +sites = Sites(client) + +result = sites.update_deployment_status( + site_id = '<SITE_ID>', + deployment_id = '<DEPLOYMENT_ID>' +) diff --git a/docs/examples/sites/update-site-deployment.md b/docs/examples/sites/update-site-deployment.md new file mode 100644 index 0000000..69014bb --- /dev/null +++ b/docs/examples/sites/update-site-deployment.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.sites import Sites + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +sites = Sites(client) + +result = sites.update_site_deployment( + site_id = '<SITE_ID>', + deployment_id = '<DEPLOYMENT_ID>' +) diff --git a/docs/examples/sites/update-variable.md b/docs/examples/sites/update-variable.md new file mode 100644 index 0000000..973f7f2 --- /dev/null +++ b/docs/examples/sites/update-variable.md @@ -0,0 +1,17 @@ +from appwrite.client import Client +from appwrite.services.sites import Sites + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +sites = Sites(client) + +result = sites.update_variable( + site_id = '<SITE_ID>', + variable_id = '<VARIABLE_ID>', + key = '<KEY>', + value = '<VALUE>', # optional + secret = False # optional +) diff --git a/docs/examples/sites/update.md b/docs/examples/sites/update.md new file mode 100644 index 0000000..7d2d286 --- /dev/null +++ b/docs/examples/sites/update.md @@ -0,0 +1,31 @@ +from appwrite.client import Client +from appwrite.services.sites import Sites +from appwrite.enums import + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +sites = Sites(client) + +result = sites.update( + site_id = '<SITE_ID>', + name = '<NAME>', + framework = .ANALOG, + enabled = False, # optional + logging = False, # optional + timeout = 1, # optional + install_command = '<INSTALL_COMMAND>', # optional + build_command = '<BUILD_COMMAND>', # optional + output_directory = '<OUTPUT_DIRECTORY>', # optional + build_runtime = .NODE_14_5, # optional + adapter = .STATIC, # optional + fallback_file = '<FALLBACK_FILE>', # optional + installation_id = '<INSTALLATION_ID>', # optional + provider_repository_id = '<PROVIDER_REPOSITORY_ID>', # optional + provider_branch = '<PROVIDER_BRANCH>', # optional + provider_silent_mode = False, # optional + provider_root_directory = '<PROVIDER_ROOT_DIRECTORY>', # optional + specification = '' # optional +) diff --git a/docs/examples/storage/create-bucket.md b/docs/examples/storage/create-bucket.md new file mode 100644 index 0000000..9672782 --- /dev/null +++ b/docs/examples/storage/create-bucket.md @@ -0,0 +1,22 @@ +from appwrite.client import Client +from appwrite.services.storage import Storage + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +storage = Storage(client) + +result = storage.create_bucket( + bucket_id = '<BUCKET_ID>', + name = '<NAME>', + permissions = ["read("any")"], # optional + file_security = False, # optional + enabled = False, # optional + maximum_file_size = 1, # optional + allowed_file_extensions = [], # optional + compression = .NONE, # optional + encryption = False, # optional + antivirus = False # optional +) diff --git a/docs/examples/storage/create-file.md b/docs/examples/storage/create-file.md index 11a1f65..6e57284 100644 --- a/docs/examples/storage/create-file.md +++ b/docs/examples/storage/create-file.md @@ -1,14 +1,17 @@ from appwrite.client import Client from appwrite.services.storage import Storage +from appwrite.input_file import InputFile client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_session('') # The user session to authenticate with storage = Storage(client) -result = storage.create_file('[FILE_ID]', open('/path/to/file.png', 'rb')) +result = storage.create_file( + bucket_id = '<BUCKET_ID>', + file_id = '<FILE_ID>', + file = InputFile.from_path('file.png'), + permissions = ["read("any")"] # optional +) diff --git a/docs/examples/storage/delete-bucket.md b/docs/examples/storage/delete-bucket.md new file mode 100644 index 0000000..dd8e8eb --- /dev/null +++ b/docs/examples/storage/delete-bucket.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.storage import Storage + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +storage = Storage(client) + +result = storage.delete_bucket( + bucket_id = '<BUCKET_ID>' +) diff --git a/docs/examples/storage/delete-file.md b/docs/examples/storage/delete-file.md index 9379cb8..17bc251 100644 --- a/docs/examples/storage/delete-file.md +++ b/docs/examples/storage/delete-file.md @@ -2,13 +2,13 @@ from appwrite.client import Client from appwrite.services.storage import Storage client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_session('') # The user session to authenticate with storage = Storage(client) -result = storage.delete_file('[FILE_ID]') +result = storage.delete_file( + bucket_id = '<BUCKET_ID>', + file_id = '<FILE_ID>' +) diff --git a/docs/examples/storage/get-bucket.md b/docs/examples/storage/get-bucket.md new file mode 100644 index 0000000..e5eeb4c --- /dev/null +++ b/docs/examples/storage/get-bucket.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.storage import Storage + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +storage = Storage(client) + +result = storage.get_bucket( + bucket_id = '<BUCKET_ID>' +) diff --git a/docs/examples/storage/get-file-download.md b/docs/examples/storage/get-file-download.md index bc815ce..411abf8 100644 --- a/docs/examples/storage/get-file-download.md +++ b/docs/examples/storage/get-file-download.md @@ -2,13 +2,14 @@ from appwrite.client import Client from appwrite.services.storage import Storage client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_session('') # The user session to authenticate with storage = Storage(client) -result = storage.get_file_download('[FILE_ID]') +result = storage.get_file_download( + bucket_id = '<BUCKET_ID>', + file_id = '<FILE_ID>', + token = '<TOKEN>' # optional +) diff --git a/docs/examples/storage/get-file-preview.md b/docs/examples/storage/get-file-preview.md index 2d14539..47e3f23 100644 --- a/docs/examples/storage/get-file-preview.md +++ b/docs/examples/storage/get-file-preview.md @@ -2,13 +2,25 @@ from appwrite.client import Client from appwrite.services.storage import Storage client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_session('') # The user session to authenticate with storage = Storage(client) -result = storage.get_file_preview('[FILE_ID]') +result = storage.get_file_preview( + bucket_id = '<BUCKET_ID>', + file_id = '<FILE_ID>', + width = 0, # optional + height = 0, # optional + gravity = ImageGravity.CENTER, # optional + quality = -1, # optional + border_width = 0, # optional + border_color = '', # optional + border_radius = 0, # optional + opacity = 0, # optional + rotation = -360, # optional + background = '', # optional + output = ImageFormat.JPG, # optional + token = '<TOKEN>' # optional +) diff --git a/docs/examples/storage/get-file-view.md b/docs/examples/storage/get-file-view.md index 7d0b30b..85cbad7 100644 --- a/docs/examples/storage/get-file-view.md +++ b/docs/examples/storage/get-file-view.md @@ -2,13 +2,14 @@ from appwrite.client import Client from appwrite.services.storage import Storage client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_session('') # The user session to authenticate with storage = Storage(client) -result = storage.get_file_view('[FILE_ID]') +result = storage.get_file_view( + bucket_id = '<BUCKET_ID>', + file_id = '<FILE_ID>', + token = '<TOKEN>' # optional +) diff --git a/docs/examples/storage/get-file.md b/docs/examples/storage/get-file.md index e8d1202..461543e 100644 --- a/docs/examples/storage/get-file.md +++ b/docs/examples/storage/get-file.md @@ -2,13 +2,13 @@ from appwrite.client import Client from appwrite.services.storage import Storage client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_session('') # The user session to authenticate with storage = Storage(client) -result = storage.get_file('[FILE_ID]') +result = storage.get_file( + bucket_id = '<BUCKET_ID>', + file_id = '<FILE_ID>' +) diff --git a/docs/examples/storage/list-buckets.md b/docs/examples/storage/list-buckets.md new file mode 100644 index 0000000..51a1ae6 --- /dev/null +++ b/docs/examples/storage/list-buckets.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.storage import Storage + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +storage = Storage(client) + +result = storage.list_buckets( + queries = [], # optional + search = '<SEARCH>' # optional +) diff --git a/docs/examples/storage/list-files.md b/docs/examples/storage/list-files.md index 0e72773..4034bd4 100644 --- a/docs/examples/storage/list-files.md +++ b/docs/examples/storage/list-files.md @@ -2,13 +2,14 @@ from appwrite.client import Client from appwrite.services.storage import Storage client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_session('') # The user session to authenticate with storage = Storage(client) -result = storage.list_files() +result = storage.list_files( + bucket_id = '<BUCKET_ID>', + queries = [], # optional + search = '<SEARCH>' # optional +) diff --git a/docs/examples/storage/update-bucket.md b/docs/examples/storage/update-bucket.md new file mode 100644 index 0000000..f2e741a --- /dev/null +++ b/docs/examples/storage/update-bucket.md @@ -0,0 +1,22 @@ +from appwrite.client import Client +from appwrite.services.storage import Storage + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +storage = Storage(client) + +result = storage.update_bucket( + bucket_id = '<BUCKET_ID>', + name = '<NAME>', + permissions = ["read("any")"], # optional + file_security = False, # optional + enabled = False, # optional + maximum_file_size = 1, # optional + allowed_file_extensions = [], # optional + compression = .NONE, # optional + encryption = False, # optional + antivirus = False # optional +) diff --git a/docs/examples/storage/update-file.md b/docs/examples/storage/update-file.md index 7e1c5f6..cf1e577 100644 --- a/docs/examples/storage/update-file.md +++ b/docs/examples/storage/update-file.md @@ -2,13 +2,15 @@ from appwrite.client import Client from appwrite.services.storage import Storage client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_session('') # The user session to authenticate with storage = Storage(client) -result = storage.update_file('[FILE_ID]', [], []) +result = storage.update_file( + bucket_id = '<BUCKET_ID>', + file_id = '<FILE_ID>', + name = '<NAME>', # optional + permissions = ["read("any")"] # optional +) diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index 9e2c832..cb3bf73 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -2,13 +2,18 @@ from appwrite.client import Client from appwrite.services.teams import Teams client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_session('') # The user session to authenticate with teams = Teams(client) -result = teams.create_membership('[TEAM_ID]', 'email@example.com', [], 'https://example.com') +result = teams.create_membership( + team_id = '<TEAM_ID>', + roles = [], + email = 'email@example.com', # optional + user_id = '<USER_ID>', # optional + phone = '+12065550100', # optional + url = 'https://example.com', # optional + name = '<NAME>' # optional +) diff --git a/docs/examples/teams/create.md b/docs/examples/teams/create.md index 36b4494..f623151 100644 --- a/docs/examples/teams/create.md +++ b/docs/examples/teams/create.md @@ -2,13 +2,14 @@ from appwrite.client import Client from appwrite.services.teams import Teams client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_session('') # The user session to authenticate with teams = Teams(client) -result = teams.create('[TEAM_ID]', '[NAME]') +result = teams.create( + team_id = '<TEAM_ID>', + name = '<NAME>', + roles = [] # optional +) diff --git a/docs/examples/teams/delete-membership.md b/docs/examples/teams/delete-membership.md index 50c259a..6fb2182 100644 --- a/docs/examples/teams/delete-membership.md +++ b/docs/examples/teams/delete-membership.md @@ -2,13 +2,13 @@ from appwrite.client import Client from appwrite.services.teams import Teams client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_session('') # The user session to authenticate with teams = Teams(client) -result = teams.delete_membership('[TEAM_ID]', '[MEMBERSHIP_ID]') +result = teams.delete_membership( + team_id = '<TEAM_ID>', + membership_id = '<MEMBERSHIP_ID>' +) diff --git a/docs/examples/teams/delete.md b/docs/examples/teams/delete.md index 8fb037c..056114b 100644 --- a/docs/examples/teams/delete.md +++ b/docs/examples/teams/delete.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.teams import Teams client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_session('') # The user session to authenticate with teams = Teams(client) -result = teams.delete('[TEAM_ID]') +result = teams.delete( + team_id = '<TEAM_ID>' +) diff --git a/docs/examples/teams/get-membership.md b/docs/examples/teams/get-membership.md index 2586e94..3c028a5 100644 --- a/docs/examples/teams/get-membership.md +++ b/docs/examples/teams/get-membership.md @@ -2,13 +2,13 @@ from appwrite.client import Client from appwrite.services.teams import Teams client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_session('') # The user session to authenticate with teams = Teams(client) -result = teams.get_membership('[TEAM_ID]', '[MEMBERSHIP_ID]') +result = teams.get_membership( + team_id = '<TEAM_ID>', + membership_id = '<MEMBERSHIP_ID>' +) diff --git a/docs/examples/teams/get-memberships.md b/docs/examples/teams/get-memberships.md deleted file mode 100644 index 6c64824..0000000 --- a/docs/examples/teams/get-memberships.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.teams import Teams - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -teams = Teams(client) - -result = teams.get_memberships('[TEAM_ID]') diff --git a/docs/examples/teams/get-prefs.md b/docs/examples/teams/get-prefs.md new file mode 100644 index 0000000..8d64589 --- /dev/null +++ b/docs/examples/teams/get-prefs.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.teams import Teams + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_session('') # The user session to authenticate with + +teams = Teams(client) + +result = teams.get_prefs( + team_id = '<TEAM_ID>' +) diff --git a/docs/examples/teams/get.md b/docs/examples/teams/get.md index 6c2b404..55f172e 100644 --- a/docs/examples/teams/get.md +++ b/docs/examples/teams/get.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.teams import Teams client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_session('') # The user session to authenticate with teams = Teams(client) -result = teams.get('[TEAM_ID]') +result = teams.get( + team_id = '<TEAM_ID>' +) diff --git a/docs/examples/teams/list-memberships.md b/docs/examples/teams/list-memberships.md new file mode 100644 index 0000000..6e6f15a --- /dev/null +++ b/docs/examples/teams/list-memberships.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.teams import Teams + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_session('') # The user session to authenticate with + +teams = Teams(client) + +result = teams.list_memberships( + team_id = '<TEAM_ID>', + queries = [], # optional + search = '<SEARCH>' # optional +) diff --git a/docs/examples/teams/list.md b/docs/examples/teams/list.md index c538aea..bf91a50 100644 --- a/docs/examples/teams/list.md +++ b/docs/examples/teams/list.md @@ -2,13 +2,13 @@ from appwrite.client import Client from appwrite.services.teams import Teams client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_session('') # The user session to authenticate with teams = Teams(client) -result = teams.list() +result = teams.list( + queries = [], # optional + search = '<SEARCH>' # optional +) diff --git a/docs/examples/teams/update-membership-roles.md b/docs/examples/teams/update-membership-roles.md deleted file mode 100644 index d637dd6..0000000 --- a/docs/examples/teams/update-membership-roles.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.teams import Teams - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -teams = Teams(client) - -result = teams.update_membership_roles('[TEAM_ID]', '[MEMBERSHIP_ID]', []) diff --git a/docs/examples/teams/update-membership-status.md b/docs/examples/teams/update-membership-status.md index 357d409..9c08421 100644 --- a/docs/examples/teams/update-membership-status.md +++ b/docs/examples/teams/update-membership-status.md @@ -2,13 +2,15 @@ from appwrite.client import Client from appwrite.services.teams import Teams client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_jwt('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token -) +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_session('') # The user session to authenticate with teams = Teams(client) -result = teams.update_membership_status('[TEAM_ID]', '[MEMBERSHIP_ID]', '[USER_ID]', '[SECRET]') +result = teams.update_membership_status( + team_id = '<TEAM_ID>', + membership_id = '<MEMBERSHIP_ID>', + user_id = '<USER_ID>', + secret = '<SECRET>' +) diff --git a/docs/examples/teams/update-membership.md b/docs/examples/teams/update-membership.md new file mode 100644 index 0000000..db20c5a --- /dev/null +++ b/docs/examples/teams/update-membership.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.teams import Teams + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_session('') # The user session to authenticate with + +teams = Teams(client) + +result = teams.update_membership( + team_id = '<TEAM_ID>', + membership_id = '<MEMBERSHIP_ID>', + roles = [] +) diff --git a/docs/examples/teams/update-name.md b/docs/examples/teams/update-name.md new file mode 100644 index 0000000..160b496 --- /dev/null +++ b/docs/examples/teams/update-name.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.teams import Teams + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_session('') # The user session to authenticate with + +teams = Teams(client) + +result = teams.update_name( + team_id = '<TEAM_ID>', + name = '<NAME>' +) diff --git a/docs/examples/teams/update-prefs.md b/docs/examples/teams/update-prefs.md new file mode 100644 index 0000000..e82da1b --- /dev/null +++ b/docs/examples/teams/update-prefs.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.teams import Teams + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_session('') # The user session to authenticate with + +teams = Teams(client) + +result = teams.update_prefs( + team_id = '<TEAM_ID>', + prefs = {} +) diff --git a/docs/examples/teams/update.md b/docs/examples/teams/update.md deleted file mode 100644 index 2b9c222..0000000 --- a/docs/examples/teams/update.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.teams import Teams - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -teams = Teams(client) - -result = teams.update('[TEAM_ID]', '[NAME]') diff --git a/docs/examples/tokens/create-file-token.md b/docs/examples/tokens/create-file-token.md new file mode 100644 index 0000000..f835a0e --- /dev/null +++ b/docs/examples/tokens/create-file-token.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.tokens import Tokens + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +tokens = Tokens(client) + +result = tokens.create_file_token( + bucket_id = '<BUCKET_ID>', + file_id = '<FILE_ID>', + expire = '' # optional +) diff --git a/docs/examples/tokens/delete.md b/docs/examples/tokens/delete.md new file mode 100644 index 0000000..4761932 --- /dev/null +++ b/docs/examples/tokens/delete.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.tokens import Tokens + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +tokens = Tokens(client) + +result = tokens.delete( + token_id = '<TOKEN_ID>' +) diff --git a/docs/examples/tokens/get.md b/docs/examples/tokens/get.md new file mode 100644 index 0000000..0d6abb8 --- /dev/null +++ b/docs/examples/tokens/get.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.tokens import Tokens + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +tokens = Tokens(client) + +result = tokens.get( + token_id = '<TOKEN_ID>' +) diff --git a/docs/examples/tokens/list.md b/docs/examples/tokens/list.md new file mode 100644 index 0000000..2694650 --- /dev/null +++ b/docs/examples/tokens/list.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.tokens import Tokens + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +tokens = Tokens(client) + +result = tokens.list( + bucket_id = '<BUCKET_ID>', + file_id = '<FILE_ID>', + queries = [] # optional +) diff --git a/docs/examples/tokens/update.md b/docs/examples/tokens/update.md new file mode 100644 index 0000000..18b0444 --- /dev/null +++ b/docs/examples/tokens/update.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.tokens import Tokens + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +tokens = Tokens(client) + +result = tokens.update( + token_id = '<TOKEN_ID>', + expire = '' # optional +) diff --git a/docs/examples/users/create-argon2user.md b/docs/examples/users/create-argon2user.md new file mode 100644 index 0000000..5e95cc2 --- /dev/null +++ b/docs/examples/users/create-argon2user.md @@ -0,0 +1,16 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users(client) + +result = users.create_argon2_user( + user_id = '<USER_ID>', + email = 'email@example.com', + password = 'password', + name = '<NAME>' # optional +) diff --git a/docs/examples/users/create-bcrypt-user.md b/docs/examples/users/create-bcrypt-user.md new file mode 100644 index 0000000..d3d9e21 --- /dev/null +++ b/docs/examples/users/create-bcrypt-user.md @@ -0,0 +1,16 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users(client) + +result = users.create_bcrypt_user( + user_id = '<USER_ID>', + email = 'email@example.com', + password = 'password', + name = '<NAME>' # optional +) diff --git a/docs/examples/users/create-j-w-t.md b/docs/examples/users/create-j-w-t.md new file mode 100644 index 0000000..bed6c48 --- /dev/null +++ b/docs/examples/users/create-j-w-t.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users(client) + +result = users.create_jwt( + user_id = '<USER_ID>', + session_id = '<SESSION_ID>', # optional + duration = 0 # optional +) diff --git a/docs/examples/users/create-m-d5user.md b/docs/examples/users/create-m-d5user.md new file mode 100644 index 0000000..b1cbb53 --- /dev/null +++ b/docs/examples/users/create-m-d5user.md @@ -0,0 +1,16 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users(client) + +result = users.create_md5_user( + user_id = '<USER_ID>', + email = 'email@example.com', + password = 'password', + name = '<NAME>' # optional +) diff --git a/docs/examples/users/create-mfa-recovery-codes.md b/docs/examples/users/create-mfa-recovery-codes.md new file mode 100644 index 0000000..64a87c0 --- /dev/null +++ b/docs/examples/users/create-mfa-recovery-codes.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users(client) + +result = users.create_mfa_recovery_codes( + user_id = '<USER_ID>' +) diff --git a/docs/examples/users/create-p-h-pass-user.md b/docs/examples/users/create-p-h-pass-user.md new file mode 100644 index 0000000..33f65f4 --- /dev/null +++ b/docs/examples/users/create-p-h-pass-user.md @@ -0,0 +1,16 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users(client) + +result = users.create_ph_pass_user( + user_id = '<USER_ID>', + email = 'email@example.com', + password = 'password', + name = '<NAME>' # optional +) diff --git a/docs/examples/users/create-s-h-a-user.md b/docs/examples/users/create-s-h-a-user.md new file mode 100644 index 0000000..5b4c8f8 --- /dev/null +++ b/docs/examples/users/create-s-h-a-user.md @@ -0,0 +1,17 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users(client) + +result = users.create_sha_user( + user_id = '<USER_ID>', + email = 'email@example.com', + password = 'password', + password_version = PasswordHash.SHA1, # optional + name = '<NAME>' # optional +) diff --git a/docs/examples/users/create-scrypt-modified-user.md b/docs/examples/users/create-scrypt-modified-user.md new file mode 100644 index 0000000..9d644ce --- /dev/null +++ b/docs/examples/users/create-scrypt-modified-user.md @@ -0,0 +1,19 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users(client) + +result = users.create_scrypt_modified_user( + user_id = '<USER_ID>', + email = 'email@example.com', + password = 'password', + password_salt = '<PASSWORD_SALT>', + password_salt_separator = '<PASSWORD_SALT_SEPARATOR>', + password_signer_key = '<PASSWORD_SIGNER_KEY>', + name = '<NAME>' # optional +) diff --git a/docs/examples/users/create-scrypt-user.md b/docs/examples/users/create-scrypt-user.md new file mode 100644 index 0000000..f442ab9 --- /dev/null +++ b/docs/examples/users/create-scrypt-user.md @@ -0,0 +1,21 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users(client) + +result = users.create_scrypt_user( + user_id = '<USER_ID>', + email = 'email@example.com', + password = 'password', + password_salt = '<PASSWORD_SALT>', + password_cpu = None, + password_memory = None, + password_parallel = None, + password_length = None, + name = '<NAME>' # optional +) diff --git a/docs/examples/users/create-session.md b/docs/examples/users/create-session.md new file mode 100644 index 0000000..7e4c49f --- /dev/null +++ b/docs/examples/users/create-session.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users(client) + +result = users.create_session( + user_id = '<USER_ID>' +) diff --git a/docs/examples/users/create-target.md b/docs/examples/users/create-target.md new file mode 100644 index 0000000..dfa64ac --- /dev/null +++ b/docs/examples/users/create-target.md @@ -0,0 +1,19 @@ +from appwrite.client import Client +from appwrite.services.users import Users +from appwrite.enums import MessagingProviderType + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users(client) + +result = users.create_target( + user_id = '<USER_ID>', + target_id = '<TARGET_ID>', + provider_type = MessagingProviderType.EMAIL, + identifier = '<IDENTIFIER>', + provider_id = '<PROVIDER_ID>', # optional + name = '<NAME>' # optional +) diff --git a/docs/examples/users/create-token.md b/docs/examples/users/create-token.md new file mode 100644 index 0000000..b40658c --- /dev/null +++ b/docs/examples/users/create-token.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users(client) + +result = users.create_token( + user_id = '<USER_ID>', + length = 4, # optional + expire = 60 # optional +) diff --git a/docs/examples/users/create.md b/docs/examples/users/create.md index 6fbd16f..4c51a3f 100644 --- a/docs/examples/users/create.md +++ b/docs/examples/users/create.md @@ -2,13 +2,16 @@ from appwrite.client import Client from appwrite.services.users import Users client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.create('[USER_ID]', 'email@example.com', 'password') +result = users.create( + user_id = '<USER_ID>', + email = 'email@example.com', # optional + phone = '+12065550100', # optional + password = '', # optional + name = '<NAME>' # optional +) diff --git a/docs/examples/users/delete-identity.md b/docs/examples/users/delete-identity.md new file mode 100644 index 0000000..412fbd3 --- /dev/null +++ b/docs/examples/users/delete-identity.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users(client) + +result = users.delete_identity( + identity_id = '<IDENTITY_ID>' +) diff --git a/docs/examples/users/delete-mfa-authenticator.md b/docs/examples/users/delete-mfa-authenticator.md new file mode 100644 index 0000000..6472498 --- /dev/null +++ b/docs/examples/users/delete-mfa-authenticator.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.users import Users +from appwrite.enums import AuthenticatorType + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users(client) + +result = users.delete_mfa_authenticator( + user_id = '<USER_ID>', + type = AuthenticatorType.TOTP +) diff --git a/docs/examples/users/delete-session.md b/docs/examples/users/delete-session.md index d25cfb3..815a96e 100644 --- a/docs/examples/users/delete-session.md +++ b/docs/examples/users/delete-session.md @@ -2,13 +2,13 @@ from appwrite.client import Client from appwrite.services.users import Users client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.delete_session('[USER_ID]', '[SESSION_ID]') +result = users.delete_session( + user_id = '<USER_ID>', + session_id = '<SESSION_ID>' +) diff --git a/docs/examples/users/delete-sessions.md b/docs/examples/users/delete-sessions.md index 9b24db1..2dde88f 100644 --- a/docs/examples/users/delete-sessions.md +++ b/docs/examples/users/delete-sessions.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.users import Users client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.delete_sessions('[USER_ID]') +result = users.delete_sessions( + user_id = '<USER_ID>' +) diff --git a/docs/examples/users/delete-target.md b/docs/examples/users/delete-target.md new file mode 100644 index 0000000..287f5a2 --- /dev/null +++ b/docs/examples/users/delete-target.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users(client) + +result = users.delete_target( + user_id = '<USER_ID>', + target_id = '<TARGET_ID>' +) diff --git a/docs/examples/users/delete.md b/docs/examples/users/delete.md index 820eead..7032b0f 100644 --- a/docs/examples/users/delete.md +++ b/docs/examples/users/delete.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.users import Users client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.delete('[USER_ID]') +result = users.delete( + user_id = '<USER_ID>' +) diff --git a/docs/examples/users/get-logs.md b/docs/examples/users/get-logs.md deleted file mode 100644 index c93ae24..0000000 --- a/docs/examples/users/get-logs.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.users import Users - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -users = Users(client) - -result = users.get_logs('[USER_ID]') diff --git a/docs/examples/users/get-mfa-recovery-codes.md b/docs/examples/users/get-mfa-recovery-codes.md new file mode 100644 index 0000000..bca43b0 --- /dev/null +++ b/docs/examples/users/get-mfa-recovery-codes.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users(client) + +result = users.get_mfa_recovery_codes( + user_id = '<USER_ID>' +) diff --git a/docs/examples/users/get-prefs.md b/docs/examples/users/get-prefs.md index 9ef100f..ec9d363 100644 --- a/docs/examples/users/get-prefs.md +++ b/docs/examples/users/get-prefs.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.users import Users client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.get_prefs('[USER_ID]') +result = users.get_prefs( + user_id = '<USER_ID>' +) diff --git a/docs/examples/users/get-sessions.md b/docs/examples/users/get-sessions.md deleted file mode 100644 index 4de3120..0000000 --- a/docs/examples/users/get-sessions.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.users import Users - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -users = Users(client) - -result = users.get_sessions('[USER_ID]') diff --git a/docs/examples/users/get-target.md b/docs/examples/users/get-target.md new file mode 100644 index 0000000..3b80b1f --- /dev/null +++ b/docs/examples/users/get-target.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users(client) + +result = users.get_target( + user_id = '<USER_ID>', + target_id = '<TARGET_ID>' +) diff --git a/docs/examples/users/get.md b/docs/examples/users/get.md index c11f96e..267086a 100644 --- a/docs/examples/users/get.md +++ b/docs/examples/users/get.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.users import Users client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.get('[USER_ID]') +result = users.get( + user_id = '<USER_ID>' +) diff --git a/docs/examples/users/list-identities.md b/docs/examples/users/list-identities.md new file mode 100644 index 0000000..0fc7811 --- /dev/null +++ b/docs/examples/users/list-identities.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users(client) + +result = users.list_identities( + queries = [], # optional + search = '<SEARCH>' # optional +) diff --git a/docs/examples/users/list-logs.md b/docs/examples/users/list-logs.md new file mode 100644 index 0000000..6cbbe49 --- /dev/null +++ b/docs/examples/users/list-logs.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users(client) + +result = users.list_logs( + user_id = '<USER_ID>', + queries = [] # optional +) diff --git a/docs/examples/users/list-memberships.md b/docs/examples/users/list-memberships.md new file mode 100644 index 0000000..c0d2f2a --- /dev/null +++ b/docs/examples/users/list-memberships.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users(client) + +result = users.list_memberships( + user_id = '<USER_ID>', + queries = [], # optional + search = '<SEARCH>' # optional +) diff --git a/docs/examples/users/list-mfa-factors.md b/docs/examples/users/list-mfa-factors.md new file mode 100644 index 0000000..a2b5989 --- /dev/null +++ b/docs/examples/users/list-mfa-factors.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users(client) + +result = users.list_mfa_factors( + user_id = '<USER_ID>' +) diff --git a/docs/examples/users/list-sessions.md b/docs/examples/users/list-sessions.md new file mode 100644 index 0000000..77b04c9 --- /dev/null +++ b/docs/examples/users/list-sessions.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users(client) + +result = users.list_sessions( + user_id = '<USER_ID>' +) diff --git a/docs/examples/users/list-targets.md b/docs/examples/users/list-targets.md new file mode 100644 index 0000000..14107fa --- /dev/null +++ b/docs/examples/users/list-targets.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users(client) + +result = users.list_targets( + user_id = '<USER_ID>', + queries = [] # optional +) diff --git a/docs/examples/users/list.md b/docs/examples/users/list.md index c4a66e4..778f339 100644 --- a/docs/examples/users/list.md +++ b/docs/examples/users/list.md @@ -2,13 +2,13 @@ from appwrite.client import Client from appwrite.services.users import Users client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.list() +result = users.list( + queries = [], # optional + search = '<SEARCH>' # optional +) diff --git a/docs/examples/users/update-email-verification.md b/docs/examples/users/update-email-verification.md new file mode 100644 index 0000000..2605861 --- /dev/null +++ b/docs/examples/users/update-email-verification.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users(client) + +result = users.update_email_verification( + user_id = '<USER_ID>', + email_verification = False +) diff --git a/docs/examples/users/update-email.md b/docs/examples/users/update-email.md index 1803623..c4a468e 100644 --- a/docs/examples/users/update-email.md +++ b/docs/examples/users/update-email.md @@ -2,13 +2,13 @@ from appwrite.client import Client from appwrite.services.users import Users client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.update_email('[USER_ID]', 'email@example.com') +result = users.update_email( + user_id = '<USER_ID>', + email = 'email@example.com' +) diff --git a/docs/examples/users/update-labels.md b/docs/examples/users/update-labels.md new file mode 100644 index 0000000..b9af53a --- /dev/null +++ b/docs/examples/users/update-labels.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users(client) + +result = users.update_labels( + user_id = '<USER_ID>', + labels = [] +) diff --git a/docs/examples/users/update-mfa-recovery-codes.md b/docs/examples/users/update-mfa-recovery-codes.md new file mode 100644 index 0000000..c0990e1 --- /dev/null +++ b/docs/examples/users/update-mfa-recovery-codes.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users(client) + +result = users.update_mfa_recovery_codes( + user_id = '<USER_ID>' +) diff --git a/docs/examples/users/update-mfa.md b/docs/examples/users/update-mfa.md new file mode 100644 index 0000000..9b35701 --- /dev/null +++ b/docs/examples/users/update-mfa.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users(client) + +result = users.update_mfa( + user_id = '<USER_ID>', + mfa = False +) diff --git a/docs/examples/users/update-name.md b/docs/examples/users/update-name.md index 728940d..1e328b4 100644 --- a/docs/examples/users/update-name.md +++ b/docs/examples/users/update-name.md @@ -2,13 +2,13 @@ from appwrite.client import Client from appwrite.services.users import Users client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.update_name('[USER_ID]', '[NAME]') +result = users.update_name( + user_id = '<USER_ID>', + name = '<NAME>' +) diff --git a/docs/examples/users/update-password.md b/docs/examples/users/update-password.md index 56b15e7..d104184 100644 --- a/docs/examples/users/update-password.md +++ b/docs/examples/users/update-password.md @@ -2,13 +2,13 @@ from appwrite.client import Client from appwrite.services.users import Users client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.update_password('[USER_ID]', 'password') +result = users.update_password( + user_id = '<USER_ID>', + password = '' +) diff --git a/docs/examples/users/update-phone-verification.md b/docs/examples/users/update-phone-verification.md new file mode 100644 index 0000000..1d2656c --- /dev/null +++ b/docs/examples/users/update-phone-verification.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users(client) + +result = users.update_phone_verification( + user_id = '<USER_ID>', + phone_verification = False +) diff --git a/docs/examples/users/update-phone.md b/docs/examples/users/update-phone.md new file mode 100644 index 0000000..14826bb --- /dev/null +++ b/docs/examples/users/update-phone.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users(client) + +result = users.update_phone( + user_id = '<USER_ID>', + number = '+12065550100' +) diff --git a/docs/examples/users/update-prefs.md b/docs/examples/users/update-prefs.md index 7e0fe7c..76903b7 100644 --- a/docs/examples/users/update-prefs.md +++ b/docs/examples/users/update-prefs.md @@ -2,13 +2,13 @@ from appwrite.client import Client from appwrite.services.users import Users client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.update_prefs('[USER_ID]', {}) +result = users.update_prefs( + user_id = '<USER_ID>', + prefs = {} +) diff --git a/docs/examples/users/update-status.md b/docs/examples/users/update-status.md index 55b32b1..49c0516 100644 --- a/docs/examples/users/update-status.md +++ b/docs/examples/users/update-status.md @@ -2,13 +2,13 @@ from appwrite.client import Client from appwrite.services.users import Users client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.update_status('[USER_ID]', False) +result = users.update_status( + user_id = '<USER_ID>', + status = False +) diff --git a/docs/examples/users/update-target.md b/docs/examples/users/update-target.md new file mode 100644 index 0000000..119c5fa --- /dev/null +++ b/docs/examples/users/update-target.md @@ -0,0 +1,17 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users(client) + +result = users.update_target( + user_id = '<USER_ID>', + target_id = '<TARGET_ID>', + identifier = '<IDENTIFIER>', # optional + provider_id = '<PROVIDER_ID>', # optional + name = '<NAME>' # optional +) diff --git a/docs/examples/users/update-verification.md b/docs/examples/users/update-verification.md deleted file mode 100644 index 6923e03..0000000 --- a/docs/examples/users/update-verification.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.users import Users - -client = Client() - -(client - .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -users = Users(client) - -result = users.update_verification('[USER_ID]', False) diff --git a/requirements.txt b/requirements.txt index 4f5b899..2c24336 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -requests==2.26.0 \ No newline at end of file +requests==2.31.0 diff --git a/setup.cfg b/setup.cfg index 224a779..0f94f37 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,2 @@ [metadata] -description-file = README.md \ No newline at end of file +description_file = README.md \ No newline at end of file diff --git a/setup.py b/setup.py index d92d176..18c78cc 100644 --- a/setup.py +++ b/setup.py @@ -1,21 +1,32 @@ import setuptools +long_description: str + +with open("README.md", "r", encoding="utf-8") as readme_file_desc: + long_description = readme_file_desc.read() + setuptools.setup( name = 'appwrite', - packages = ['appwrite', 'appwrite/services'], - version = '0.6.1', + packages = [ + 'appwrite', + 'appwrite/services', + 'appwrite/encoders', + 'appwrite/enums', + ], + version = '11.1.0', license='BSD-3-Clause', description = 'Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API', + long_description = long_description, + long_description_content_type = 'text/markdown', author = 'Appwrite Team', author_email = 'team@appwrite.io', maintainer = 'Appwrite Team', maintainer_email = 'team@appwrite.io', url = 'https://appwrite.io/support', - download_url='https://github.com/appwrite/sdk-for-python/archive/0.6.1.tar.gz', - # keywords = ['SOME', 'MEANINGFULL', 'KEYWORDS'], + download_url='https://github.com/appwrite/sdk-for-python/archive/11.1.0.tar.gz', install_requires=[ - 'requests', - ], + 'requests', + ], classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers',