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 104c53f..0000000 --- a/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -language: python - -dist: bionic - -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 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 47cfdfb..c1602fc 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2023 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: diff --git a/README.md b/README.md index 86bb1c4..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-1.4.2-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 1.4.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 @@ -46,7 +46,7 @@ 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 @@ -66,7 +66,7 @@ client = Client() users = Users(client) -result = users.create(ID.unique(), 'email@example.com', 'password') +result = users.create(ID.unique(), email = "email@example.com", phone = "+123456789", password = "password", name = "Walter O'Brien") ``` ### Error Handling @@ -75,7 +75,7 @@ The Appwrite Python SDK raises `AppwriteException` object with `message`, `code` ```python users = Users(client) try: - result = users.create(ID.unique(), '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 73f97c1..ed4d4b5 100644 --- a/appwrite/client.py +++ b/appwrite/client.py @@ -1,22 +1,25 @@ import io -import requests +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': '', - 'user-agent' : 'AppwritePythonSDK/4.0.0 (${os.uname().sysname}; ${os.uname().version}; ${os.uname().machine})', + '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': '4.0.0', - 'X-Appwrite-Response-Format' : '1.4.0', + 'x-sdk-version': '11.1.0', + 'X-Appwrite-Response-Format' : '1.7.0', } def set_self_signed(self, status=True): @@ -24,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 @@ -53,7 +59,19 @@ 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 = {} @@ -63,10 +81,9 @@ def call(self, method, path='', headers=None, params=None): 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': @@ -74,8 +91,7 @@ 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'] @@ -84,23 +100,33 @@ def call(self, method, path='', headers=None, params=None): 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, stringify=stringify), - data=self.flatten(data), - json=json, + 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() @@ -109,9 +135,9 @@ 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().get('type'), 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) @@ -148,12 +174,11 @@ def chunked_upload( offset = 0 counter = 0 - if upload_id != 'unique()': - try: - result = self.call('get', path + '/' + upload_id, headers) - counter = result['chunksUploaded'] - except: - pass + try: + result = self.call('get', path + '/' + upload_id, headers) + counter = result['chunksUploaded'] + except: + pass if counter > 0: offset = counter * self._chunk_size @@ -166,7 +191,7 @@ def chunked_upload( if offset + self._chunk_size < size: end = offset + self._chunk_size else: - end = size - offset + end = size input_file.data = input[offset:end] params[param_name] = input_file @@ -178,10 +203,10 @@ def chunked_upload( headers, params, ) - + offset = offset + self._chunk_size - - if "$id" in result: + + if "$id" in result: headers["x-appwrite-id"] = result["$id"] if on_progress is not None: @@ -207,7 +232,7 @@ def flatten(self, data, prefix='', stringify=False): 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, stringify)} else: @@ -217,4 +242,3 @@ def flatten(self, data, prefix='', stringify=False): 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/id.py b/appwrite/id.py index a9ed5f3..0be3040 100644 --- a/appwrite/id.py +++ b/appwrite/id.py @@ -1,8 +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(): - return 'unique()' \ No newline at end of file + 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 index 9f11b0c..33d5a77 100644 --- a/appwrite/input_file.py +++ b/appwrite/input_file.py @@ -12,7 +12,7 @@ def from_path(cls, path): return instance @classmethod - def from_bytes(cls, bytes, filename = None, mime_type = None): + def from_bytes(cls, bytes, filename, mime_type = None): instance = cls() instance.data = bytes instance.filename = filename diff --git a/appwrite/query.py b/appwrite/query.py index da63672..f25e33d 100644 --- a/appwrite/query.py +++ b/appwrite/query.py @@ -1,92 +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.add_query(attribute, "equal", value) + return str(Query("equal", attribute, value)) @staticmethod def not_equal(attribute, value): - return Query.add_query(attribute, "notEqual", value) - + return str(Query("notEqual", attribute, value)) + @staticmethod def less_than(attribute, value): - return Query.add_query(attribute, "lessThan", value) - + return str(Query("lessThan", attribute, value)) + @staticmethod def less_than_equal(attribute, value): - return Query.add_query(attribute, "lessThanEqual", value) - + return str(Query("lessThanEqual", attribute, value)) + @staticmethod def greater_than(attribute, value): - return Query.add_query(attribute, "greaterThan", value) - + return str(Query("greaterThan", attribute, value)) + @staticmethod def greater_than_equal(attribute, value): - return Query.add_query(attribute, "greaterThanEqual", value) + return str(Query("greaterThanEqual", attribute, value)) @staticmethod def is_null(attribute): - return f'isNull("{attribute}")' + return str(Query("isNull", attribute, None)) @staticmethod def is_not_null(attribute): - return f'isNotNull("{attribute}")' + return str(Query("isNotNull", attribute, None)) @staticmethod def between(attribute, start, end): - return Query.add_query(attribute, "between", [start, end]) + return str(Query("between", attribute, [start, end])) @staticmethod def starts_with(attribute, value): - return Query.add_query(attribute, "startsWith", value) + return str(Query("startsWith", attribute, value)) @staticmethod def ends_with(attribute, value): - return Query.add_query(attribute, "endsWith", value) + return str(Query("endsWith", attribute, value)) @staticmethod def select(attributes): - return f'select([{",".join(map(Query.parseValues, attributes))}])' + return str(Query("select", None, attributes)) @staticmethod def search(attribute, value): - return Query.add_query(attribute, "search", value) + return str(Query("search", attribute, value)) @staticmethod def order_asc(attribute): - return f'orderAsc("{attribute}")' + return str(Query("orderAsc", attribute, None)) @staticmethod def order_desc(attribute): - return f'orderDesc("{attribute}")' + return str(Query("orderDesc", attribute, None)) @staticmethod def cursor_before(id): - return f'cursorBefore("{id}")' + return str(Query("cursorBefore", None, id)) @staticmethod def cursor_after(id): - return f'cursorAfter("{id}")' + return str(Query("cursorAfter", None, id)) @staticmethod def limit(limit): - return f'limit({limit})' + return str(Query("limit", None, limit)) @staticmethod def offset(offset): - return f'offset({offset})' + return str(Query("offset", None, offset)) + + @staticmethod + def contains(attribute, value): + return str(Query("contains", attribute, value)) @staticmethod - def add_query(attribute, method, value): - if type(value) == list: - return f'{method}("{attribute}", [{",".join(map(Query.parseValues, value))}])' - else: - return f'{method}("{attribute}", [{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 f'"{value}"' - elif type(value) == bool: - return str(value).lower() - else: - return str(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/services/account.py b/appwrite/services/account.py index 29ab85c..6062ad4 100644 --- a/appwrite/services/account.py +++ b/appwrite/services/account.py @@ -1,26 +1,109 @@ 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"') + + if email is None: + raise AppwriteException('Missing required parameter: "email"') + + if password is None: + raise AppwriteException('Missing required parameter: "password"') + + + 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 update_email(self, email, password): - """Update Email""" + 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: @@ -37,23 +120,56 @@ def update_email(self, email, password): 'content-type': 'application/json', }, api_params) - def list_identities(self, queries = None): - """List Identities""" + 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, { - 'content-type': 'application/json', }, api_params) - def delete_identity(self, identity_id): - """Delete Identity""" + 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: @@ -66,23 +182,374 @@ def delete_identity(self, identity_id): 'content-type': 'application/json', }, api_params) - def list_logs(self, queries = None): - """List Logs""" + 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 update_name(self, name): - """Update Name""" + 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: @@ -95,10 +562,29 @@ def update_name(self, name): 'content-type': 'application/json', }, api_params) - def update_password(self, password, old_password = None): - """Update Password""" + 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: @@ -112,10 +598,29 @@ def update_password(self, password, old_password = None): 'content-type': 'application/json', }, api_params) - def update_phone(self, phone, password): - """Update Phone""" + 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: @@ -132,21 +637,48 @@ def update_phone(self, phone, password): 'content-type': 'application/json', }, api_params) - def get_prefs(self): - """Get Account Preferences""" + 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, { - 'content-type': 'application/json', }, api_params) - def update_prefs(self, prefs): - """Update Preferences""" + 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: @@ -159,10 +691,29 @@ def update_prefs(self, prefs): 'content-type': 'application/json', }, api_params) - def create_recovery(self, email, url): - """Create Password Recovery""" + 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: @@ -179,10 +730,33 @@ def create_recovery(self, email, url): 'content-type': 'application/json', }, api_params) - def update_recovery(self, user_id, secret, password, password_again): - """Create Password Recovery (confirmation)""" + 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: @@ -194,34 +768,51 @@ def update_recovery(self, user_id, secret, password, password_again): 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 api_params['password'] = password - api_params['passwordAgain'] = password_again return self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) - def list_sessions(self): - """List Sessions""" + 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, { - 'content-type': 'application/json', }, api_params) - def delete_sessions(self): - """Delete Sessions""" + 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 = {} @@ -229,10 +820,207 @@ def delete_sessions(self): 'content-type': 'application/json', }, api_params) - def get_session(self, session_id): - """Get Session""" + 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"') + + if password is None: + raise AppwriteException('Missing required parameter: "password"') + + + 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"') + + if secret is None: + raise AppwriteException('Missing required parameter: "secret"') + + + api_params['userId'] = user_id + api_params['secret'] = secret + + return self.client.call('put', api_path, { + 'content-type': 'application/json', + }, 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"') + + + 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: + raise AppwriteException('Missing required parameter: "secret"') + + + api_params['userId'] = user_id + api_params['secret'] = secret + + 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: @@ -242,13 +1030,29 @@ def get_session(self, session_id): return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def update_session(self, session_id): - """Update OAuth Session (Refresh Tokens)""" + 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. + + 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: @@ -261,10 +1065,27 @@ def update_session(self, session_id): 'content-type': 'application/json', }, api_params) - def delete_session(self, session_id): - """Delete Session""" + 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: @@ -277,10 +1098,21 @@ def delete_session(self, session_id): 'content-type': 'application/json', }, api_params) - def update_status(self): - """Update Status""" + 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 = {} @@ -288,10 +1120,208 @@ def update_status(self): 'content-type': 'application/json', }, api_params) - def create_verification(self, url): - """Create Email Verification""" + 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"') + + if email is None: + raise AppwriteException('Missing required parameter: "email"') + + + api_params['userId'] = user_id + api_params['email'] = email + api_params['phrase'] = phrase + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, 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"') + + if email is None: + raise AppwriteException('Missing required parameter: "email"') + + + api_params['userId'] = user_id + api_params['email'] = email + api_params['url'] = url + api_params['phrase'] = phrase + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, 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"') + + + 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: @@ -304,10 +1334,29 @@ def create_verification(self, url): 'content-type': 'application/json', }, api_params) - def update_verification(self, user_id, secret): - """Create Email Verification (confirmation)""" + 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: @@ -324,10 +1373,21 @@ def update_verification(self, user_id, secret): 'content-type': 'application/json', }, api_params) - def create_phone_verification(self): - """Create Phone Verification""" + 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 = {} @@ -335,10 +1395,29 @@ def create_phone_verification(self): 'content-type': 'application/json', }, api_params) - def update_phone_verification(self, user_id, secret): - """Create Phone Verification (confirmation)""" + 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: diff --git a/appwrite/services/avatars.py b/appwrite/services/avatars.py index 6b7ed84..2bd32f7 100644 --- a/appwrite/services/avatars.py +++ b/appwrite/services/avatars.py @@ -1,15 +1,44 @@ 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""" - + 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: @@ -22,13 +51,38 @@ def get_browser(self, code, width = None, height = None, quality = None): api_params['quality'] = quality return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def get_credit_card(self, code, width = None, height = None, quality = None): - """Get Credit Card Icon""" + 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: @@ -41,13 +95,31 @@ def get_credit_card(self, code, width = None, height = None, quality = None): api_params['quality'] = quality return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def get_favicon(self, url): - """Get Favicon""" + 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: @@ -57,13 +129,38 @@ def get_favicon(self, url): api_params['url'] = url return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def get_flag(self, code, width = None, height = None, quality = None): - """Get Country Flag""" + 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: @@ -76,13 +173,37 @@ def get_flag(self, code, width = None, height = None, quality = None): api_params['quality'] = quality return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def get_image(self, url, width = None, height = None): - """Get Image from URL""" + 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: @@ -94,13 +215,40 @@ def get_image(self, url, width = None, height = None): api_params['height'] = height return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def get_initials(self, name = None, width = None, height = None, background = None): - """Get User Initials""" + 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 = {} @@ -110,13 +258,36 @@ def get_initials(self, name = None, width = None, height = None, background = No api_params['background'] = background return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def get_qr(self, text, size = None, margin = None, download = None): - """Get QR Code""" + 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: @@ -129,5 +300,4 @@ def get_qr(self, text, size = None, margin = None, download = None): api_params['download'] = download return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) diff --git a/appwrite/services/databases.py b/appwrite/services/databases.py index 1a8384c..40b7372 100644 --- a/appwrite/services/databases.py +++ b/appwrite/services/databases.py @@ -1,15 +1,38 @@ 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): + def __init__(self, client) -> None: super(Databases, self).__init__(client) - def list(self, queries = None, search = None): - """List Databases""" + 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 = {} @@ -17,13 +40,34 @@ def list(self, queries = None, search = None): api_params['search'] = search return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def create(self, database_id, name, enabled = None): - """Create Database""" + 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: @@ -41,10 +85,27 @@ def create(self, database_id, name, enabled = None): 'content-type': 'application/json', }, api_params) - def get(self, database_id): - """Get Database""" + 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: @@ -54,13 +115,33 @@ def get(self, database_id): return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def update(self, database_id, name, enabled = None): - """Update Database""" + 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: @@ -78,10 +159,27 @@ def update(self, database_id, name, enabled = None): 'content-type': 'application/json', }, api_params) - def delete(self, database_id): - """Delete Database""" + 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: @@ -94,10 +192,31 @@ def delete(self, database_id): 'content-type': 'application/json', }, api_params) - def list_collections(self, database_id, queries = None, search = None): - """List Collections""" + 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: @@ -109,13 +228,39 @@ def list_collections(self, database_id, queries = None, search = None): api_params['search'] = search return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def create_collection(self, database_id, collection_id, name, permissions = None, document_security = None, enabled = None): - """Create Collection""" - + 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: @@ -139,10 +284,29 @@ def create_collection(self, database_id, collection_id, name, permissions = None 'content-type': 'application/json', }, api_params) - def get_collection(self, database_id, collection_id): - """Get Collection""" + 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: @@ -156,13 +320,39 @@ def get_collection(self, database_id, collection_id): return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def update_collection(self, database_id, collection_id, name, permissions = None, document_security = None, enabled = None): - """Update Collection""" - + 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: @@ -186,10 +376,29 @@ def update_collection(self, database_id, collection_id, name, permissions = None 'content-type': 'application/json', }, api_params) - def delete_collection(self, database_id, collection_id): - """Delete Collection""" + 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: @@ -206,10 +415,31 @@ def delete_collection(self, database_id, collection_id): 'content-type': 'application/json', }, api_params) - def list_attributes(self, database_id, collection_id, queries = None): - """List Attributes""" + 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: @@ -224,13 +454,40 @@ def list_attributes(self, database_id, collection_id, queries = None): api_params['queries'] = queries return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def create_boolean_attribute(self, database_id, collection_id, key, required, default = None, array = None): - """Create Boolean Attribute""" + 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: @@ -257,10 +514,37 @@ def create_boolean_attribute(self, database_id, collection_id, key, required, de 'content-type': 'application/json', }, api_params) - def update_boolean_attribute(self, database_id, collection_id, key, required, default): - """Update Boolean Attribute""" - + 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: @@ -281,15 +565,43 @@ def update_boolean_attribute(self, database_id, collection_id, key, required, de 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, collection_id, key, required, default = None, array = None): - """Create DateTime Attribute""" - + 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: @@ -316,10 +628,37 @@ def create_datetime_attribute(self, database_id, collection_id, key, required, d 'content-type': 'application/json', }, api_params) - def update_datetime_attribute(self, database_id, collection_id, key, required, default): - """Update DateTime Attribute""" - + 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: @@ -340,15 +679,44 @@ def update_datetime_attribute(self, database_id, collection_id, key, required, d 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, collection_id, key, required, default = None, array = None): - """Create Email Attribute""" + 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: @@ -375,10 +743,38 @@ def create_email_attribute(self, database_id, collection_id, key, required, defa 'content-type': 'application/json', }, api_params) - def update_email_attribute(self, database_id, collection_id, key, required, default): - """Update Email Attribute""" + 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: @@ -399,15 +795,46 @@ def update_email_attribute(self, database_id, collection_id, key, required, defa 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, collection_id, key, elements, required, default = None, array = None): - """Create Enum Attribute""" + 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: @@ -438,10 +865,40 @@ def create_enum_attribute(self, database_id, collection_id, key, elements, requi 'content-type': 'application/json', }, api_params) - def update_enum_attribute(self, database_id, collection_id, key, elements, required, default): - """Update Enum Attribute""" + 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: @@ -466,15 +923,48 @@ def update_enum_attribute(self, database_id, collection_id, key, elements, requi 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, collection_id, key, required, min = None, max = None, default = None, array = None): - """Create Float Attribute""" + 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: @@ -503,10 +993,42 @@ def create_float_attribute(self, database_id, collection_id, key, required, min 'content-type': 'application/json', }, api_params) - def update_float_attribute(self, database_id, collection_id, key, required, min, max, default): - """Update Float Attribute""" + 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: @@ -521,12 +1043,6 @@ def update_float_attribute(self, database_id, collection_id, key, required, min, if required is None: raise AppwriteException('Missing required parameter: "required"') - if min is None: - raise AppwriteException('Missing required parameter: "min"') - - if max is None: - raise AppwriteException('Missing required parameter: "max"') - api_path = api_path.replace('{databaseId}', database_id) api_path = api_path.replace('{collectionId}', collection_id) api_path = api_path.replace('{key}', key) @@ -535,15 +1051,48 @@ def update_float_attribute(self, database_id, collection_id, key, required, min, 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, collection_id, key, required, min = None, max = None, default = None, array = None): - """Create Integer Attribute""" + 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: @@ -572,10 +1121,42 @@ def create_integer_attribute(self, database_id, collection_id, key, required, mi 'content-type': 'application/json', }, api_params) - def update_integer_attribute(self, database_id, collection_id, key, required, min, max, default): - """Update Integer Attribute""" + 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: @@ -590,12 +1171,6 @@ def update_integer_attribute(self, database_id, collection_id, key, required, mi if required is None: raise AppwriteException('Missing required parameter: "required"') - if min is None: - raise AppwriteException('Missing required parameter: "min"') - - if max is None: - raise AppwriteException('Missing required parameter: "max"') - api_path = api_path.replace('{databaseId}', database_id) api_path = api_path.replace('{collectionId}', collection_id) api_path = api_path.replace('{key}', key) @@ -604,15 +1179,44 @@ def update_integer_attribute(self, database_id, collection_id, key, required, mi 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, collection_id, key, required, default = None, array = None): - """Create IP Address Attribute""" + 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: @@ -639,10 +1243,38 @@ def create_ip_attribute(self, database_id, collection_id, key, required, default 'content-type': 'application/json', }, api_params) - def update_ip_attribute(self, database_id, collection_id, key, required, default): - """Update IP Address Attribute""" + 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: @@ -663,15 +1295,48 @@ def update_ip_attribute(self, database_id, collection_id, key, required, default 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, collection_id, related_collection_id, type, two_way = None, key = None, two_way_key = None, on_delete = None): - """Create Relationship Attribute""" + 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: @@ -700,10 +1365,42 @@ def create_relationship_attribute(self, database_id, collection_id, related_coll 'content-type': 'application/json', }, api_params) - def create_string_attribute(self, database_id, collection_id, key, size, required, default = None, array = None, encrypt = None): - """Create String Attribute""" + 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: @@ -735,10 +1432,40 @@ def create_string_attribute(self, database_id, collection_id, key, size, require 'content-type': 'application/json', }, api_params) - def update_string_attribute(self, database_id, collection_id, key, required, default): - """Update String Attribute""" + 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: @@ -759,15 +1486,45 @@ def update_string_attribute(self, database_id, collection_id, key, required, def 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, collection_id, key, required, default = None, array = None): - """Create URL Attribute""" + 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: @@ -794,10 +1551,38 @@ def create_url_attribute(self, database_id, collection_id, key, required, defaul 'content-type': 'application/json', }, api_params) - def update_url_attribute(self, database_id, collection_id, key, required, default): - """Update URL Attribute""" + 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: @@ -818,15 +1603,37 @@ def update_url_attribute(self, database_id, collection_id, key, required, defaul 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, collection_id, key): - """Get Attribute""" + 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: @@ -844,13 +1651,33 @@ def get_attribute(self, database_id, collection_id, key): return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def delete_attribute(self, database_id, collection_id, key): - """Delete Attribute""" + 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: @@ -871,10 +1698,36 @@ def delete_attribute(self, database_id, collection_id, key): 'content-type': 'application/json', }, api_params) - def update_relationship_attribute(self, database_id, collection_id, key, on_delete = None): - """Update Relationship Attribute""" + 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: @@ -891,15 +1744,37 @@ def update_relationship_attribute(self, database_id, collection_id, key, on_dele 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, collection_id, queries = None): - """List Documents""" + 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: @@ -914,13 +1789,37 @@ def list_documents(self, database_id, collection_id, queries = None): api_params['queries'] = queries return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def create_document(self, database_id, collection_id, document_id, data, permissions = None): - """Create Document""" - + 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: @@ -946,10 +1845,219 @@ def create_document(self, database_id, collection_id, document_id, data, permiss 'content-type': 'application/json', }, api_params) - def get_document(self, database_id, collection_id, document_id, queries = None): - """Get Document""" + 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: @@ -968,13 +2076,93 @@ def get_document(self, database_id, collection_id, document_id, queries = None): api_params['queries'] = queries return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def update_document(self, database_id, collection_id, document_id, data = None, permissions = None): - """Update Document""" + 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: @@ -997,10 +2185,31 @@ def update_document(self, database_id, collection_id, document_id, data = None, 'content-type': 'application/json', }, api_params) - def delete_document(self, database_id, collection_id, document_id): - """Delete Document""" + 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: @@ -1021,10 +2230,145 @@ def delete_document(self, database_id, collection_id, document_id): 'content-type': 'application/json', }, api_params) - def list_indexes(self, database_id, collection_id, queries = None): - """List Indexes""" + 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: @@ -1039,13 +2383,42 @@ def list_indexes(self, database_id, collection_id, queries = None): api_params['queries'] = queries return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def create_index(self, database_id, collection_id, key, type, attributes, orders = None): - """Create Index""" - + 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: @@ -1070,15 +2443,37 @@ def create_index(self, database_id, collection_id, key, type, attributes, orders 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, collection_id, key): - """Get Index""" + 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: @@ -1096,13 +2491,33 @@ def get_index(self, database_id, collection_id, key): return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def delete_index(self, database_id, collection_id, key): - """Delete Index""" + 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: diff --git a/appwrite/services/functions.py b/appwrite/services/functions.py index a08e7eb..3dd2459 100644 --- a/appwrite/services/functions.py +++ b/appwrite/services/functions.py @@ -1,15 +1,40 @@ 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, queries = None, search = None): - """List Functions""" + 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 = {} @@ -17,13 +42,63 @@ def list(self, queries = None, search = None): api_params['search'] = search return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def create(self, function_id, name, runtime, execute = None, events = None, schedule = None, timeout = None, enabled = None, logging = None, entrypoint = None, commands = None, installation_id = None, provider_repository_id = None, provider_branch = None, provider_silent_mode = None, provider_root_directory = None, template_repository = None, template_owner = None, template_root_directory = None, template_branch = None): - """Create Function""" - + 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: @@ -47,35 +122,81 @@ def create(self, function_id, name, runtime, execute = None, events = None, sche 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['templateRepository'] = template_repository - api_params['templateOwner'] = template_owner - api_params['templateRootDirectory'] = template_root_directory - api_params['templateBranch'] = template_branch + api_params['specification'] = specification return self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def list_runtimes(self): - """List runtimes""" + 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, { - 'content-type': 'application/json', }, api_params) - def get(self, function_id): - """Get Function""" + 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: @@ -85,13 +206,63 @@ def get(self, function_id): return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def update(self, function_id, name, runtime = None, execute = None, events = None, schedule = None, timeout = None, enabled = None, logging = None, entrypoint = None, commands = None, installation_id = None, provider_repository_id = None, provider_branch = None, provider_silent_mode = None, provider_root_directory = None): - """Update Function""" - + 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: @@ -112,20 +283,39 @@ def update(self, function_id, name, runtime = None, execute = None, events = Non 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', }, api_params) - def delete(self, function_id): - """Delete Function""" + 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: @@ -138,10 +328,70 @@ def delete(self, function_id): 'content-type': 'application/json', }, api_params) - def list_deployments(self, function_id, queries = None, search = None): - """List Deployments""" + 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"') + + if deployment_id is None: + raise AppwriteException('Missing required parameter: "deployment_id"') + + api_path = api_path.replace('{functionId}', function_id) + + api_params['deploymentId'] = deployment_id + + 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: @@ -153,13 +403,43 @@ def list_deployments(self, function_id, queries = None, search = None): api_params['search'] = search return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def create_deployment(self, function_id, code, activate, entrypoint = None, commands = None, on_progress = None): - """Create Deployment""" - + 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: @@ -187,11 +467,32 @@ def create_deployment(self, function_id, code, activate, entrypoint = None, comm 'content-type': 'multipart/form-data', }, api_params, param_name, on_progress, upload_id) - def get_deployment(self, function_id, deployment_id): - """Get Deployment""" + 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. - api_path = '/functions/{functionId}/deployments/{deploymentId}' + 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"') @@ -200,17 +501,149 @@ def get_deployment(self, function_id, deployment_id): 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['deploymentId'] = deployment_id + api_params['buildId'] = build_id - return self.client.call('get', api_path, { + return self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_deployment(self, function_id, deployment_id): - """Update Function Deployment""" + 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"') + + 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('{functionId}', function_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, 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"') + + 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('{functionId}', function_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, 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: @@ -223,14 +656,32 @@ def update_deployment(self, function_id, deployment_id): api_path = api_path.replace('{deploymentId}', deployment_id) - return self.client.call('patch', api_path, { - 'content-type': 'application/json', + return self.client.call('get', api_path, { }, api_params) - def delete_deployment(self, function_id, deployment_id): - """Delete Deployment""" + 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: @@ -247,11 +698,32 @@ def delete_deployment(self, function_id, deployment_id): 'content-type': 'application/json', }, api_params) - def create_build(self, function_id, deployment_id, build_id): - """Create Build""" + 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 - api_path = '/functions/{functionId}/deployments/{deploymentId}/builds/{buildId}' + 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"') @@ -259,23 +731,38 @@ def create_build(self, function_id, deployment_id, build_id): if deployment_id is None: raise AppwriteException('Missing required parameter: "deployment_id"') - if build_id is None: - raise AppwriteException('Missing required parameter: "build_id"') - api_path = api_path.replace('{functionId}', function_id) api_path = api_path.replace('{deploymentId}', deployment_id) - api_path = api_path.replace('{buildId}', build_id) + api_params['type'] = type - return self.client.call('post', api_path, { - 'content-type': 'application/json', + return self.client.call('get', api_path, { }, api_params) - def download_deployment(self, function_id, deployment_id): - """Download Deployment""" + 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. - api_path = '/functions/{functionId}/deployments/{deploymentId}/download' + 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"') @@ -287,14 +774,33 @@ def download_deployment(self, function_id, deployment_id): api_path = api_path.replace('{deploymentId}', deployment_id) - return self.client.call('get', api_path, { + return self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def list_executions(self, function_id, queries = None, search = None): - """List Executions""" + 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: @@ -303,16 +809,43 @@ def list_executions(self, function_id, queries = None, search = None): api_path = api_path.replace('{functionId}', function_id) api_params['queries'] = queries - api_params['search'] = search return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def create_execution(self, function_id, body = None, xasync = None, path = None, method = None, headers = None): - """Create Execution""" - + 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: @@ -325,15 +858,35 @@ def create_execution(self, function_id, body = None, xasync = None, path = None, api_params['path'] = path api_params['method'] = method api_params['headers'] = headers + api_params['scheduledAt'] = scheduled_at return self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def get_execution(self, function_id, execution_id): - """Get Execution""" + 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: @@ -347,13 +900,68 @@ def get_execution(self, function_id, 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 execution_id is None: + raise AppwriteException('Missing required parameter: "execution_id"') + + api_path = api_path.replace('{functionId}', function_id) + api_path = api_path.replace('{executionId}', execution_id) + + + return self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def list_variables(self, function_id): - """List Variables""" + 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: @@ -363,13 +971,35 @@ def list_variables(self, function_id): return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def create_variable(self, function_id, key, value): - """Create Variable""" - + 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: @@ -385,15 +1015,35 @@ def create_variable(self, function_id, key, value): 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, function_id, variable_id): - """Get Variable""" + 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: @@ -407,13 +1057,37 @@ def get_variable(self, function_id, variable_id): return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def update_variable(self, function_id, variable_id, key, value = None): - """Update Variable""" - + 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: @@ -430,15 +1104,35 @@ def update_variable(self, function_id, variable_id, key, value = None): 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, function_id, variable_id): - """Delete Variable""" + 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: diff --git a/appwrite/services/graphql.py b/appwrite/services/graphql.py index 7f9d87d..69ad4e0 100644 --- a/appwrite/services/graphql.py +++ b/appwrite/services/graphql.py @@ -1,15 +1,33 @@ from ..service import Service +from typing import List, Dict, Any from ..exception import AppwriteException class Graphql(Service): - def __init__(self, client): + def __init__(self, client) -> None: super(Graphql, self).__init__(client) - def query(self, query): - """GraphQL Endpoint""" + 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: @@ -23,10 +41,27 @@ def query(self, query): 'content-type': 'application/json', }, api_params) - def mutation(self, query): - """GraphQL Endpoint""" + 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: diff --git a/appwrite/services/health.py b/appwrite/services/health.py index 15bd0db..665fd1e 100644 --- a/appwrite/services/health.py +++ b/appwrite/services/health.py @@ -1,139 +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""" + 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, { - 'content-type': 'application/json', }, api_params) - def get_antivirus(self): - """Get Antivirus""" + 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, { - 'content-type': 'application/json', }, api_params) - def get_cache(self): - """Get Cache""" + 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, { - 'content-type': 'application/json', }, api_params) - def get_db(self): - """Get DB""" + 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, { - 'content-type': 'application/json', }, api_params) - def get_pub_sub(self): - """Get PubSub""" + 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, { - 'content-type': 'application/json', }, api_params) - def get_queue(self): - """Get Queue""" + 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. - api_path = '/health/queue' + 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, { - 'content-type': 'application/json', }, api_params) - def get_queue_certificates(self): - """Get Certificates Queue""" + 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, { - 'content-type': 'application/json', }, api_params) - def get_queue_functions(self): - """Get Functions Queue""" + 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, { - 'content-type': 'application/json', }, api_params) - def get_queue_logs(self): - """Get Logs Queue""" + 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, { - 'content-type': 'application/json', }, api_params) - def get_queue_webhooks(self): - """Get Webhooks Queue""" + 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, { - 'content-type': 'application/json', }, api_params) - def get_storage_local(self): - """Get Local Storage""" + 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, { - 'content-type': 'application/json', }, api_params) - def get_time(self): - """Get Time""" + 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, { - 'content-type': 'application/json', }, api_params) diff --git a/appwrite/services/locale.py b/appwrite/services/locale.py index 8216ac4..c34ddee 100644 --- a/appwrite/services/locale.py +++ b/appwrite/services/locale.py @@ -1,95 +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""" + 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, { - 'content-type': 'application/json', }, api_params) - def list_codes(self): - """List Locale Codes""" + 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, { - 'content-type': 'application/json', }, api_params) - def list_continents(self): - """List Continents""" + 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, { - 'content-type': 'application/json', }, api_params) - def list_countries(self): - """List Countries""" + 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, { - 'content-type': 'application/json', }, api_params) - def list_countries_eu(self): - """List EU Countries""" + 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, { - 'content-type': 'application/json', }, api_params) - def list_countries_phones(self): - """List Countries Phone Codes""" + 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, { - 'content-type': 'application/json', }, api_params) - def list_currencies(self): - """List Currencies""" + 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, { - 'content-type': 'application/json', }, api_params) - def list_languages(self): - """List Languages""" + 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, { - 'content-type': 'application/json', }, 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 48f1220..e970187 100644 --- a/appwrite/services/storage.py +++ b/appwrite/services/storage.py @@ -1,15 +1,39 @@ 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_buckets(self, queries = None, search = None): - """List buckets""" + 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 = {} @@ -17,13 +41,47 @@ def list_buckets(self, queries = None, search = None): api_params['search'] = search return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def create_bucket(self, bucket_id, name, permissions = None, file_security = None, enabled = None, maximum_file_size = None, allowed_file_extensions = None, compression = None, encryption = None, antivirus = None): - """Create bucket""" - + 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: @@ -48,10 +106,27 @@ def create_bucket(self, bucket_id, name, permissions = None, file_security = Non 'content-type': 'application/json', }, api_params) - def get_bucket(self, bucket_id): - """Get Bucket""" + 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: @@ -61,13 +136,47 @@ def get_bucket(self, bucket_id): return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def update_bucket(self, bucket_id, name, permissions = None, file_security = None, enabled = None, maximum_file_size = None, allowed_file_extensions = None, compression = None, encryption = None, antivirus = None): - """Update Bucket""" - + 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: @@ -92,10 +201,27 @@ def update_bucket(self, bucket_id, name, permissions = None, file_security = Non 'content-type': 'application/json', }, api_params) - def delete_bucket(self, bucket_id): - """Delete Bucket""" + 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: @@ -108,10 +234,31 @@ def delete_bucket(self, bucket_id): 'content-type': 'application/json', }, api_params) - def list_files(self, bucket_id, queries = None, search = None): - """List Files""" + 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: @@ -123,13 +270,44 @@ def list_files(self, bucket_id, queries = None, search = None): api_params['search'] = search return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def create_file(self, bucket_id, file_id, file, permissions = None, on_progress = None): - """Create File""" + 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: @@ -157,10 +335,29 @@ def create_file(self, bucket_id, file_id, file, permissions = None, on_progress 'content-type': 'multipart/form-data', }, api_params, param_name, on_progress, upload_id) - def get_file(self, bucket_id, file_id): - """Get File""" + 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: @@ -174,13 +371,35 @@ def get_file(self, bucket_id, file_id): return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def update_file(self, bucket_id, file_id, name = None, permissions = None): - """Update File""" - + 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: @@ -199,10 +418,29 @@ def update_file(self, bucket_id, file_id, name = None, permissions = None): 'content-type': 'application/json', }, api_params) - def delete_file(self, bucket_id, file_id): - """Delete File""" + 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: @@ -219,10 +457,31 @@ def delete_file(self, bucket_id, file_id): 'content-type': 'application/json', }, api_params) - def get_file_download(self, bucket_id, file_id): - """Get File for Download""" + 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: @@ -234,15 +493,58 @@ def get_file_download(self, bucket_id, file_id): 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, { - 'content-type': 'application/json', }, api_params) - def get_file_preview(self, bucket_id, 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""" - + 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: @@ -265,15 +567,36 @@ def get_file_preview(self, bucket_id, file_id, width = None, height = None, grav api_params['rotation'] = rotation api_params['background'] = background api_params['output'] = output + api_params['token'] = token return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def get_file_view(self, bucket_id, file_id): - """Get File for View""" + 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: @@ -285,7 +608,7 @@ def get_file_view(self, bucket_id, file_id): 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, { - 'content-type': 'application/json', }, api_params) diff --git a/appwrite/services/teams.py b/appwrite/services/teams.py index c7b4272..50e0297 100644 --- a/appwrite/services/teams.py +++ b/appwrite/services/teams.py @@ -1,15 +1,35 @@ 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, queries = None, search = None): - """List Teams""" + 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 = {} @@ -17,13 +37,33 @@ def list(self, queries = None, search = None): api_params['search'] = search return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def create(self, team_id, name, roles = None): - """Create Team""" + 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: @@ -41,10 +81,27 @@ def create(self, team_id, name, roles = None): 'content-type': 'application/json', }, api_params) - def get(self, team_id): - """Get Team""" + 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: @@ -54,13 +111,31 @@ def get(self, team_id): return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def update_name(self, team_id, name): - """Update Name""" + 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: @@ -77,10 +152,27 @@ def update_name(self, team_id, name): 'content-type': 'application/json', }, api_params) - def delete(self, team_id): - """Delete Team""" + 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: @@ -93,10 +185,31 @@ def delete(self, team_id): 'content-type': 'application/json', }, api_params) - def list_memberships(self, team_id, queries = None, search = None): - """List Team Memberships""" + 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: @@ -108,13 +221,48 @@ def list_memberships(self, team_id, queries = None, search = None): api_params['search'] = search return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def create_membership(self, team_id, roles, email = None, user_id = None, phone = None, url = None, name = None): - """Create Team Membership""" + 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: @@ -136,10 +284,29 @@ def create_membership(self, team_id, roles, email = None, user_id = None, phone 'content-type': 'application/json', }, api_params) - def get_membership(self, team_id, membership_id): - """Get Team Membership""" + 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: @@ -153,13 +320,34 @@ def get_membership(self, team_id, membership_id): return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def update_membership(self, team_id, membership_id, roles): - """Update Membership""" + 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: @@ -180,10 +368,29 @@ def update_membership(self, team_id, membership_id, roles): 'content-type': 'application/json', }, api_params) - def delete_membership(self, team_id, membership_id): - """Delete Team Membership""" + 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: @@ -200,10 +407,36 @@ def delete_membership(self, team_id, membership_id): 'content-type': 'application/json', }, api_params) - def update_membership_status(self, team_id, membership_id, user_id, secret): - """Update Team Membership Status""" + 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: @@ -228,10 +461,27 @@ def update_membership_status(self, team_id, membership_id, user_id, secret): 'content-type': 'application/json', }, api_params) - def get_prefs(self, team_id): - """Get Team Preferences""" + 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: @@ -241,13 +491,31 @@ def get_prefs(self, team_id): return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def update_prefs(self, team_id, prefs): - """Update Preferences""" + 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: 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 0962d7c..1af4e41 100644 --- a/appwrite/services/users.py +++ b/appwrite/services/users.py @@ -1,15 +1,38 @@ 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, queries = None, search = 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 = {} @@ -17,13 +40,37 @@ def list(self, queries = None, search = None): api_params['search'] = search return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def create(self, user_id, email = None, phone = None, password = None, name = None): - """Create User""" - + 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: @@ -40,10 +87,33 @@ def create(self, user_id, email = None, phone = None, password = None, name = No 'content-type': 'application/json', }, api_params) - def create_argon2_user(self, user_id, email, password, name = None): - """Create User with Argon2 Password""" - + 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: @@ -65,10 +135,33 @@ def create_argon2_user(self, user_id, email, password, name = None): 'content-type': 'application/json', }, api_params) - def create_bcrypt_user(self, user_id, email, password, name = None): - """Create User with Bcrypt Password""" - + 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: @@ -90,10 +183,29 @@ def create_bcrypt_user(self, user_id, email, password, name = None): 'content-type': 'application/json', }, api_params) - def list_identities(self, queries = None, search = None): - """List Identities""" + 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 = {} @@ -101,13 +213,29 @@ def list_identities(self, queries = None, search = None): api_params['search'] = search return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def delete_identity(self, identity_id): - """Delete Identity""" + 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: @@ -120,10 +248,33 @@ def delete_identity(self, identity_id): 'content-type': 'application/json', }, api_params) - def create_md5_user(self, user_id, email, password, name = None): - """Create User with MD5 Password""" - + 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: @@ -145,10 +296,33 @@ def create_md5_user(self, user_id, email, password, name = None): 'content-type': 'application/json', }, api_params) - def create_ph_pass_user(self, user_id, email, password, name = None): - """Create User with PHPass Password""" - + 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: @@ -170,10 +344,43 @@ def create_ph_pass_user(self, user_id, email, password, name = None): 'content-type': 'application/json', }, api_params) - def create_scrypt_user(self, user_id, email, password, password_salt, password_cpu, password_memory, password_parallel, password_length, name = None): - """Create User with Scrypt Password""" - + 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: @@ -215,10 +422,39 @@ def create_scrypt_user(self, user_id, email, password, password_salt, password_c 'content-type': 'application/json', }, api_params) - def create_scrypt_modified_user(self, user_id, email, password, password_salt, password_salt_separator, password_signer_key, name = None): - """Create User with Scrypt Modified Password""" - + 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: @@ -252,10 +488,35 @@ def create_scrypt_modified_user(self, user_id, email, password, password_salt, p 'content-type': 'application/json', }, api_params) - def create_sha_user(self, user_id, email, password, password_version = None, name = None): - """Create User with SHA Password""" - + 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: @@ -278,10 +539,27 @@ def create_sha_user(self, user_id, email, password, password_version = None, nam 'content-type': 'application/json', }, api_params) - def get(self, user_id): - """Get User""" + 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: @@ -291,13 +569,29 @@ def get(self, user_id): return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def delete(self, user_id): - """Delete User""" + 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: @@ -310,10 +604,29 @@ def delete(self, user_id): 'content-type': 'application/json', }, api_params) - def update_email(self, user_id, email): - """Update Email""" + 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: @@ -330,10 +643,70 @@ def update_email(self, user_id, email): 'content-type': 'application/json', }, api_params) - def update_labels(self, user_id, labels): - """Update User Labels""" + 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"') + + api_path = api_path.replace('{userId}', user_id) + + 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: @@ -350,10 +723,29 @@ def update_labels(self, user_id, labels): 'content-type': 'application/json', }, api_params) - def list_logs(self, user_id, queries = None): - """List User Logs""" + 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: @@ -364,13 +756,33 @@ def list_logs(self, user_id, queries = None): api_params['queries'] = queries return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def list_memberships(self, user_id): - """List User Memberships""" + 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: @@ -378,15 +790,243 @@ def list_memberships(self, user_id): 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 mfa is None: + raise AppwriteException('Missing required parameter: "mfa"') + + api_path = api_path.replace('{userId}', user_id) + + api_params['mfa'] = mfa + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, 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) + + + 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"') + + api_path = api_path.replace('{userId}', user_id) + + + 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. + + + 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('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', + }, 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) + + + return self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def update_name(self, user_id, name): - """Update Name""" + 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: @@ -403,10 +1043,29 @@ def update_name(self, user_id, name): 'content-type': 'application/json', }, api_params) - def update_password(self, user_id, password): - """Update Password""" + 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: @@ -423,10 +1082,29 @@ def update_password(self, user_id, password): 'content-type': 'application/json', }, api_params) - def update_phone(self, user_id, number): - """Update Phone""" + 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: @@ -443,10 +1121,27 @@ def update_phone(self, user_id, number): 'content-type': 'application/json', }, api_params) - def get_prefs(self, user_id): - """Get User Preferences""" + 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: @@ -456,13 +1151,31 @@ def get_prefs(self, user_id): return self.client.call('get', api_path, { - 'content-type': 'application/json', }, api_params) - def update_prefs(self, user_id, prefs): - """Update User Preferences""" + 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: @@ -479,10 +1192,27 @@ def update_prefs(self, user_id, prefs): 'content-type': 'application/json', }, api_params) - def list_sessions(self, user_id): - """List User Sessions""" + 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: @@ -492,13 +1222,64 @@ def list_sessions(self, 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"') + + api_path = api_path.replace('{userId}', user_id) + + + return self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def delete_sessions(self, user_id): - """Delete User Sessions""" + 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: @@ -511,10 +1292,29 @@ def delete_sessions(self, user_id): 'content-type': 'application/json', }, api_params) - def delete_session(self, user_id, session_id): - """Delete User Session""" + 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: @@ -531,10 +1331,29 @@ def delete_session(self, user_id, session_id): 'content-type': 'application/json', }, api_params) - def update_status(self, user_id, status): - """Update User Status""" + 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: @@ -551,10 +1370,286 @@ def update_status(self, user_id, status): 'content-type': 'application/json', }, api_params) - def update_email_verification(self, user_id, email_verification): - """Update Email Verification""" + 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"') + + 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"') + + api_path = api_path.replace('{userId}', user_id) + api_path = api_path.replace('{targetId}', target_id) + + api_params['identifier'] = identifier + api_params['providerId'] = provider_id + api_params['name'] = name + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, 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) + + + 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"') + + 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: @@ -571,10 +1666,29 @@ def update_email_verification(self, user_id, email_verification): 'content-type': 'application/json', }, api_params) - def update_phone_verification(self, user_id, phone_verification): - """Update Phone Verification""" + 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: 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 index 2203cdb..c130646 100644 --- a/docs/examples/account/create-phone-verification.md +++ b/docs/examples/account/create-phone-verification.md @@ -2,12 +2,9 @@ from appwrite.client import Client from appwrite.services.account import Account client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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/create-recovery.md b/docs/examples/account/create-recovery.md index 21130fe..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://cloud.appwrite.io/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 c45d0d4..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://cloud.appwrite.io/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 index bac4334..0c894fa 100644 --- a/docs/examples/account/delete-identity.md +++ b/docs/examples/account/delete-identity.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.account import Account client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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_identity('[IDENTITY_ID]') +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 8095cdc..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://cloud.appwrite.io/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 1728d61..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://cloud.appwrite.io/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-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 da2fd76..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://cloud.appwrite.io/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 25b8f03..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://cloud.appwrite.io/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.md b/docs/examples/account/get.md index f75bad7..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://cloud.appwrite.io/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 index 3c166d1..aeb23be 100644 --- a/docs/examples/account/list-identities.md +++ b/docs/examples/account/list-identities.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.account import Account client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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.list_identities() +result = account.list_identities( + queries = [] # optional +) diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/list-logs.md index 65802d8..67d193d 100644 --- a/docs/examples/account/list-logs.md +++ b/docs/examples/account/list-logs.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.account import Account client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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.list_logs() +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 index 12d5c81..c553a7b 100644 --- a/docs/examples/account/list-sessions.md +++ b/docs/examples/account/list-sessions.md @@ -2,12 +2,9 @@ from appwrite.client import Client from appwrite.services.account import Account client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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/update-email.md b/docs/examples/account/update-email.md index f4a6776..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://cloud.appwrite.io/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 eb1eb62..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://cloud.appwrite.io/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 955ada6..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://cloud.appwrite.io/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('') +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 index f2a75b4..bcc57de 100644 --- a/docs/examples/account/update-phone-verification.md +++ b/docs/examples/account/update-phone-verification.md @@ -2,13 +2,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 - .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_phone_verification('[USER_ID]', '[SECRET]') +result = account.update_phone_verification( + user_id = '', + secret = '' +) diff --git a/docs/examples/account/update-phone.md b/docs/examples/account/update-phone.md index aaee1f7..a2cb7d3 100644 --- a/docs/examples/account/update-phone.md +++ b/docs/examples/account/update-phone.md @@ -2,13 +2,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 - .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_phone('+12065550100', 'password') +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 e96546b..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://cloud.appwrite.io/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 b4ea8aa..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://cloud.appwrite.io/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 index e7234f7..abee773 100644 --- a/docs/examples/account/update-session.md +++ b/docs/examples/account/update-session.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.account import Account client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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_session('[SESSION_ID]') +result = account.update_session( + session_id = '' +) diff --git a/docs/examples/account/update-status.md b/docs/examples/account/update-status.md index 5924d4d..a5272f0 100644 --- a/docs/examples/account/update-status.md +++ b/docs/examples/account/update-status.md @@ -2,12 +2,9 @@ from appwrite.client import Client from appwrite.services.account import Account client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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/update-verification.md b/docs/examples/account/update-verification.md index 9a410a5..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://cloud.appwrite.io/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 9ed56d1..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://cloud.appwrite.io/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 9fa6b0f..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://cloud.appwrite.io/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 75b0315..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://cloud.appwrite.io/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 70d2e5f..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://cloud.appwrite.io/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 35015d9..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://cloud.appwrite.io/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 639fa03..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://cloud.appwrite.io/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 27fc8e2..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://cloud.appwrite.io/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/databases/create-boolean-attribute.md b/docs/examples/databases/create-boolean-attribute.md index f073d3d..f12f446 100644 --- a/docs/examples/databases/create-boolean-attribute.md +++ b/docs/examples/databases/create-boolean-attribute.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.create_boolean_attribute('[DATABASE_ID]', '[COLLECTION_ID]', '', False) +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 index 183c55c..596d4a9 100644 --- a/docs/examples/databases/create-collection.md +++ b/docs/examples/databases/create-collection.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.create_collection('[DATABASE_ID]', '[COLLECTION_ID]', '[NAME]') +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 index 5c77689..8fd59e6 100644 --- a/docs/examples/databases/create-datetime-attribute.md +++ b/docs/examples/databases/create-datetime-attribute.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.create_datetime_attribute('[DATABASE_ID]', '[COLLECTION_ID]', '', False) +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 index aa95de9..1eaf024 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.create_document('[DATABASE_ID]', '[COLLECTION_ID]', '[DOCUMENT_ID]', {}) +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 index 92cdcb2..230567a 100644 --- a/docs/examples/databases/create-email-attribute.md +++ b/docs/examples/databases/create-email-attribute.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.create_email_attribute('[DATABASE_ID]', '[COLLECTION_ID]', '', False) +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 index df66f12..de1ceb9 100644 --- a/docs/examples/databases/create-enum-attribute.md +++ b/docs/examples/databases/create-enum-attribute.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.create_enum_attribute('[DATABASE_ID]', '[COLLECTION_ID]', '', [], False) +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 index 0bfe424..53305c8 100644 --- a/docs/examples/databases/create-float-attribute.md +++ b/docs/examples/databases/create-float-attribute.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.create_float_attribute('[DATABASE_ID]', '[COLLECTION_ID]', '', False) +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 index 78a7d33..f7bb455 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -1,14 +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 - .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 databases = Databases(client) -result = databases.create_index('[DATABASE_ID]', '[COLLECTION_ID]', '', 'key', []) +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 index b3cce2b..92e8b0f 100644 --- a/docs/examples/databases/create-integer-attribute.md +++ b/docs/examples/databases/create-integer-attribute.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.create_integer_attribute('[DATABASE_ID]', '[COLLECTION_ID]', '', False) +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 index 967d284..a7f424b 100644 --- a/docs/examples/databases/create-ip-attribute.md +++ b/docs/examples/databases/create-ip-attribute.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.create_ip_attribute('[DATABASE_ID]', '[COLLECTION_ID]', '', False) +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 index 4f69eca..6c8f4dc 100644 --- a/docs/examples/databases/create-relationship-attribute.md +++ b/docs/examples/databases/create-relationship-attribute.md @@ -1,14 +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 - .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 databases = Databases(client) -result = databases.create_relationship_attribute('[DATABASE_ID]', '[COLLECTION_ID]', '[RELATED_COLLECTION_ID]', 'oneToOne') +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 index 00bbbe9..dc434cc 100644 --- a/docs/examples/databases/create-string-attribute.md +++ b/docs/examples/databases/create-string-attribute.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.create_string_attribute('[DATABASE_ID]', '[COLLECTION_ID]', '', 1, False) +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 index fd5b7f4..af37573 100644 --- a/docs/examples/databases/create-url-attribute.md +++ b/docs/examples/databases/create-url-attribute.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.create_url_attribute('[DATABASE_ID]', '[COLLECTION_ID]', '', False) +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 index e4a8320..0492203 100644 --- a/docs/examples/databases/create.md +++ b/docs/examples/databases/create.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.create('[DATABASE_ID]', '[NAME]') +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 index 41871b2..e1c4eec 100644 --- a/docs/examples/databases/delete-attribute.md +++ b/docs/examples/databases/delete-attribute.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.delete_attribute('[DATABASE_ID]', '[COLLECTION_ID]', '') +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 index 998bb61..02f1e1c 100644 --- a/docs/examples/databases/delete-collection.md +++ b/docs/examples/databases/delete-collection.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.delete_collection('[DATABASE_ID]', '[COLLECTION_ID]') +result = databases.delete_collection( + database_id = '', + collection_id = '' +) diff --git a/docs/examples/databases/delete-document.md b/docs/examples/databases/delete-document.md index 605b087..57f8b3b 100644 --- a/docs/examples/databases/delete-document.md +++ b/docs/examples/databases/delete-document.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.delete_document('[DATABASE_ID]', '[COLLECTION_ID]', '[DOCUMENT_ID]') +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 index a53e06c..0060064 100644 --- a/docs/examples/databases/delete-index.md +++ b/docs/examples/databases/delete-index.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.delete_index('[DATABASE_ID]', '[COLLECTION_ID]', '') +result = databases.delete_index( + database_id = '', + collection_id = '', + key = '' +) diff --git a/docs/examples/databases/delete.md b/docs/examples/databases/delete.md index 780e145..be64e8c 100644 --- a/docs/examples/databases/delete.md +++ b/docs/examples/databases/delete.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.databases import Databases client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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 databases = Databases(client) -result = databases.delete('[DATABASE_ID]') +result = databases.delete( + database_id = '' +) diff --git a/docs/examples/databases/get-attribute.md b/docs/examples/databases/get-attribute.md index 0a61052..dcdb0a6 100644 --- a/docs/examples/databases/get-attribute.md +++ b/docs/examples/databases/get-attribute.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.get_attribute('[DATABASE_ID]', '[COLLECTION_ID]', '') +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 index 90f57a3..0833b4f 100644 --- a/docs/examples/databases/get-collection.md +++ b/docs/examples/databases/get-collection.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.get_collection('[DATABASE_ID]', '[COLLECTION_ID]') +result = databases.get_collection( + database_id = '', + collection_id = '' +) diff --git a/docs/examples/databases/get-document.md b/docs/examples/databases/get-document.md index 7085384..aff5008 100644 --- a/docs/examples/databases/get-document.md +++ b/docs/examples/databases/get-document.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.get_document('[DATABASE_ID]', '[COLLECTION_ID]', '[DOCUMENT_ID]') +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 index 3213c66..6971683 100644 --- a/docs/examples/databases/get-index.md +++ b/docs/examples/databases/get-index.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.get_index('[DATABASE_ID]', '[COLLECTION_ID]', '') +result = databases.get_index( + database_id = '', + collection_id = '', + key = '' +) diff --git a/docs/examples/databases/get.md b/docs/examples/databases/get.md index 93a46b3..c8191a3 100644 --- a/docs/examples/databases/get.md +++ b/docs/examples/databases/get.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.databases import Databases client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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 databases = Databases(client) -result = databases.get('[DATABASE_ID]') +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 index 632202c..c97a5ce 100644 --- a/docs/examples/databases/list-attributes.md +++ b/docs/examples/databases/list-attributes.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.list_attributes('[DATABASE_ID]', '[COLLECTION_ID]') +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 index d0c98da..17d0a3d 100644 --- a/docs/examples/databases/list-collections.md +++ b/docs/examples/databases/list-collections.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.list_collections('[DATABASE_ID]') +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 index 5eb03b2..8b450cd 100644 --- a/docs/examples/databases/list-documents.md +++ b/docs/examples/databases/list-documents.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.list_documents('[DATABASE_ID]', '[COLLECTION_ID]') +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 index b4224be..1457151 100644 --- a/docs/examples/databases/list-indexes.md +++ b/docs/examples/databases/list-indexes.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.list_indexes('[DATABASE_ID]', '[COLLECTION_ID]') +result = databases.list_indexes( + database_id = '', + collection_id = '', + queries = [] # optional +) diff --git a/docs/examples/databases/list.md b/docs/examples/databases/list.md index 3aa6839..58336c9 100644 --- a/docs/examples/databases/list.md +++ b/docs/examples/databases/list.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.list() +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 index e6a7d55..a0f72a4 100644 --- a/docs/examples/databases/update-boolean-attribute.md +++ b/docs/examples/databases/update-boolean-attribute.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.update_boolean_attribute('[DATABASE_ID]', '[COLLECTION_ID]', '', False, False) +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 index 4a38aab..2e5be50 100644 --- a/docs/examples/databases/update-collection.md +++ b/docs/examples/databases/update-collection.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.update_collection('[DATABASE_ID]', '[COLLECTION_ID]', '[NAME]') +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 index 5c79257..29bc6be 100644 --- a/docs/examples/databases/update-datetime-attribute.md +++ b/docs/examples/databases/update-datetime-attribute.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.update_datetime_attribute('[DATABASE_ID]', '[COLLECTION_ID]', '', False, '') +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 index c768c54..9ef6527 100644 --- a/docs/examples/databases/update-document.md +++ b/docs/examples/databases/update-document.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.update_document('[DATABASE_ID]', '[COLLECTION_ID]', '[DOCUMENT_ID]') +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 index 8148b01..c833789 100644 --- a/docs/examples/databases/update-email-attribute.md +++ b/docs/examples/databases/update-email-attribute.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.update_email_attribute('[DATABASE_ID]', '[COLLECTION_ID]', '', False, 'email@example.com') +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 index 65ef26f..6186a72 100644 --- a/docs/examples/databases/update-enum-attribute.md +++ b/docs/examples/databases/update-enum-attribute.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.update_enum_attribute('[DATABASE_ID]', '[COLLECTION_ID]', '', [], False, '[DEFAULT]') +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 index efbf1ad..68cb7d7 100644 --- a/docs/examples/databases/update-float-attribute.md +++ b/docs/examples/databases/update-float-attribute.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.update_float_attribute('[DATABASE_ID]', '[COLLECTION_ID]', '', False, None, None, None) +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 index 61c74b8..05c6bfe 100644 --- a/docs/examples/databases/update-integer-attribute.md +++ b/docs/examples/databases/update-integer-attribute.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.update_integer_attribute('[DATABASE_ID]', '[COLLECTION_ID]', '', False, None, None, None) +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 index 7d5a35d..550d3af 100644 --- a/docs/examples/databases/update-ip-attribute.md +++ b/docs/examples/databases/update-ip-attribute.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.update_ip_attribute('[DATABASE_ID]', '[COLLECTION_ID]', '', False, '') +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 index 7c426a6..3b6c8e9 100644 --- a/docs/examples/databases/update-relationship-attribute.md +++ b/docs/examples/databases/update-relationship-attribute.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.update_relationship_attribute('[DATABASE_ID]', '[COLLECTION_ID]', '') +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 index 2ee236e..5b66fb0 100644 --- a/docs/examples/databases/update-string-attribute.md +++ b/docs/examples/databases/update-string-attribute.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.update_string_attribute('[DATABASE_ID]', '[COLLECTION_ID]', '', False, '[DEFAULT]') +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 index 119c787..4a62027 100644 --- a/docs/examples/databases/update-url-attribute.md +++ b/docs/examples/databases/update-url-attribute.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.update_url_attribute('[DATABASE_ID]', '[COLLECTION_ID]', '', False, 'https://example.com') +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 index d46692e..35d2c0c 100644 --- a/docs/examples/databases/update.md +++ b/docs/examples/databases/update.md @@ -2,13 +2,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 - .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 databases = Databases(client) -result = databases.update('[DATABASE_ID]', '[NAME]') +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-build.md b/docs/examples/functions/create-build.md deleted file mode 100644 index 76888f8..0000000 --- a/docs/examples/functions/create-build.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.functions import Functions - -client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -functions = Functions(client) - -result = functions.create_build('[FUNCTION_ID]', '[DEPLOYMENT_ID]', '[BUILD_ID]') diff --git a/docs/examples/functions/create-deployment.md b/docs/examples/functions/create-deployment.md index 1ee1be0..0774005 100644 --- a/docs/examples/functions/create-deployment.md +++ b/docs/examples/functions/create-deployment.md @@ -1,15 +1,18 @@ from appwrite.client import Client -from appwrite.input_file import InputFile 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 - .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_deployment('[FUNCTION_ID]', InputFile.from_path('file.png'), False) +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 7c04522..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://cloud.appwrite.io/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-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 index f33ed08..2089830 100644 --- a/docs/examples/functions/create-variable.md +++ b/docs/examples/functions/create-variable.md @@ -2,13 +2,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 - .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_variable('[FUNCTION_ID]', '[KEY]', '[VALUE]') +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 bf66396..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://cloud.appwrite.io/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-18.0') +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 index 42d526e..f874b2d 100644 --- a/docs/examples/functions/delete-deployment.md +++ b/docs/examples/functions/delete-deployment.md @@ -2,13 +2,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 - .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_deployment('[FUNCTION_ID]', '[DEPLOYMENT_ID]') +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-variable.md b/docs/examples/functions/delete-variable.md index cae0f2d..a6e3dc8 100644 --- a/docs/examples/functions/delete-variable.md +++ b/docs/examples/functions/delete-variable.md @@ -2,13 +2,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 - .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_variable('[FUNCTION_ID]', '[VARIABLE_ID]') +result = functions.delete_variable( + function_id = '', + variable_id = '' +) diff --git a/docs/examples/functions/delete.md b/docs/examples/functions/delete.md index e89213e..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://cloud.appwrite.io/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/download-deployment.md b/docs/examples/functions/download-deployment.md deleted file mode 100644 index ee51f67..0000000 --- a/docs/examples/functions/download-deployment.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.functions import Functions - -client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -functions = Functions(client) - -result = functions.download_deployment('[FUNCTION_ID]', '[DEPLOYMENT_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 index 6257b59..59a1374 100644 --- a/docs/examples/functions/get-deployment.md +++ b/docs/examples/functions/get-deployment.md @@ -2,13 +2,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 - .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_deployment('[FUNCTION_ID]', '[DEPLOYMENT_ID]') +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 f0e4f0d..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://cloud.appwrite.io/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-variable.md b/docs/examples/functions/get-variable.md index 4e71bff..629948e 100644 --- a/docs/examples/functions/get-variable.md +++ b/docs/examples/functions/get-variable.md @@ -2,13 +2,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 - .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_variable('[FUNCTION_ID]', '[VARIABLE_ID]') +result = functions.get_variable( + function_id = '', + variable_id = '' +) diff --git a/docs/examples/functions/get.md b/docs/examples/functions/get.md index 30e1d59..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://cloud.appwrite.io/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 index d1797a1..4eb92f6 100644 --- a/docs/examples/functions/list-deployments.md +++ b/docs/examples/functions/list-deployments.md @@ -2,13 +2,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 - .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_deployments('[FUNCTION_ID]') +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 d70f004..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://cloud.appwrite.io/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 19b85e2..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://cloud.appwrite.io/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-variables.md b/docs/examples/functions/list-variables.md index 9a72bba..ebc19c5 100644 --- a/docs/examples/functions/list-variables.md +++ b/docs/examples/functions/list-variables.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.functions import Functions client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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_variables('[FUNCTION_ID]') +result = functions.list_variables( + function_id = '' +) diff --git a/docs/examples/functions/list.md b/docs/examples/functions/list.md index b8442e5..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://cloud.appwrite.io/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-deployment.md b/docs/examples/functions/update-deployment.md deleted file mode 100644 index 87dd097..0000000 --- a/docs/examples/functions/update-deployment.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.functions import Functions - -client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -functions = Functions(client) - -result = functions.update_deployment('[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-variable.md b/docs/examples/functions/update-variable.md index ab5b43a..f8bcc03 100644 --- a/docs/examples/functions/update-variable.md +++ b/docs/examples/functions/update-variable.md @@ -2,13 +2,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 - .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_variable('[FUNCTION_ID]', '[VARIABLE_ID]', '[KEY]') +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 3960054..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://cloud.appwrite.io/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 index 24226a5..189892a 100644 --- a/docs/examples/graphql/mutation.md +++ b/docs/examples/graphql/mutation.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.graphql import Graphql client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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 graphql = Graphql(client) -result = graphql.mutation({}) +result = graphql.mutation( + query = {} +) diff --git a/docs/examples/graphql/query.md b/docs/examples/graphql/query.md index 8e1597c..585a502 100644 --- a/docs/examples/graphql/query.md +++ b/docs/examples/graphql/query.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.graphql import Graphql client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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 graphql = Graphql(client) -result = graphql.query({}) +result = graphql.query( + query = {} +) diff --git a/docs/examples/health/get-antivirus.md b/docs/examples/health/get-antivirus.md index fbfaf0e..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://cloud.appwrite.io/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 40bc010..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://cloud.appwrite.io/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 803dd73..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://cloud.appwrite.io/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 index 43ada69..e5115d0 100644 --- a/docs/examples/health/get-pub-sub.md +++ b/docs/examples/health/get-pub-sub.md @@ -2,12 +2,9 @@ from appwrite.client import Client from appwrite.services.health import Health client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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-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 4fb0266..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://cloud.appwrite.io/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 92e4e20..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://cloud.appwrite.io/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 b798ad7..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://cloud.appwrite.io/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 new file mode 100644 index 0000000..266ca82 --- /dev/null +++ b/docs/examples/health/get-queue-usage.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_usage( + threshold = None # optional +) diff --git a/docs/examples/health/get-queue-webhooks.md b/docs/examples/health/get-queue-webhooks.md index 8406de1..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://cloud.appwrite.io/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-queue.md b/docs/examples/health/get-queue.md deleted file mode 100644 index 5a35588..0000000 --- a/docs/examples/health/get-queue.md +++ /dev/null @@ -1,14 +0,0 @@ -from appwrite.client import Client -from appwrite.services.health import Health - -client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/v1') # Your API Endpoint - .set_project('5df5acd0d48c2') # Your project ID - .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key -) - -health = Health(client) - -result = health.get_queue() diff --git a/docs/examples/health/get-storage-local.md b/docs/examples/health/get-storage-local.md index bb2533e..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://cloud.appwrite.io/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 9fe313d..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://cloud.appwrite.io/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 d3ff594..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://cloud.appwrite.io/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.md b/docs/examples/locale/get.md index 06b04f2..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://cloud.appwrite.io/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 index 3dc6cf8..5f3e501 100644 --- a/docs/examples/locale/list-codes.md +++ b/docs/examples/locale/list-codes.md @@ -2,12 +2,9 @@ from appwrite.client import Client from appwrite.services.locale import Locale client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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-continents.md b/docs/examples/locale/list-continents.md index ba9c94f..0aead81 100644 --- a/docs/examples/locale/list-continents.md +++ b/docs/examples/locale/list-continents.md @@ -2,12 +2,9 @@ from appwrite.client import Client from appwrite.services.locale import Locale client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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-countries-e-u.md b/docs/examples/locale/list-countries-e-u.md index ea4c43c..f88e331 100644 --- a/docs/examples/locale/list-countries-e-u.md +++ b/docs/examples/locale/list-countries-e-u.md @@ -2,12 +2,9 @@ from appwrite.client import Client from appwrite.services.locale import Locale client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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-countries-phones.md b/docs/examples/locale/list-countries-phones.md index 5a4cafe..b1fdc1a 100644 --- a/docs/examples/locale/list-countries-phones.md +++ b/docs/examples/locale/list-countries-phones.md @@ -2,12 +2,9 @@ from appwrite.client import Client from appwrite.services.locale import Locale client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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-countries.md b/docs/examples/locale/list-countries.md index f8ec83c..0c5b23c 100644 --- a/docs/examples/locale/list-countries.md +++ b/docs/examples/locale/list-countries.md @@ -2,12 +2,9 @@ from appwrite.client import Client from appwrite.services.locale import Locale client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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-currencies.md b/docs/examples/locale/list-currencies.md index 347e81c..20009d6 100644 --- a/docs/examples/locale/list-currencies.md +++ b/docs/examples/locale/list-currencies.md @@ -2,12 +2,9 @@ from appwrite.client import Client from appwrite.services.locale import Locale client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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-languages.md b/docs/examples/locale/list-languages.md index ce50a6e..1962a83 100644 --- a/docs/examples/locale/list-languages.md +++ b/docs/examples/locale/list-languages.md @@ -2,12 +2,9 @@ from appwrite.client import Client from appwrite.services.locale import Locale client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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/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 index 72ffdcc..9672782 100644 --- a/docs/examples/storage/create-bucket.md +++ b/docs/examples/storage/create-bucket.md @@ -2,13 +2,21 @@ from appwrite.client import Client from appwrite.services.storage import Storage client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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 storage = Storage(client) -result = storage.create_bucket('[BUCKET_ID]', '[NAME]') +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 b469b5b..6e57284 100644 --- a/docs/examples/storage/create-file.md +++ b/docs/examples/storage/create-file.md @@ -1,15 +1,17 @@ from appwrite.client import Client -from appwrite.input_file import InputFile from appwrite.services.storage import Storage +from appwrite.input_file import InputFile client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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('[BUCKET_ID]', '[FILE_ID]', InputFile.from_path('file.png')) +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 index 60dc107..dd8e8eb 100644 --- a/docs/examples/storage/delete-bucket.md +++ b/docs/examples/storage/delete-bucket.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.storage import Storage client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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 storage = Storage(client) -result = storage.delete_bucket('[BUCKET_ID]') +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 9bed0af..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://cloud.appwrite.io/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('[BUCKET_ID]', '[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 index 7ea64f2..e5eeb4c 100644 --- a/docs/examples/storage/get-bucket.md +++ b/docs/examples/storage/get-bucket.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.storage import Storage client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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 storage = Storage(client) -result = storage.get_bucket('[BUCKET_ID]') +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 e9f5cce..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://cloud.appwrite.io/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('[BUCKET_ID]', '[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 4e12291..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://cloud.appwrite.io/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('[BUCKET_ID]', '[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 01cbfaf..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://cloud.appwrite.io/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('[BUCKET_ID]', '[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 f83ed8a..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://cloud.appwrite.io/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('[BUCKET_ID]', '[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 index 204fd95..51a1ae6 100644 --- a/docs/examples/storage/list-buckets.md +++ b/docs/examples/storage/list-buckets.md @@ -2,13 +2,13 @@ from appwrite.client import Client from appwrite.services.storage import Storage client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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 storage = Storage(client) -result = storage.list_buckets() +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 63101e2..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://cloud.appwrite.io/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('[BUCKET_ID]') +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 index fb1b76b..f2e741a 100644 --- a/docs/examples/storage/update-bucket.md +++ b/docs/examples/storage/update-bucket.md @@ -2,13 +2,21 @@ from appwrite.client import Client from appwrite.services.storage import Storage client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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 storage = Storage(client) -result = storage.update_bucket('[BUCKET_ID]', '[NAME]') +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 24a92e3..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://cloud.appwrite.io/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('[BUCKET_ID]', '[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 cde8455..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://cloud.appwrite.io/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]', []) +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 c690123..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://cloud.appwrite.io/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 f8d8759..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://cloud.appwrite.io/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 4fc0fa4..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://cloud.appwrite.io/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 e9c62ae..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://cloud.appwrite.io/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-prefs.md b/docs/examples/teams/get-prefs.md index 40909fa..8d64589 100644 --- a/docs/examples/teams/get-prefs.md +++ b/docs/examples/teams/get-prefs.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.teams import Teams client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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.get_prefs('[TEAM_ID]') +result = teams.get_prefs( + team_id = '<TEAM_ID>' +) diff --git a/docs/examples/teams/get.md b/docs/examples/teams/get.md index fdca2fc..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://cloud.appwrite.io/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 index 63e662a..6e6f15a 100644 --- a/docs/examples/teams/list-memberships.md +++ b/docs/examples/teams/list-memberships.md @@ -2,13 +2,14 @@ from appwrite.client import Client from appwrite.services.teams import Teams client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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_memberships('[TEAM_ID]') +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 e60cb60..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://cloud.appwrite.io/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-status.md b/docs/examples/teams/update-membership-status.md index a6cd4cd..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://cloud.appwrite.io/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 index 816c6ad..db20c5a 100644 --- a/docs/examples/teams/update-membership.md +++ b/docs/examples/teams/update-membership.md @@ -2,13 +2,14 @@ from appwrite.client import Client from appwrite.services.teams import Teams client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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.update_membership('[TEAM_ID]', '[MEMBERSHIP_ID]', []) +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 index 929f4ec..160b496 100644 --- a/docs/examples/teams/update-name.md +++ b/docs/examples/teams/update-name.md @@ -2,13 +2,13 @@ from appwrite.client import Client from appwrite.services.teams import Teams client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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.update_name('[TEAM_ID]', '[NAME]') +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 index 4176c62..e82da1b 100644 --- a/docs/examples/teams/update-prefs.md +++ b/docs/examples/teams/update-prefs.md @@ -2,13 +2,13 @@ from appwrite.client import Client from appwrite.services.teams import Teams client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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_prefs('[TEAM_ID]', {}) +result = teams.update_prefs( + team_id = '<TEAM_ID>', + prefs = {} +) 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 index be1e8ce..5e95cc2 100644 --- a/docs/examples/users/create-argon2user.md +++ b/docs/examples/users/create-argon2user.md @@ -2,13 +2,15 @@ from appwrite.client import Client from appwrite.services.users import Users client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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_argon2_user('[USER_ID]', 'email@example.com', 'password') +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 index 77c9918..d3d9e21 100644 --- a/docs/examples/users/create-bcrypt-user.md +++ b/docs/examples/users/create-bcrypt-user.md @@ -2,13 +2,15 @@ from appwrite.client import Client from appwrite.services.users import Users client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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_bcrypt_user('[USER_ID]', 'email@example.com', 'password') +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 index f3ab3f8..b1cbb53 100644 --- a/docs/examples/users/create-m-d5user.md +++ b/docs/examples/users/create-m-d5user.md @@ -2,13 +2,15 @@ from appwrite.client import Client from appwrite.services.users import Users client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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_md5_user('[USER_ID]', 'email@example.com', 'password') +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 index e715f47..33f65f4 100644 --- a/docs/examples/users/create-p-h-pass-user.md +++ b/docs/examples/users/create-p-h-pass-user.md @@ -2,13 +2,15 @@ from appwrite.client import Client from appwrite.services.users import Users client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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_ph_pass_user('[USER_ID]', 'email@example.com', 'password') +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 index 2a2db5a..5b4c8f8 100644 --- a/docs/examples/users/create-s-h-a-user.md +++ b/docs/examples/users/create-s-h-a-user.md @@ -2,13 +2,16 @@ from appwrite.client import Client from appwrite.services.users import Users client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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_sha_user('[USER_ID]', 'email@example.com', 'password') +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 index 0b42e98..9d644ce 100644 --- a/docs/examples/users/create-scrypt-modified-user.md +++ b/docs/examples/users/create-scrypt-modified-user.md @@ -2,13 +2,18 @@ from appwrite.client import Client from appwrite.services.users import Users client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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_scrypt_modified_user('[USER_ID]', 'email@example.com', 'password', '[PASSWORD_SALT]', '[PASSWORD_SALT_SEPARATOR]', '[PASSWORD_SIGNER_KEY]') +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 index b445623..f442ab9 100644 --- a/docs/examples/users/create-scrypt-user.md +++ b/docs/examples/users/create-scrypt-user.md @@ -2,13 +2,20 @@ from appwrite.client import Client from appwrite.services.users import Users client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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_scrypt_user('[USER_ID]', 'email@example.com', 'password', '[PASSWORD_SALT]', None, None, None, None) +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 05249c0..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://cloud.appwrite.io/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]') +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 index d103824..412fbd3 100644 --- a/docs/examples/users/delete-identity.md +++ b/docs/examples/users/delete-identity.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.users import Users client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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_identity('[IDENTITY_ID]') +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 26b041d..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://cloud.appwrite.io/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 dabe4f6..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://cloud.appwrite.io/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 7fdc775..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://cloud.appwrite.io/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-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 2bbaa88..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://cloud.appwrite.io/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-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 463957d..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://cloud.appwrite.io/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 index 0addd3e..0fc7811 100644 --- a/docs/examples/users/list-identities.md +++ b/docs/examples/users/list-identities.md @@ -2,13 +2,13 @@ from appwrite.client import Client from appwrite.services.users import Users client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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_identities() +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 index ca3a5eb..6cbbe49 100644 --- a/docs/examples/users/list-logs.md +++ b/docs/examples/users/list-logs.md @@ -2,13 +2,13 @@ from appwrite.client import Client from appwrite.services.users import Users client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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_logs('[USER_ID]') +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 index 0dfb97a..c0d2f2a 100644 --- a/docs/examples/users/list-memberships.md +++ b/docs/examples/users/list-memberships.md @@ -2,13 +2,14 @@ from appwrite.client import Client from appwrite.services.users import Users client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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_memberships('[USER_ID]') +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 index 5f8fbd6..77b04c9 100644 --- a/docs/examples/users/list-sessions.md +++ b/docs/examples/users/list-sessions.md @@ -2,13 +2,12 @@ from appwrite.client import Client from appwrite.services.users import Users client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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_sessions('[USER_ID]') +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 baaf42c..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://cloud.appwrite.io/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 index 8be33ad..2605861 100644 --- a/docs/examples/users/update-email-verification.md +++ b/docs/examples/users/update-email-verification.md @@ -2,13 +2,13 @@ from appwrite.client import Client from appwrite.services.users import Users client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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_verification('[USER_ID]', False) +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 4899bd3..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://cloud.appwrite.io/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 index b2d4c2d..b9af53a 100644 --- a/docs/examples/users/update-labels.md +++ b/docs/examples/users/update-labels.md @@ -2,13 +2,13 @@ from appwrite.client import Client from appwrite.services.users import Users client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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_labels('[USER_ID]', []) +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 66bb6b2..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://cloud.appwrite.io/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 e79f125..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://cloud.appwrite.io/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]', '') +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 index e42317c..1d2656c 100644 --- a/docs/examples/users/update-phone-verification.md +++ b/docs/examples/users/update-phone-verification.md @@ -2,13 +2,13 @@ from appwrite.client import Client from appwrite.services.users import Users client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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_phone_verification('[USER_ID]', False) +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 index 6df39fc..14826bb 100644 --- a/docs/examples/users/update-phone.md +++ b/docs/examples/users/update-phone.md @@ -2,13 +2,13 @@ from appwrite.client import Client from appwrite.services.users import Users client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/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_phone('[USER_ID]', '+12065550100') +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 53d1e52..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://cloud.appwrite.io/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 6d1577d..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://cloud.appwrite.io/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/setup.py b/setup.py index 851e7e4..18c78cc 100644 --- a/setup.py +++ b/setup.py @@ -7,8 +7,13 @@ setuptools.setup( name = 'appwrite', - packages = ['appwrite', 'appwrite/services'], - version = '4.0.0', + 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, @@ -18,11 +23,10 @@ maintainer = 'Appwrite Team', maintainer_email = 'team@appwrite.io', url = 'https://appwrite.io/support', - download_url='https://github.com/appwrite/sdk-for-python/archive/4.0.0.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', <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> <html xmlns='http://www.w3.org/1999/xhtml'> <head> <title>pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy